Commit Graph

1147 Commits

Author SHA1 Message Date
Doug Gregor
7fee09b41e Axle: Implement Matrix<T, N> and Matrix<T, N, M> syntactic sugar.
This completes the majority of <rdar://problem/15100137>.


Swift SVN r9098
2013-10-09 22:24:21 +00:00
Doug Gregor
fba128e191 Axle: Implement Vec<T, N> syntactic sugar for the VecTxN structs.
Implements the first part of <rdar://problem/15100137>.


Swift SVN r9092
2013-10-09 21:12:19 +00:00
Jordan Rose
09787207fc Push TUKind into SourceFile (as InputKind).
Different SourceFiles in the same module will eventually have different
input kinds (at the very least Main vs. Library).

Swift SVN r9076
2013-10-09 18:38:25 +00:00
Jordan Rose
f5de2e43d7 Push SourceFile into Parser and REPL somewhat.
Swift SVN r9073
2013-10-09 18:38:17 +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
Chris Lattner
394ca8f944 implement basic support for parsing the new form of attribute, though this
is only used by the sil parser.  The old form is still parsed.


Swift SVN r8906
2013-10-04 04:02:09 +00:00
Doug Gregor
12e228c0f1 Introduce a new representation of polymorphic function types.
Introduces a new kind of function type, GenericFunctionType, that
represents a polymorphic function type with all of its generic
parameters and requirements stored in a more readily canonicalizable
form. It is meant to eventually replace PolymorphicFunctionType, but
for now we build it up in parallel so we can switch over to it
pieacemeal.

Note: this representation is built and then thrown away. We'll start
recording it soon.


