Commit Graph

594 Commits

Author SHA1 Message Date
Eli Friedman
43e7559310 Add GenericSubscriptExpr to represent subscripting into a generic type.
Swift SVN r2336
2012-07-10 23:39:46 +00:00
Eli Friedman
b067da1104 Add GenericMemberRefExpr to represent a reference to a member of a generic type.
Add a couple other misc pieces necessary for semantic analysis of members of
generic types.  We're now up to the point where we can actually construct a
useful AST for small testcases.



Swift SVN r2308
2012-07-05 20:45:31 +00:00
Doug Gregor
0741dcec2b Introduce ArchetypeSubscriptExpr to model subscripting of a value of
archetype type.


Swift SVN r2209
2012-06-20 00:27:28 +00:00
Doug Gregor
f847fe4a22 Introduce basic support for type-checking the definitions of generic
functions. This involves a few steps:

  - When assigning archetypes to type parameters, also walk all of the
  protocols to which the type parameter conforms and assign archetypes
  to each of the associated types.
  - When performing name lookup into an archetype, look into all of
  the protocols to which it conforms. If we find something, it can be
  referenced via the new ArchetypeMemberRefExpr.
  - When type-checking ArchetypeMemberRefExpr, substitute the values
  of the various associated types into the type of the member, so the
  resulting expression involves the archetypes for the enclosing
  generic method.

The rest of the type checking essentially follows from the fact that
archetypes are unique types which (therefore) have no behavior beyond
what is provided via the protocols they conform to. However, there is
still much work to do to ensure that we get the archetypes set up
correctly.



Swift SVN r2201
2012-06-19 21:16:14 +00:00
Doug Gregor
265292805e Introduce ExistentialSubscriptExpr, which describes subscript
operations into an existential type.


Swift SVN r2194
2012-06-18 17:45:57 +00:00
Chris Lattner
db0cd646fc lexer/parser/ast/sema support for do/while statements. irgen next.
Swift SVN r2186
2012-06-17 02:29:54 +00:00
Eli Friedman
45f1fa1f6c Fix some comments; remove unused ErrorStmt.
Swift SVN r2169
2012-06-07 22:14:17 +00:00
Eli Friedman
e5b4b924a1 More work on constructors. Basic testcases with "constructor" declarations appear to be working, although there's probably more work to be done. (Both old-style and new-style constructors work for the moment.)
Swift SVN r2163
2012-06-07 01:57:57 +00:00
Eli Friedman
75907029f1 Add parsing and semantic analysis for a basic ConstructorDecl. Still missing: no IRGen, and semantic analysis to actually call them.
Swift SVN r2159
2012-06-05 23:51:19 +00:00
Eli Friedman
ba4a76038b Make oneofs never implicitly generate an ExtensionDecl. This matters for local oneofs.
Swift SVN r2098
2012-05-31 21:20:56 +00:00
Eli Friedman
c404598fcb Parsing and semantic analysis for 'break' and 'continue'.
Swift SVN r2087
2012-05-31 00:55:33 +00:00
Eli Friedman
6fe5759841 Get rid of a hack where ASTWalker was trying to walk the AST for BinaryExprs in a non-standard order. It introduces complexity with no obvious benefit.
Swift SVN r1984
2012-05-25 01:39:00 +00:00
Doug Gregor
0062c84351 Introduce ExistentialMemberRefExpr for references to the members of
values of existential type, e.g.,

  var x : Printable
  x.print()

