Commit Graph

2486 Commits

Author SHA1 Message Date
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
Dmitri Hrybenko
7119b8e467 Enum case parsing: always set the identifier location during recovery
Fixes rdar://15466065


Swift SVN r10491
2013-11-15 02:42:15 +00:00
Dmitri Hrybenko
936cdd4556 Parser: recover better if a keyword is used as an identifier in enum case that
appears as a last member.  (Consider r_brace a synchronization token.)

Part of rdar://15466065


Swift SVN r10489
2013-11-15 02:04:56 +00:00
Joe Groff
4c333d8071 AST: Accessors of static properties must be static functions.
Build the getter and setter of a static property as static func decls, and add a verifier check that the static-ness of a var and its accessors match up.

Swift SVN r10395
2013-11-13 00:28:52 +00:00
Joe Groff
4f2adbe7ed AST: Include 'static' bit in VarDecls.
And track the 'static' SourceLoc in the PatternBindingDecl. This lets isInstanceMember return the right thing for static vars.

Swift SVN r10369
2013-11-12 06:16:48 +00:00
Joe Groff
8b11158753 Parser: Allow static vars in DisallowStoredVar contexts.
The contexts for which we set the DisallowStoredVar bit, currently enums and extensions, can both (theoretically) support static variables, so change PD_DisallowStoredVar to PD_DisallowStoredInstanceVar, and allow static vars to be declared in these contexts.

Swift SVN r10350
2013-11-12 00:13:21 +00:00
Joe Groff
ea698da596 Parser: Admit 'static' properties in nongeneric struct or enum decls.
These properties are truly static and can be implemented just as global variables, and this is all we need in the short term to give a good interface to NS_OPTIONS-like Cocoa enumerations.

Swift SVN r10349
2013-11-11 23:57:27 +00:00
Dmitri Hrybenko
d19d82e876 Parser: fix a crash on extra closing brace in parse-as-library mode
rdar://15359129


Swift SVN r10071
2013-11-09 02:44:56 +00:00
Dmitri Hrybenko
d6012459c3 Eliminate IsTopLevel parameter from Parser::parseBraceItems() -- its value can
be computed from other parameter.


Swift SVN r10069
2013-11-09 02:06:39 +00:00
Anna Zaks
54524e622a Replace ExprStmtOrDecl with ASTNode and make it a struct.
Previously, the Parser and BranchStmt typedef-ed ExprStmtOrDecl as a pointer union. Using typedef made the objects compatible, but did not allow us to extend the type with helper methods, such as getSourceRange(), which is something you can get on all of the AST objects. This patch introduces ASTNode that subclasses from PointerUnion and is used by both parser and BranchStmt.

Swift SVN r9971
2013-11-05 21:46:59 +00:00
Doug Gregor
e5ca2c90d0 Parse @optional attribute on protocol members.
Swift SVN r9959
2013-11-05 15:58:19 +00:00
Chris Lattner
68af974227 Remove 'axle' related code and build machinery. It turns out that we
will not be pursuing this project in the immediate future.



Swift SVN r9901
2013-11-03 16:04:27 +00:00
Dmitri Hrybenko
91ce21666d Change 'func' keyword to 'def'
I tried hard find all references to 'func' in documentation, comments and
diagnostics, but I am sure that I missed a few.  If you find something, please
let me know.

rdar://15346654


Swift SVN r9886
2013-11-02 01:00:42 +00:00
Jordan Rose
766f41f266 Put top-level decls in the SourceFile DeclContext, rather than in the TU.
Swift SVN r9647
2013-10-24 18:59:24 +00:00
Mark Lacey
eaa7018ed0 Fixup attribute syntax in LangRef.html.
There are still some [infix_left=] in the text. Based on
r4627 it looks like these can just be deleted, but I haven't
done so at this time.

Swift SVN r9616
2013-10-23 08:12:21 +00:00
Dmitri Hrybenko
e2b0f08f57 Parser: allow an optional trailing comma in array and dictionary literals
rdar://14874038


Swift SVN r9567
2013-10-21 23:13:22 +00:00
Dmitri Hrybenko
2b7c36c1a8 Parser recovery: skip multiple right braces at top level, both at the beginning
and at the end of the file

rdar://15267668


Swift SVN r9544
2013-10-21 17:55:31 +00:00
Joe Groff
5721bdda01 Don't pretend we can parse enum case refined types.
There's no way we'll be able to fully implement GADTs anytime soon.

Swift SVN r9477
2013-10-18 01:34:25 +00:00
Dmitri Hrybenko
2415cd9028 Code completion: rename a variable for consistency with AST node name
Swift SVN r9425
2013-10-16 22:28:26 +00:00
Dmitri Hrybenko
278cbad8a4 Code completion: don't produce any results in enum case. Only integer literals
are allowed in that context.


Swift SVN r9383
2013-10-15 22:45:54 +00:00
Dmitri Hrybenko
46a4bc1402 Code completion: preserve the AST for the parsed top-level code. This enables
us to find iteration variables while doing code completion in nested top-level
code.

Fixes part of rdar://15199468


Swift SVN r9343
2013-10-15 01:24:16 +00:00
Manman Ren
d503c65036 SILParser: parse sil_vtable
rdar://15165644


Swift SVN r9342
2013-10-15 00:52:40 +00:00
Chris Lattner
b8baf03495 rename parseAttribute* to parseDeclAttribute*, since they
are for decl attributes.


Swift SVN r9288
2013-10-13 16:53:44 +00:00
Chris Lattner
24ff772bad switch get/set specifiers to the new attribute syntax, and completely remove
the old syntax, woo.


Swift SVN r9287
2013-10-13 16:50:03 +00:00