Commit Graph

162 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
Dave Abrahams
0f994b6ba0 Rename "Container" => "Sequence" in core compiler
A few places in the core compiler were referring to instances of the
Sequence protocol as "Containers".  The "Indexable" protocol will soon
be renamed "Container," so eliminate this potential confusion

Swift SVN r11944
2014-01-06 20:07:01 +00:00
Chris Lattner
b35858f131 Simplify more cases to use getSemanticsProvidingPattern.
Change Pattern::getBoundName to look through VarPatterns,
which means that the presence of var/let in an argument list no longer 
change the mangling of the function.



Swift SVN r11780
2013-12-31 22:25:43 +00:00
Joe Groff
017440165e Fix the weird capitalization of MetaTypeType.
Swift SVN r11475
2013-12-19 18:43:08 +00:00
Chris Lattner
39224db6a9 remove the ZeroValueExpr AST node.
Swift SVN r11048
2013-12-09 23:16:14 +00:00
Doug Gregor
19759529db Allow delayed identifier expressions (.foo) with static variables and methods.
This allows expressions such as ".foo" and ".foo(1)" to refer to
static variables and static methods, respectively, as well as enum
cases. 

To get here, rework the parsing of delayed identifier expressions a
bit, so that the argument itself is part of the delayed argument
expression rather than a separate call expression. This simplifies
both the handling of patterns of this form and the type checker, which
can now user simpler constraints.

If we really want to support (.foo)(1), we can make that work, but it
seems unnecessary and perhaps confusing.


Swift SVN r10626
2013-11-21 06:24:06 +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
Doug Gregor
a7664fda78 Clean up the checking of pattern binding declarations.
Eliminate the annoying, rarely-firing "while converting 'var' initial
value to declared type" note. We'll eventually have better ways to
deal with this. Otherwise, no functionality change.


Swift SVN r9677
2013-10-25 21:14:03 +00:00
Argyrios Kyrtzidis
d9e0921a76 [ASTWalker] Walk the pattern of a ForEachStmt.
Swift SVN r9291
2013-10-13 18:50:50 +00:00
Argyrios Kyrtzidis
f995d2ac28 [ASTWalker] Walk the TypeRepr of a typealias.
Swift SVN r9290
2013-10-13 18:50:49 +00:00
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
Argyrios Kyrtzidis
275ce0970e [ASTWalker] Walk the TypeReprs of an extension decl.
Swift SVN r9032
2013-10-08 21:53:56 +00:00
Doug Gregor
611a5cce4b Replace the library-defined postfix '!' with an expr-postfix production.
As with the monadic '?', we treat any left-bound '!' as a postfix
operator. Currently, it extracts the value of its optional
subexpression, failing at run-time if the optional is empty.


Swift SVN r8948
2013-10-06 23:09:58 +00:00
Argyrios Kyrtzidis
781dcf7b11 [AST] Store the TypeReprs of generic arguments used to specialize a decl reference in DeclRefExpr, to impove source fidelity.
Fixes rdar://15034958

Swift SVN r8880
2013-10-03 17:55:55 +00:00
Argyrios Kyrtzidis
883a9eec61 [ASTWalker] Walk the TypeReprs of UnresolvedSpecializeExprs so we can syntax-annotate them.
Swift SVN r8879
2013-10-03 17:55:54 +00:00
Joe Groff
3b0180b1b0 Allow '_' in assignments again.
Parse '_' as a DiscardAssignmentExpr. Type-check it as an lvalue, and check that it only appears in the LHS of AssignExprs. During matching pattern resolution, convert it into an AnyPattern. In SILGen, when we see '_' in the LHS of an assignment, ignore the corresponding RHS rvalue.

Swift SVN r8848
2013-10-02 18:43:20 +00:00
John McCall
298577676e Introduce the monadic ? operator.
A ? operator is interpreted as this if it's left-bound,
so ternary operators now have to be spaced on the left.

