Commit Graph

784 Commits

Author SHA1 Message Date
Chris Lattner
827e168b40 refactor all the get/set parsing logic to merge the cases together into
one function.  Add to it logic to parse didset/willset.

Sema doesn't exist yet, so these aren't too useful yet.


Swift SVN r13019
2014-01-28 00:09:12 +00:00
Manman Ren
729d30fb54 SILParser: first step towards parsing sil_witness_table.
Only one entry kind out of four is supported right now.


Swift SVN r12936
2014-01-24 21:58:45 +00:00
Doug Gregor
11656c9798 Introduce the ParseDeclOptions option set in the Parser. NFC.
Swift SVN r12588
2014-01-20 17:38:12 +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
Doug Gregor
8cb2f1e131 Make sure we have a local context when parsing top-level code.
... even if that code is invalid. Eliminates a crash found as part of
<rdar://problem/15059074>.


Swift SVN r11869
2014-01-03 21:55:12 +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
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
ab27d863a1 Parse all top-level code in the same local context.
Swift SVN r11207
2013-12-12 19:56:24 +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
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