Commit Graph

559 Commits

Author SHA1 Message Date
Argyrios Kyrtzidis
84e20a0620 [AST] Break down IdentTypeRepr to different subtypes.
This makes memory allocation for it more efficient and it's more convenient to handle.

Swift SVN r12541
2014-01-18 20:19:09 +00:00
Chris Lattner
7e67fdb30a decls always can get to an ASTContext, remove the unneeded
ASTContext argument from VarDecl::setComputedAccessors.


Swift SVN r12538
2014-01-18 20:04:05 +00:00
Doug Gregor
11de3455d6 Introduce TypeRepr cloning and use it to fix interface types for getters/setters.
Swift SVN r12450
2014-01-17 01:19:01 +00:00
Jordan Rose
11008f0ed1 Split diagnostics out into separate files.
Thanks to the way we've set up our diagnostics engine, there's not actually
a reason for /everything/ to get rebuilt when /one/ diagnostic changes.
I've split them up into five categories for now: Parse, Sema, SIL, IRGen,
and Frontend, plus a set of "Common" diagnostics that are used in multiple
areas of the compiler. We can massage this later.

No functionality change, but should speed up compile times!

Swift SVN r12438
2014-01-17 00:15:12 +00:00
Jordan Rose
69a8860a53 Move diagnostics enum out-of-line.
Groundwork for splitting up Diagnostics.def.

Swift SVN r12437
2014-01-17 00:15:10 +00:00
Argyrios Kyrtzidis
357986bb9e [Parser] When parsing a constructor with a missing '{', at least return the declaration.
Swift SVN r12236
2014-01-13 18:13:14 +00:00
Doug Gregor
a534f6978a Add a new class attribute requires_stored_property_inits.
This attribute states that all stored properties within the class must
provide initial values. This will allow us to move stored property
initialization into Objective-C's post-allocation initialization hook,
.cxx_construct.

Swift SVN r12228
2014-01-13 16:31:22 +00:00
Chris Lattner
c081e7ddb1 random comment cleanups.
Swift SVN r12133
2014-01-10 20:25:24 +00:00
Chris Lattner
b87dd57079 implement SILGen and parser support for 'type' let's, implementing rdar://15767586.
General compiler support is missing for 'type' properties on classes, and lets don't
work either, but at least we have a nice diagnostic now.
also, rename static -> type in a few internal diagnostic names.



Swift SVN r12102
2014-01-09 22:42:24 +00:00
Chris Lattner
6b7b7522ca Two minor tweaks:
- improve error recovery when rejecting lets with getters/setters.
 - mark the 'self' parameter of an implicitly generator init() method
   as 'let' when it is for a class.



Swift SVN r12098
2014-01-09 21:31:52 +00:00
Doug Gregor
2bb0b57682 Add an error on "static" with a Fix-It to "type".
Swift SVN r12049
2014-01-08 05:29:04 +00:00
Doug Gregor
1318c61f9f Update grammar in the parser for "static" -> "type".
Swift SVN r12046
2014-01-08 05:00:25 +00:00
Doug Gregor
9412c07dea Switch 'static' to 'type' in tests.
Switch some diagnostic text from 'static' over to 'type' to make
things easier, and fix up some parsing issues with selector-style
declarations found by doing this. NFC


Swift SVN r12030
2014-01-08 01:37:32 +00:00
Doug Gregor
7cf688123b Allow "type var" and "type func" as synonyms for "static var" and "static func".
Swift SVN r12025
2014-01-08 00:59:22 +00:00
Chris Lattner
468ead25a6 allow 'var' and 'let' to appear in patterns (not just matching patterns).
This allows them to appear in argument lists of functions, enabling behavior
like this:

func test_arguments(a : Int, var b : Int, let c : Int) {
  a = 1  // ok (for now).
  b = 2  // ok.
  c = 3  // expected-error {{cannot assign to the result of this expression}}
}



Swift SVN r11746
2013-12-30 21:48:06 +00:00
Chris Lattner
fc5606ff19 Now that enough bugs are fixed :), mark more things as immutable values:
- foreach enumerators
- closure arguments with explicit patterns
- 'value' in a setter
- subscript arguments



Swift SVN r11681
2013-12-27 23:30:52 +00:00
Jordan Rose
7a30de2efe Disallow inheritance clauses for concrete typealiases.
typealias MyInt: ForwardIndex = Int

There is no real reason to allow this; it's just a static_assert that Int
conforms to ForwardIndex, which would be better spelled some other way.

