Commit Graph

624 Commits

Author SHA1 Message Date
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
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
John McCall
a5febc6b48 Track discriminators for closure expressions.
Swift SVN r10905
2013-12-06 02:23:57 +00:00
Dave Abrahams
4c0e6eec4a [stdlib] Rename Enumerable => Sequence
Swift SVN r10857
2013-12-05 13:18:41 +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
Doug Gregor
002038ad8e Allow a comma-separated list of init expressions in C-style for loops.
Swift SVN r10748
2013-12-03 15:14:54 +00:00
Argyrios Kyrtzidis
3a1d504cff [Parser] Fix crash-on-invalid, with top-level statements and -parse-as-library.
Part of rdar://15484631

Swift SVN r10558
2013-11-19 17:55:04 +00:00
Dmitri Hrybenko
81dc5deee8 Change 'def' keyword back to 'func'
Swift SVN r10522
2013-11-17 07:45:28 +00:00
Doug Gregor
3700c7bf13 Allow comma-separated expressions in the increment portion of a C-style for loop.
Fixes <rdar://problem/15267269>.


Swift SVN r10399
2013-11-13 00:54:02 +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
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
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
Dmitri Hrybenko
238d898a0d Code completion for enums: model completion in switch case as a separate kind
of completion.  This approach (rather than SourceLoc tricks) better reflects
the intent and allows us to fix the rest of testcases.


Swift SVN r9557
2013-10-21 20:58:23 +00:00
Dmitri Hrybenko
de6a0a0f8c Code completion: complete references to enum elements in switch statements when
we have enough type context to find the correct enum


Swift SVN r9439
2013-10-17 02:09:49 +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
Argyrios Kyrtzidis
74ba1e8851 [Parser] In Parser::parseBraceItemList, when we don't find a right brace recover by using the PreviousLoc.
This ensures that the brace range will include all contained items.
The previous scheme of choosing the end location of the last item was not accurate because for pattern bindings decls
we also push the var decls as items, but they don't have the full source range of the pattern binding decl.

Fixes rdar://15190792.

Swift SVN r9293
2013-10-13 18:50:53 +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
Chris Lattner
6e006bbfea remove the (unused now) AttrListKind enum which previously distinguished
between decl and type attributes.  Now that these are going down different
paths, it isn't needed.


Swift SVN r9267
2013-10-13 03:33:22 +00:00
Chris Lattner
a718c8f57a start improving the attribute implementation: start with passing down
a "kind" for the attribute, to indicate whether the caller is looking for
a type, decl, or sil attribute.  This is currently unused.


Swift SVN r9261
2013-10-12 22:13:51 +00:00
Dmitri Hrybenko
2123682ed9 Code completion / parser: propagate code completion bits from braced stmt
Swift SVN r9125
2013-10-10 02:00:28 +00:00
Dmitri Hrybenko
af4ad7e9b7 Code completion: assign a special semantic context for iteration variables
in a C-style for loop


Swift SVN r9111
2013-10-09 23:32:59 +00:00
Chris Lattner
f990775e3c enhance the parser to parse the new attribute syntax on all decls. Switch a few
testcases to use it.


Swift SVN r8910
2013-10-04 05:03:52 +00:00
Dmitri Hrybenko
04a8cdef03 Completely remove the 'constructor' keyword
Swift SVN r8882
2013-10-03 18:12:15 +00:00
Joe Groff
66dafba3f5 Reject empty switch statements.
<rdar://problem/14432432>

Swift SVN r8829
2013-10-02 01:07:19 +00:00
Jordan Rose
e05c03d5bc Standardize terminology for "computed", "stored", "variable", and "property".
These are the terms sent out in the proposal last week and described in
StoredAndComputedVariables.rst.

variable
  anything declared with 'var'
member variable
  a variable inside a nominal type (may be an instance variable or not)
property
  another term for "member variable"
computed variable
  a variable with a custom getter or setter
stored variable
  a variable with backing storage; any non-computed variable

These terms pre-exist in SIL and IRGen, so I only attempted to solidify
their definitions. Other than the use of "field" for "tuple element",
none of these should be exposed to users.

field
  a tuple element, or
  the underlying storage for a stored variable in a struct or class