Swift SVN r8832
2013-10-02 01:27:45 +00:00
Argyrios Kyrtzidis
9b4c94d4c2 [AST] Walk body parameter patterns.
Swift SVN r8804
2013-10-01 15:37:47 +00:00
Joe Groff
911929f1dd Parse and type check initializer closures after 'new T[n]' exprs.
Require that either T be default constructible or that the user provide a closure that maps indices to initial values. We don't actually call the closure yet to initialize the array; that's blocked on function abstraction difference <rdar://problem/13251236>.

Swift SVN r8801
2013-10-01 05:12:54 +00:00
Argyrios Kyrtzidis
7bfebfbe03 [AST] Have the ASTWalker visit the indices pattern and element TypeRepr of a subscript decl.
Swift SVN r8782
2013-09-30 17:59:04 +00:00
Argyrios Kyrtzidis
5bec0390dd Syntax-annotate 'get'/set' in a getter/setter as keywords.
Also make sure that ColorASTWalker passes SyntaxNodes in source order.
This is a patch by Sonny with some modifications.

Swift SVN r8777
2013-09-30 16:26:00 +00:00
Joe Groff
92cce69e15 AST: Give NominalTypePattern a better AST-level representation.
Instead of relying on the subpattern being a well-formed TuplePattern, let's track our own subelements so we can associate them to properties and validate them ourselves.

Swift SVN r8771
2013-09-30 01:03:18 +00:00
Argyrios Kyrtzidis
b4d0d01071 [AST] Enable walking of all VarDecls.
This allows:
-The verifier to verify them.
-swiftIDE to annotate them.

Swift SVN r8767
2013-09-29 00:12:27 +00:00
Argyrios Kyrtzidis
4a91e28d11 [AST] For the ASTWalker add Module and Decl as a parent kind, and make ParentTy a class.
Swift SVN r8756
2013-09-29 00:12:11 +00:00
Doug Gregor
0d33ff3f40 Teach SILGen to directly emit optional injection operations for dynamic lookup.
... rather than synthesizing expressions in the AST.


Swift SVN r8723
2013-09-27 14:12:33 +00:00
Argyrios Kyrtzidis
4255aa64c9 [ASTWalker] When walking a SelfApplyExpr, walk the base expression first to get a source-order walk.
Swift SVN r8679
2013-09-25 23:55:47 +00:00
Doug Gregor
f67aa78d69 Dynamic lookup for subscripts: semantic analysis and ASTs.
Swift SVN r8591
2013-09-24 05:51:30 +00:00
Joe Groff
ae496fa64c ASTWalker: Walk the pre-type-checked raw literal expr of EnumElements.
As suggested by Dmitri, walk the expr so that clients such as syntax highlighting can see it, but discard the result if it doesn't come back as a LiteralExpr to avoid breaking the invariant.

Swift SVN r8573
2013-09-23 22:19:04 +00:00
Argyrios Kyrtzidis
ab82766a74 [AST] Walk the inherited TypeReprs of a nominal type declaration with the ASTWalker.
Swift SVN r8556
2013-09-23 15:39:44 +00:00
Argyrios Kyrtzidis
8e1538e110 [AST] Consolidate walking of NominalTypeDecl subclasses to reduce duplication.
Swift SVN r8555
2013-09-23 15:39:42 +00:00
Joe Groff
2c04f45912 Have the ASTWalker walk type-checked raw value exprs.
We don't let it see the pre-type-checked LiteralExpr yet because EnumElementDecls need to do its own checking.

Swift SVN r8547
2013-09-21 15:21:16 +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
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
7c408791cd Code completion: implement delayed parsing of destructors (and basic code completion)
Swift SVN r8352
2013-09-17 21:08:09 +00:00
Dmitri Hrybenko
f1f189f4e0 Rename PipeClosureExpr -> ClosureExpr
Swift SVN r8321
2013-09-17 01:37:36 +00:00
Dmitri Hrybenko
b18c38a322 Rename ImplicitClosureExpr -> AutoClosureExpr
Swift SVN r8304
2013-09-16 23:03:50 +00:00
Dmitri Hrybenko
f8bd657b2f ImplicitClosureExpr (AutoClosureExpr in future): store body as BraceStmt
This allows us to add AnyFunctionRef::getBody(), which returns the body
as a BraceStmt for every function-like AST node.