Swift SVN r8881
2013-10-03 17:59:35 +00:00
Joe Groff
4b5db0cd50 Parse trailing closure productions as expr-postfix.
This is more naturally where they belong in the grammar, allows for nice chained transformation calls like 'x.map { ... }.filter { ... }', and lets us remove a bunch of kludgy fixits to try to handle the 'wanted to parse postfix but didn't' case. Fixes <rdar://problem/14098078>. Also fix the special-case handling of "builder pattern" style method chains to parse 'x\n.method{' as a chained method call, like it does 'x\n.method(' or 'x\n.property['. (There's got to be a better way...)

Swift SVN r8828
2013-10-02 00:27:26 +00:00
Argyrios Kyrtzidis
6942646f80 [AST] Make 'self' vars implicit and provide a source location for them.
Verifier expects all decls to have locations, let's keep it happy.

Swift SVN r8757
2013-09-29 00:12:13 +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
Jordan Rose
c5322d4bf6 Record a back-pointer from a VarDecl to its containing PatternBindingDecl.
This will be used for lazy type-checking of global and member vars.

Swift SVN r8640
2013-09-25 20:08:07 +00:00
Dmitri Hrybenko
10d8fdc64f AST/AbstractFunctionDecl: Remember if a function had a selector-style signature
... and use this information in AST printing


Swift SVN r8583
2013-09-24 00:56:33 +00:00
Joe Groff
5d8a7ff9e7 Allow multiple comma-separated enum elements in a 'case' decl.
Introduce an EnumCaseDecl for source fidelity to track the 'case' location and ordering of EnumElementDecls. Parse a comma-separated list of EnumElementDecls after a 'case' token.

Swift SVN r8509
2013-09-20 19:51:13 +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
Dmitri Hrybenko
0aaceb3878 Parser: improve error recovery in case of a bad function signature with selector-style arguments
We used to skip until the end of the file in two of these cases.
Looks like plain skipUntil() is never the correct tool for recovery.


Swift SVN r8441
2013-09-19 02:24:59 +00:00
Doug Gregor
90b8b3e499 Constructor selectors always start with 'init'.
Implement the new rules for mapping between selector names and
constructors. The selector for a given constructor is formed by
looking at the names of the constructor parameters:
  * For the first parameter, prepend "init" to the parameter name and
  uppercase the first letter of the parameter name. Append ':' if
  there are > 1 parameters or the parameter has non-empty-tuple type.
  * For the remaining parameters, the name of each parameter followed
  by ':'.

When a parameter doesn't exist, assume that the parameter name is the
empty string.

And, because I failed to commit it separately, support selector-style
declarations of constructor parameters so that we can actually write
constructors nicely, e.g.:

  // selector is initWithFoo:bar:
  constructor withFoo(foo : Foo) bar(bar : Bar) { ... }



Swift SVN r8361
2013-09-17 22:49:05 +00:00
Dmitri Hrybenko
07e83ea49c Code completion: basic completion in constructor bodies
Swift SVN r8338
2013-09-17 18:20:26 +00:00
Dmitri Hrybenko
0d6d9a0ffb Move the DeclContext base class from FuncExpr to FuncDecl
FuncDecl still has a FuncExpr because capture list is stored in FuncExpr
(which is a CapturingExpr).


Swift SVN r8179
2013-09-13 01:40:41 +00:00
Dmitri Hrybenko
c69c79084a Move result typeloc and body result type from FuncExpr to FuncDecl
Swift SVN r8153
2013-09-12 18:40:57 +00:00
Dmitri Hrybenko
3cc01cf7d6 Introduce AbstractFunctionDecl -- a base class for ConstructorDecl,
DestructorDecl, FuncDecl -- and move some of the common concepts and logic
into it

No functionality change.


Swift SVN r8090
2013-09-11 04:04:01 +00:00
Dmitri Hrybenko
94d417a838 Parser: introduce skipUntilGreaterInTypeList(), which implements a better
heuristic than skipUntilAnyOperator() to find the end of a type list

Almost all testcases added in this commit used to skip all the way to EOF.


Swift SVN r7991
2013-09-06 17:50:11 +00:00
Dmitri Hrybenko
9bbfe27615 Add an option for diagnostics -- PointsToFirstBadToken
Diagnostics that point to the first bad token are marked with this option in
Diagnostics.def.  Parser::diagnose treats the source location of such
diagnostics in a special way: if source location points to a token at the
beginning of the line, then it moves the diagnostic to the end of the previous
token.

This behaviour improves experience for "expected token X" diagnostics.


Swift SVN r7965
2013-09-05 23:38:32 +00:00
Dmitri Hrybenko
d52982cd0d Recovery from parsing extensions for non-nominal types: stop abusing the type
checker for what can be a simple syntactic check, when implemented on
appropriate level -- during type parsing.


Swift SVN r7954
2013-09-05 20:22:31 +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
9b90a66087 Use \returns in the documentation comment
Swift SVN r7745
2013-08-29 21:21:04 +00:00
Dmitri Hrybenko
3a6feb7814 Disallow constructors in protocols
Swift SVN r7701
2013-08-28 23:03:37 +00:00
Jordan Rose
fa3dd42c54 Don't parse function bodies in imported TUs.
...unless the functions are declared [transparent], or if we're in an
immediate mode (in which case we won't get a separate chance to link
against the imported TUs).

This is an optimization that will matter more when we start dealing with
Xcode projects with many cross-file dependencies, especially if we have
some kind of implicit import of the other source files in the project.

In the future, we may want to parse more function bodies for the purpose
of inlining, not just the transparent ones, but we weren't taking
advantage of that now, so it's not a regression. (We're still not taking
advantage of it even for [transparent] functions.)

Swift SVN r7698
2013-08-28 22:53:28 +00:00
Dmitri Hrybenko
9447f6c73f parseBraceItems(): don't skip over braced lists of statements during recovery
This increases the amount of noise in diagnostics.  But we did not get these
diagnostics before because we were just skipping these brace statements.  We
shoud improve recovery in parsing of whatever declaration that precedes the
brace statement so that it is picked up as a body of that declaration.


Swift SVN r7679
2013-08-28 19:33:43 +00:00
Ted Kremenek
8f5b8ccb02 Rename "This" to "Self" and "this" to "self".
This was not likely an error-free change.  Where you see problems
please correct them.  This went through a fairly tedious audit
before committing, but comments might have been changed incorrectly,
not changed at all, etc.

Swift SVN r7631
2013-08-27 21:58:27 +00:00
Dmitri Hrybenko
db44574605 parseBraceItemList(): use ParserResult
Now we propagate error bits better, which decreases noise in diagnostics in one
case.


Swift SVN r7628
2013-08-27 19:01:15 +00:00
Dmitri Hrybenko
55dec1eca5 Remove outdated comment.
Swift SVN r7626
2013-08-27 17:33:53 +00:00
Dmitri Hrybenko
d07a5e82cc parseStmtCase(): use ParserResult
Swift SVN r7620
2013-08-27 02:09:08 +00:00
Dmitri Hrybenko
c3c5d7d5f3 parseStmt(): use ParserResult
Swift SVN r7617
2013-08-27 01:08:02 +00:00
Dmitri Hrybenko
af8fd2c25f Change variable name in header to match source file
Swift SVN r7615
2013-08-27 00:52:54 +00:00
Dmitri Hrybenko
78d2f03a8d parseStmtSwitch(): use ParserResult
Swift SVN r7614
2013-08-27 00:48:24 +00:00
Dmitri Hrybenko
cadc9016c5 parseExprOrStmt(): use ParserStatus
Swift SVN r7613
2013-08-27 00:41:37 +00:00
Dmitri Hrybenko
e1d39e5052 parseStmtFor(): use ParserResult
Swift SVN r7612
2013-08-27 00:20:29 +00:00
Dmitri Hrybenko
09ad614035 parseStmtDoWhile(): use ParserResult
Swift SVN r7608
2013-08-26 23:43:09 +00:00
Dmitri Hrybenko
a9f56c4839 parseStmtWhile(): use ParserResult
Swift SVN r7606
2013-08-26 23:38:52 +00:00
Dmitri Hrybenko
45c46314ab parseStmtIf(): use ParserResult
Swift SVN r7605
2013-08-26 23:33:32 +00:00
Dmitri Hrybenko
c6f0dd106d parseStmtReturn(): use ParserResult
This caught a bug in parseExprPostfix(): it did not return a code completion
status.


Swift SVN r7603
2013-08-26 23:18:51 +00:00
Dmitri Hrybenko
45c4cc334f Brush up comments in Parser: no need to describe the return value of functions
that return ParserResult; use Doxygen syntax.


Swift SVN r7550
2013-08-24 01:25:19 +00:00
Dmitri Hrybenko
4bc13e6cd2 Code completion: complete types in the typealias inheritance clause
Swift SVN r7524
2013-08-23 21:10:53 +00:00
Dmitri Hrybenko
a56893dec2 parseDecl(): use ParserResult
Now we make the desicion to delay parsing if the parsed production contained a
code completion token, not if we just stopped at the code completion token.


Swift SVN r7442
2013-08-22 00:39:45 +00:00
Dmitri Hrybenko
caeddfdaf0 parseExprList(): use ParserResult
Swift SVN r7440
2013-08-22 00:27:43 +00:00
Dmitri Hrybenko
421b107091 parseExprCollection, parseExprArray, parseExprDictionary: use ParserResult
Swift SVN r7439
2013-08-21 23:47:07 +00:00
Dmitri Hrybenko
2bf010151b parseExprSequence(): use ParserResult
Swift SVN r7438
2013-08-21 23:30:47 +00:00
Dmitri Hrybenko
4957bca697 parseExprUnary(): use ParserResult
Swift SVN r7437
2013-08-21 23:20:23 +00:00
Dmitri Hrybenko
f9a24073a5 parseExprPostfix(): use ParserResult
Swift SVN r7430
2013-08-21 21:53:52 +00:00
Dmitri Hrybenko
04bcc5553e parseExprNew(): use ParserResult
Swift SVN r7429
2013-08-21 21:32:21 +00:00