physical
  describes an entity whose value can be accessed directly
logical
  describes an entity whose value must be accessed through some accessor

Swift SVN r8698
2013-09-26 18:50:44 +00:00
Joe Groff
e109124186 Replace 'union' keyword with 'enum'.
This only touches the compiler and tests. Doc updates to follow.

Swift SVN r8478
2013-09-20 01:33:14 +00:00
Doug Gregor
978959ced8 Make the "init" and "constructor" keywords synonymns.
Swift SVN r8391
2013-09-18 04:23:28 +00:00
Dmitri Hrybenko
f1f189f4e0 Rename PipeClosureExpr -> ClosureExpr
Swift SVN r8321
2013-09-17 01:37:36 +00:00
Dmitri Hrybenko
10291e0334 Make AbstractClosureExpr a DeclContext
(remove DeclContext base class from PipeClosureExpr and ImplicitClosureExpr)


Swift SVN r8303
2013-09-16 22:39:12 +00:00
Dmitri Hrybenko
a1f5f2ba25 Switch 'case' parsing: when the parser expects a colon, don't unconditionally
consume the next token; consume the token only if it is actually a colon.


Swift SVN r8010
2013-09-06 22:33:36 +00:00
Dmitri Hrybenko
fbe081b06b Mark diagnostics from c-style-for parsing as PointsToFirstBadToken
Swift SVN r8008
2013-09-06 22:15:54 +00:00
Dmitri Hrybenko
d44177165e Improve QoI for "expected expression in 'return' statement" diagnostic
- suppress error from type checker (missing return value in a non-void
  function) if the source had an expression, but had a parse error;

- mark the diagnostic as PointsToFirstBadToken.


Swift SVN r8004
2013-09-06 21:34:28 +00:00
Dmitri Hrybenko
f24063da4e Parser: don't try to parse the expression after 'return' if we see the
beginning of decl (we used to only check for the beginning of statement).
This is going to be a parse error anyway.


Swift SVN r8003
2013-09-06 21:24:28 +00:00
Dmitri Hrybenko
b38d8e38b8 Code completion: basic completion inside closures
This does not mean that it works well, we just don't crash like we used to.


Swift SVN r7889
2013-09-04 01:31:20 +00:00
Dmitri Hrybenko
dfec888b1c Parser: build AST for 'for <expr>; {}' and improve partial type checking of
function bodies

Allows us to fix a few FIXMEs in code completion.


Swift SVN r7883
2013-09-04 00:23:20 +00:00
Dmitri Hrybenko
d24a5d7aa4 Improve recovery in parsing the c-style for statement
Allows code completion to see declarations in the init part of the for
statement.


Swift SVN r7878
2013-09-03 23:10:13 +00:00
Dmitri Hrybenko
47629bf856 Revert unintended change
Swift SVN r7825
2013-08-31 01:58:05 +00:00
Dmitri Hrybenko
23ced2fba3 Move the parseIdentifierDeclName() helper above parseDeclExtension()
(so that extension parsing can use these helpers)


Swift SVN r7824
2013-08-31 01:54:50 +00:00
Dmitri Hrybenko
47f529d8a4 Fix variable name case. The rest of the file seems consistent.
Swift SVN r7755
2013-08-29 22:22:34 +00:00
Dmitri Hrybenko
ddfa9bc8d8 Parser::skip*() routines: don't stop on code completion token anymore
Our recovery is better now, and we don't skip that much.  Actually, even if we
would stop at code completion token during recovery, completion results would
be something very generic anyway (because there is no interesting parser state
to observe), and these results can be produced as a fallback separately (not
implemented).


Swift SVN r7754
2013-08-29 22:15:12 +00:00
Dmitri Hrybenko
d98408425e Remove unused OwningPtr.h includes
Swift is C++11 and uses std::unique_ptr.


Swift SVN r7731
2013-08-29 20:09:49 +00:00
Dmitri Hrybenko
cfe695166a Parser: if we parsed a bare closure as an expression, it will be a discarded
value expression and the type checker will complain anyway.

Instead, recover by unwrapping the BraceStmt that is contained inside, and
produce a specialized diagnostic.


Swift SVN r7680
2013-08-28 19:37:51 +00:00