This only applies to concrete typealiases, i.e. those that simply alias an
underlying type. Associated types can still have both inheritance clauses
and a (default) underlying type.

Swift SVN r11481
2013-12-19 21:13:54 +00:00
Joe Groff
9929f25f74 IRGen: Build correct TypeInfos for thin and thick function types.
Derive the appropriate ExtraData for a SILFunctionType from its thinness and calling convention. Consider @!thin @cc(witness_method) as having ExtraData::Metatype. This should eliminate all of the unspoken gentleperson's agreements that let thin and witness functions survive IRGen currently when we can turn on SIL witness tables.

Swift SVN r11446
2013-12-18 23:03:39 +00:00
Chris Lattner
42d0fdadcf - Introduce the ability for attributes to be inverted with !.
- Switch @mutable to be a tri-state attribute that is invertable with @!mutable.
- Move the semantic form of 'mutable' to being a bit on FuncDecl instead of
  something in DeclAttrs.  The former is a binary bit, the later is a tristate
  which differentiates between "not present", "present and set" "present and inverted".
- Diagnose some invalid uses of @mutable, e.g. on class methods.
- Make setters default to mutable, and allow them to be switched with @!mutable.



Swift SVN r11439
2013-12-18 21:38:53 +00:00
Doug Gregor
ec4913b0ea Implement default definitions for associated types.
Addresses <rdar://problem/14292873>.


Swift SVN r11422
2013-12-18 06:24:53 +00:00
Chris Lattner
51862b91fd rename the inout decl attribute (not the type attribute) to @mutating.
Swift SVN r11416
2013-12-18 04:44:56 +00:00
John McCall
7173cec9db Thread contextual information about parsing the top-level
through various bits and use that to globally discriminate.

Swift SVN r11379
2013-12-17 04:31:40 +00:00
Chris Lattner
71af72a0ca Change a few more kinds of arguments to be 'var' arguments instead of 'let'
arguments.  Until we have @inout methods on structs, we can't mark anything
that can be address-exposed.  This temporarily regresses a few testcases,
but they will come back later.



Swift SVN r11359
2013-12-16 20:33:23 +00:00
John McCall
ba3dda3cce Parse and analyze initializers of non-local var decls in a
PatternBindingInitializer context.

Swift SVN r11355
2013-12-16 19:56:52 +00:00
Chris Lattner
b26ac34ade rework how let-ness of 'self' is determined, to be based on the type of self.
This time, it correctly handles static methods, which have metatypetype.


Swift SVN r11302
2013-12-14 06:18:42 +00:00
Doug Gregor
037c674f05 Move diagnostic about missing function definition into semantic analysis.
The parser shouldn't be diagnosing such semantic constraints. While
I'm here, allow definitions on functions in protocols (they're ignored
for now).


Swift SVN r11223
2013-12-13 00:07:51 +00:00
Chris Lattner
ef5f42323a fix some test failures from my last commit.
Swift SVN r11212
2013-12-12 21:38:10 +00:00
Chris Lattner
a00268d1e8 accept (but ignore) @inout on func decls.
Swift SVN r11209
2013-12-12 21:15:18 +00:00
John McCall
ab27d863a1 Parse all top-level code in the same local context.
Swift SVN r11207
2013-12-12 19:56:24 +00:00
John McCall
30e388fbf2 Extract the actual context info out of the ParseFunctionBody RAII object.
Swift SVN r11205
2013-12-12 19:46:25 +00:00
Chris Lattner
65aa09d464 implement support for let declarations.
Swift SVN r11195
2013-12-12 18:33:42 +00:00
Chris Lattner
03518d240f revert r11192, I accidentally included too much in the patch.
Swift SVN r11193
2013-12-12 18:24:33 +00:00
Chris Lattner
778225eb96 Implement let declarations.
Swift SVN r11192
2013-12-12 18:22:46 +00:00
Chris Lattner
64f77480c3 mark "self" immutable (except in methods on value types), and mark the "value" argument to setters as immutable.
Swift SVN r11185
2013-12-12 07:45:40 +00:00
John McCall
dfe138fdc4 Build and register the PDB earlier, removing the need for a
special case in code-completion.

Swift SVN r11179
2013-12-12 03:36:30 +00:00
John McCall
342a8b35db Parse default-argument expressions in an initializer context.
Swift SVN r11178
2013-12-12 03:36:27 +00:00
Chris Lattner
6d4cd89e4e mark closure arguments, subscript arguments and destructor arguments (??)
as immutable.