Swift SVN r8293
2013-09-16 20:52:12 +00:00
Dmitri Hrybenko
e7af4d6c72 Collapse ImplicitClosureExpr into its abstract base class, ClosureExpr
Swift SVN r8280
2013-09-16 18:31:05 +00:00
Dmitri Hrybenko
536ed954ad Remove FuncExpr. Add CaptureInfo to FuncDecl. Introduce AnyFunctionRef.
AnyFunctionRef is a universal function reference that can wrap all AST nodes
that represent functions and exposes a common interface to them.  Use it in two
places in SIL where CapturingExpr was used previously.

AnyFunctionRef allows further simplifications in other places, but these will
be done separately.


Swift SVN r8239
2013-09-14 02:15:48 +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
Doug Gregor
8c60d88f5a Provide DynamicMemberRefExpr with .Some(fn)/.None helper expressions.
These helper expressions will eventually be used by SILGen to help
package up the optional values. I expect that we'll eventually have
library builtins for this, so consider this a stop-gap until those
appear.

As part of this, make OpaqueValueExpr a bit more usable: it can now
persist in the AST as a placeholder, but its uses must be within AST
subtrees of some specific introduction point (similarly to how Clang's
OpaqueValueExpr works).


Swift SVN r8051
2013-09-09 19:58:51 +00:00
Dmitri Hrybenko
1e23c936e0 Rename FuncDecl::getBody() to FuncDecl::getFuncExpr()
ConstructorDecl::getBody() and DestructorDecl::getBody() return 'BraceStmt *'.
After changing the AST representation for functions, FuncDecl::getBody() will
return 'BraceStmt *' and FuncDecl::getFuncExpr() will be gone.


Swift SVN r8050
2013-09-09 19:57:27 +00:00
Doug Gregor
0554c944a2 Fold GenericSubscriptExpr into SubscriptExpr.
Swift SVN r7845
2013-09-03 16:25:07 +00:00
Doug Gregor
786f9d299b Fold GenericMemberRefExpr into MemberRefExpr.
MemberRefExpr now uses ConcreteDeclRef to refer to its member, which
includes the substitutions and obviates the need for
GenericMemberRefExpr.


Swift SVN r7842
2013-09-03 15:49:19 +00:00
Doug Gregor
b06e65c3b3 Add the DynamicLookup protocol for lookup across all classes and protocols.
When performing member lookup into an existential that involves the
DynamicLookup protocol, look into all classes and protocols for that
member. References to anything found via this lookup mechanism are
returned as instances of Optional.

This introduces the basic lookup mechanics into the type
checker. There are still numerous issues to work through:
  - Subscripting isn't supported yet
  - There's no SILGen or IRGen support
  - The ASTs probably aren't good enough for the above anyway
  - References to generics will be broken
  - Ambiguity resolution or non-resolution

Thanks to Jordan for the patch wiring up DynamicLookup.


Swift SVN r7689
2013-08-28 21:38:50 +00:00
Argyrios Kyrtzidis
6d57b49e02 Have the ASTWalker walk protocol declarations.
Also make the implicit AssociatedTypeDecl, created for a protocol, to have the
location of its protocol, otherwise the verifier will complain that a decl has no
source range.

Swift SVN r7673
2013-08-28 18:22:06 +00:00
Dmitri Hrybenko
d9035426ed Rename RebindThisInConstructorExpr -> RebindSelfInConstructorExpr
Swift SVN r7658
2013-08-28 03:02:30 +00:00
Doug Gregor
7e5e154f87 Traversal: turn missing visit*Stmt methods into link-time errors.
Swift SVN r7508
2013-08-23 18:16:22 +00:00