Existential member references reify the type of the implicit object
argument (implicitly, because we have no way of expressing this in the
type system), and replace the types of any other archetypes
with existential types that (don't, but will eventually) conform to
the protocols to which the archetypes conform.



Swift SVN r1963
2012-05-23 23:06:34 +00:00
Doug Gregor
a9906ad38f Introduce support for implicit user-defined conversions.
A user-defined conversion function is an instance method that accepts
an empty tuple and returns a value of the type we're converting to,
has the [conversion] attribute, and is named __conversion. The last of
these restrictions is a temporary hack to work around our inability to
perform a lookup across all extensions for "every function with the
conversion attribute", and shouldn't last too long.

As in C++, we only get one user-defined conversion function. Unlike in
C++, a constructor is not (and cannot) be a conversion function.

Introduce NSString <-> String conversion functions, but leave the
runtime implementations as stubs for Dave to fill in.



Swift SVN r1921
2012-05-21 23:36:16 +00:00
Eli Friedman
b788bad8e6 A couple missing pieces for classes. Also, a few fixes for local types.
Swift SVN r1873
2012-05-16 19:21:07 +00:00
Eli Friedman
33f20a14e0 Add NewReferenceExpr, for allocating class objects.
Swift SVN r1867
2012-05-16 01:36:03 +00:00
Eli Friedman
6f045aad2f Throw the switch to use "var" syntax to declare members of structs. This also means we no longer build an implicit extension for every struct decl. Everything seems to be working, but please yell if this breaks anything.
Swift SVN r1851
2012-05-15 03:27:13 +00:00
Eli Friedman
4ca443d0f5 Add OneOfDecl; use it as a DeclContext for OneOfElementDecls instead of OneOfType, and get rid of the implicit TypeAliasDecl. Add TypeDecl as a base class for OneOfDecl and TypeAliasDecl (and StructDecl, once we have it). Adjust a whole bunch of stuff to this new scheme.
Swift SVN r1774
2012-05-08 21:09:42 +00:00
Chris Lattner
2f44c0038c Initial stab at implementing string literal interpolation for simple expressions,
e.g. "foo is \(i+j)".  This implements rdar://11223686

Doug implemented all the hard parts of this.  I ripped out support for nested string
literals (i.e. string literals within an interpolated string), which simplified the
approach and defined away some problems with his patch in progress.  I plan a few refinements
on top of this basic patch.



Swift SVN r1738
2012-05-04 05:53:50 +00:00
Chris Lattner
46c94377f1 Add support for var decls in the initializer of a c-style for loop,
implementing rdar://11360347 / 11349750.  C-style for loops could be
further enhanced by allowing a comma-separated list of statements in
the increment, but this isn't something I plan to do in the short term.


Swift SVN r1713
2012-05-02 05:44:58 +00:00
Chris Lattner
20663a8aff introduce a new abstract LiteralExpr base class shared among the literals,
simplifying some code that previously enumerated all of them.


Swift SVN r1664
2012-04-26 23:04:24 +00:00
Eli Friedman
e33b1aac24 Don't try to synthesize an expression for a return statement which doesn't have one. <rdar://problem/11315114>.
Swift SVN r1639
2012-04-25 22:58:06 +00:00
Doug Gregor
f997a781bf Parsing and basic AST representation for 'foreach' statement.
Swift SVN r1594
2012-04-24 18:12:44 +00:00
Doug Gregor
6122a9f5e3 Introduce an overloaded subscript expression type, to cope with cases
where overloading based on the indices is insufficient to select an
overload candidate. Implement type coercion for overloaded subscript
expressions, so that the context can help push overload resolution
along.


Swift SVN r1516
2012-04-19 23:43:44 +00:00
Doug Gregor
cd7be4edf1 Add an AST for subscript expressions; no real type checking yet.
Swift SVN r1512
2012-04-19 22:07:42 +00:00
Chris Lattner
cbc1eac438 irgen parser and sema support for for statements.
Swift SVN r1505
2012-04-19 21:43:46 +00:00
Eli Friedman
d5e7784010 Get rid of isModuleScope bit, since we don't like scattering bits across the AST; as a replacement, introduce TopLevelCodeDecl, which provides a DeclContext for all expressions and statements at the top level. <rdar://problem/11259941>.
Swift SVN r1503
2012-04-19 21:22:12 +00:00
John McCall
66318f5e12 First round of type-checking for new-expressions: form
the appropriate slice type and check the bounds.  The
first bound must be a literal or a type with a
getArrayBoundValue method, which has the same recursive
nature as getLogicValue (i.e. it can return a type that
has a getArrayBoundValue that returns an integral type,
but that's it;  it's capped at one hop).  The rest
of the bounds must be empty (meaning a slice) or
constant under the same conditions as fixed-size
array types.

Swift SVN r1501
2012-04-19 21:05:37 +00:00
Doug Gregor
b7b8f171b3 Treat a function application A(b) as a coercion of the expression 'b'
to the type named by A (when A is in fact a direct reference to a
type). If that coercion would fail, then fall back to invoking a
constructor. Fixes <rdar://problem/11272190>.



Swift SVN r1472
2012-04-18 17:04:34 +00:00
John McCall
71157c65d5 Add parsing support, but no type-checking or IR-generation,
for new expressions.

Swift SVN r1466
2012-04-18 08:09:18 +00:00
Doug Gregor
3243108518 Introduce an new expression, MemberRefExpr, that refers to a
member of an object. This expression kind is currently used to refer
to properties within an object, but will eventually be extended to
refer to fields as well (once we make StructDecl real).


Swift SVN r1445
2012-04-17 00:35:06 +00:00
Eli Friedman
37de44a35d Implement changes to parsing/sema/etc so that we can implement a REPL and the main module parses the same way as a REPL.
Next step: implement an actual REPL.



Swift SVN r1441
2012-04-16 23:52:01 +00:00
Doug Gregor
0fdb4d00fc When we parse a 'var' declaration, we add all of the VarDecls and the
PatternBindingDecl to the DeclContext. Do the same for the get/set
functions for a property, so we don't need to perform 'deep' setting
of the DeclContext. This is simpler, although it makes pretty-printing
the AST a bit more difficult.



Swift SVN r1428
2012-04-13 22:22:17 +00:00
Doug Gregor
511195b1be Traverse the getter/setter of a VarDecl, so that we get type checking
for these functions. And now that it's actually type-checked, build
the getter's AST properly.


Swift SVN r1416
2012-04-13 18:16:15 +00:00
Doug Gregor
a3c34c5dbd Introduce an AST node (OverloadedMemberRefExpr) that represents dot
syntax when name lookup finds multiple candidates. Overload resolution
is then used to select the best candidate and map the overloaded
member reference expression down to DotSyntaxCallExpr or
DotSyntaxBaseIgnoredExpr, as appropriate.

This implements part of <rdar://problem/11071641>, so that simple
overload resolution works, but there is still a bit of cleanup to do.



Swift SVN r1366
2012-04-10 22:52:41 +00:00
Chris Lattner
5650d08ddf implement parsing, AST, and sema support for simple strings,
no irgen yet.


Swift SVN r1351
2012-04-10 01:25:51 +00:00
Doug Gregor
c24d6ec8c4 Factor OverloadSetRefExpr into an abstract base class covering the
notion of a reference to a set of declarations. Introduce one derived
class, OverloadedDeclRefExpr, which covers the only case we currently
handle for overload resolution [*]: a direct (unqualified) reference
to an overloaded set of entities. Future subclasses should handle,
e.g., overloaded member references such as a.b or a.b.c.

[*] Ugly hacks for static methods notwithstanding


Swift SVN r1345
2012-04-09 17:16:11 +00:00
Eli Friedman
94244131f7 Remove ElementRefDecl and DeclVarName. Add the replacement, PatternBindingDecl. Use proper pattern parsing for variable declarations. Uniformly use PatternBindingDecl for variable initialization. Adapt type-checking and IRGen for this new style of variable declaration. <rdar://problem/11124980>.
Swift SVN r1312
2012-04-02 23:49:28 +00:00
Doug Gregor
3299d8b176 Eliminate BinaryExpr::getArgTuple(). The argument to a binary
expression will always be a two-element tuple, but it may not always
be a tuple literal. In the near future, it could also be a tuple
shuffle.



Swift SVN r1299
2012-03-30 18:37:02 +00:00
Eli Friedman
d2bbf81245 Zap AnonClosureArgExpr.
Swift SVN r1269
2012-03-27 01:03:15 +00:00
John McCall
2fd608ae4d Add basic parsing and type-system support for the byref(heap)
qualifier, making sure that variables end up so-qualified by
default.  Add a RequalifyExpr to capture the act of adding
qualifiers (to form a supertype) to an l-value.

Swift SVN r1236
2012-03-19 06:55:23 +00:00
Chris Lattner
4e4c1bf417 rename DotSyntaxPlusFuncUseExpr -> DotSyntaxBaseIgnoredExpr
to properly represent its newly generalized role.  It is formed
for things like "swift.print" where swift is a module type and is
evaluated and ignored.


Swift SVN r1230
2012-03-19 05:23:39 +00:00
Chris Lattner
f3b62f09c7 enhance astwalker to allow implementations to control pre/post-order visiting of decls.
Swift SVN r1203
2012-03-11 21:26:02 +00:00
Chris Lattner
b54d2bc5fb rename Walk.cpp -> ASTWalker.cpp
Swift SVN r1202
2012-03-11 16:29:47 +00:00