Swift SVN r11147
2013-12-11 22:36:11 +00:00
Chris Lattner
b1a2059604 Implement the ability to create a Pattern as a set of 'let' decls instead of
var decls.  I was originally intending to use this for argument lists, but I
don't think that's a great direction to go anymore.

In any case, it seems uncontroversial to enforce immutability on foreach
enumation patterns, so I did that (see testcase)



Swift SVN r11124
2013-12-11 07:28:13 +00:00
Chris Lattner
698380d6d3 Introduce a new bit in VarDecl, "isLet". Teach Sema that 'isLet' properties
are not settable (like get-only ones).  Set the 'isLet' bit in various 
places, but not the particularly interesting or useful places yet.



Swift SVN r11121
2013-12-11 06:45:40 +00:00
Joe Groff
669295be29 Revert "Refactor ArchetypeBuilder to work with abstract generic parameters."
This reverts commit r10966. It breaks test/Parse/self_keyword_recovery.swift.

Swift SVN r10974
2013-12-07 03:03:43 +00:00
Joe Groff
155a4aec7c Refactor ArchetypeBuilder to work with abstract generic parameters.
Have ArchetypeBuilder key the archetypes it produces by the abstract {depth,index} position of generic parameters rather than by the identity of particular GenericTypeParamDecls. Tighten the signature of AbstractTypeParamDecl-taking methods to only take GenericTypeParamDecls; that's the only case that comes up anymore. Introduce 'addGenericParameter' and 'getArchetype' overloads that work with GenericTypeParamTypes and DependentMemberTypes in addition to those that work with GenericTypeParamDecls.
Move ArchetypeBuilder.cpp from 'Sema' to 'AST' to correspond to its header's location.

When we parse something like 'protocol P { protocol Q {} }', eagerly give the erroneous nested protocol Q an ErrorType to suppress type-checking of the declaration. Otherwise, the nested implicit 'Self' parameters, which are fixed depth 0 index 0 in the generic parameter space, will collide in the ArchetypeBuilder.

Swift SVN r10966
2013-12-07 01:29:34 +00:00
Chris Lattner
a42debfb69 fix a few places that missed marking 'self' as an implicit decl.
Swift SVN r10961
2013-12-07 01:11:16 +00:00
John McCall
a5febc6b48 Track discriminators for closure expressions.
Swift SVN r10905
2013-12-06 02:23:57 +00:00
Jordan Rose
417b5d3982 Merge TranslationUnit into Module, and eliminate the term "translation unit".
This completes the FileUnit refactoring. A module consists of multiple
FileUnits, which provide decls from various file-like sources. I say
"file-like" because the Builtin module is implemented with a single
BuiltinUnit, and imported Clang modules are just a single FileUnit source
within a module.

Most modules, therefore, contain a single file unit; only the main module
will contain multiple source files (and eventually partial AST files).

The term "translation unit" has been scrubbed from the project. To refer
to the context of declarations outside of any other declarations, use
"top-level" or "module scope". To refer to a .swift file or its DeclContext,
use "source file". To refer to a single unit of compilation, use "module",
since the model is that an entire module will be compiled with a single
driver call. (It will still be possible to compile a single source file
through the direct-to-frontend interface, but only in the context of the
whole module.)

Swift SVN r10837
2013-12-05 01:51:15 +00:00
John McCall
892a900332 Track a discriminator for named declarations (except physical
vars) in local contexts, for future use in mangling.

Swift SVN r10827
2013-12-05 01:42:09 +00:00
Manman Ren
05899b7a8d SILParser: parse sil_global and sil_global_addr.
rdar://15493552


Swift SVN r10823
2013-12-05 00:46:40 +00:00
Dmitri Hrybenko
d076501cca Don't repeat Context.getIdentifier("self") everywhere in the code base
Swift SVN r10786
2013-12-04 18:42:34 +00:00
Argyrios Kyrtzidis
f2055cae32 [Parser] Fix crash when parsing top-level 'for i' in '-parse-as-library' mode.
rdar://15503916

Swift SVN r10589
2013-11-20 08:12:42 +00:00
John McCall
20e58dcf93 Change the type of function values in SIL to SILFunctionType.
Perform major abstraction remappings in SILGen.  Introduce
thunking functions as necessary to map between abstraction
patterns.

Swift SVN r10562
2013-11-19 22:55:09 +00:00
Dmitri Hrybenko
81dc5deee8 Change 'def' keyword back to 'func'
Swift SVN r10522
2013-11-17 07:45:28 +00:00