Commit Graph

641 Commits

Author SHA1 Message Date
Eli Friedman
ea17adc3ec Completely switch over IRGen for closures to use the standard prologue/epilogue emission.
Swift SVN r1250
2012-03-22 01:04:05 +00:00
Eli Friedman
61c2a9ea18 Fix error-checking for UnresolvedMemberExpr coercion. Some minor improvements for coercion and lvalues. Converting dependent types still has a lot of issues.
Swift SVN r1249
2012-03-21 05:13:40 +00:00
Eli Friedman
fdc45c7611 Store the VarDecls and Patterns for AnonClosureArgExpr and ExplicitClosureExpr in the AST.
It might be possible to save some memory by breaking the AnonClosureArgExpr linked list during type-checking... not sure if that's worthwhile.



Swift SVN r1248
2012-03-20 21:43:36 +00:00
Eli Friedman
8ece7c0103 Fix a few minor typos.
Swift SVN r1241
2012-03-20 01:23:44 +00:00
Eli Friedman
d39a7abe36 Implement CapturingExpr. In addition to unifying the hierarchy between FuncExpr and ClosureExpr, this introduces a DeclContext for ClosureExprs. <rdar://problem/11076715>
Swift SVN r1240
2012-03-20 01:08:04 +00:00
John McCall
1a4b945a14 Flag in a ValueDecl whether it's ever been used as an
l-value or a heap l-value, except to immediate convert
it to an r-value or a non-heap l-value.

Swift SVN r1237
2012-03-19 08:28:42 +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
6185ab6d50 move getImplicitThisDecl to FuncDecl where the other 'this' handling stuff goes.
Swift SVN r1233
2012-03-19 05:43:20 +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
e7cd357065 reimplement TypeChecker::semaUnresolvedDotExpr in terms of the new
MemberLookup class.


Swift SVN r1229
2012-03-19 05:16:19 +00:00
Chris Lattner
1884e4943f refactor some code out of Sema into AST.
Swift SVN r1225
2012-03-17 23:07:00 +00:00
John McCall
1f118dbda6 Basic support for Builtin.ObjectPointer as a completely
opaque type.  Also some rudimentary support for retain/release.

Swift SVN r1214
2012-03-16 09:26:32 +00:00
Eli Friedman
595676abf7 Limit the number of potential getLogicValue() calls for a conditional to 2. Per Chris's comments.
Swift SVN r1208
2012-03-13 21:58:53 +00:00
Chris Lattner
11f3d2bcae implement a method to get the 'this' argument for a FuncExpr if there is one.
Swift SVN r1204
2012-03-11 23:35:48 +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
0cccfe9299 rename the Walker class to ASTWalker to match ASTVisitor.
Swift SVN r1201
2012-03-11 16:28:50 +00:00
Chris Lattner
0340dd17d0 rename Walk.h to Walker.h to match the name of the class it declares.
Swift SVN r1200
2012-03-11 16:22:26 +00:00
Chris Lattner
3b0db63f85 introduce ImplicitThisTupleElementExpr, progress towards 10682135.
IRGen should really use visitors for expr emission...


Swift SVN r1199
2012-03-11 15:02:16 +00:00
Chris Lattner
7c2da880e1 Put 'Expr' in the right place.
Swift SVN r1197
2012-03-11 14:54:43 +00:00
Chris Lattner
d75f76a096 split TupleElementExpr into an abstract TupleElementExpr class and a concrete
SyntacticTupleElementExpr class.  One step towards resolving rdar://10682135.


Swift SVN r1195
2012-03-11 14:48:04 +00:00
Chris Lattner
672801980d enhance ASTVisitor for expressions to automatically synthesize visit methods for nodes
that are not handled by a visitor.  Make their implementation chain up to a parent node's
implementation.  For example, a (silly) visitor could choose to just implement visitExpr
and get all nodes.


Swift SVN r1194
2012-03-11 14:47:16 +00:00
Chris Lattner
e3f6f4b87a Convert test cases to use the new auto_closure attribute,
inform conversion ranking about auto_closure, and rip out the
CR_AutoClosure implicit conversion.  Our conversion ranking is
now completely trivial: we either have an identity conversion
or an invalid one - no crazy implicit conversions (still have
tuple shuffles etc though).


Swift SVN r1192
2012-03-11 14:08:40 +00:00
Chris Lattner
71f351e0b6 fix the autoclosure bit to be properly canonicalized and preserved when building functiontypes.
Swift SVN r1190
2012-03-11 14:00:05 +00:00
Chris Lattner
cd108afcce reject auto_closure on decls.
Swift SVN r1189
2012-03-11 13:23:15 +00:00
Chris Lattner
494aa187fa prune #include
Swift SVN r1188
2012-03-11 13:15:47 +00:00
Chris Lattner
145d926548 Perform sema of FunctionType's that have auto_closure behavior, building a bit in FunctionType.
Swift SVN r1187
2012-03-11 13:15:03 +00:00
Chris Lattner
01b184acab parse the auto_closure attribute.
Swift SVN r1186
2012-03-11 12:44:19 +00:00
John McCall
ed436cf3ff Forbid the declaration of a custom unary '&' operator.
Swift SVN r1184
2012-03-11 09:15:28 +00:00
John McCall
b2a2027a43 Revert r1144, r1145, and r1146. These changes (which removed ParenType
in favor of a single-element non-canonical TupleType) broke the type
system, in that supposed sugar (the TupleType) supported a different
set of operations from the canonical type.  For example, a
single-element unlabelled tuple type supports elementwise projection
(foo.$0), but the underlying element does not (or supports it
differently).

The IR-gen failure was due to a very related problem:  IR-gen
was not updated to reflect that a single unlabelled tuple element
is the same type as its element type, and therefore it was giving
different representations to these types ({ %foo } and %foo,
respectively), which broke widespread assumptions.

The removal of ParenType was done in pursuit of an AST invariant
that's not actually particularly interesting in the first place
and which, furthermore, is problematic to attain.

Swift SVN r1182
2012-03-11 09:15:21 +00:00
John McCall
b8b1694564 Complain about file names that aren't valid identifiers.
When we divide the world into scripts and modules, this
won't matter for the former.  Recognize <stdin> as a
special case;  it should instead just always be a script.
Fixes rdar://problem/10986311.

Swift SVN r1181
2012-03-11 09:15:17 +00:00
Chris Lattner
9e873372d9 move attributes out to their own .def file, to match expr's and stmt's.
Part of rdar://10719165 - Clean up attributes code


Swift SVN r1179
2012-03-11 01:39:11 +00:00
Eli Friedman
18016053df Add basic infinite loop checking for conversion for conditional, per John's comment. There's probably some way I can't think of off the top of my head to write an infinite loop this doesn't catch, but it should be enough to catch obvious mistakes.
Swift SVN r1175
2012-03-10 00:26:36 +00:00
Eli Friedman
eada7c6558 Make sure we catch 0x/0o/0b which isn't followed by an appropriate digit. Per Chris's comment.
Swift SVN r1174
2012-03-10 00:12:43 +00:00
Chris Lattner
50c95e7f32 resolve the FIXME.
Swift SVN r1172
2012-03-09 11:13:43 +00:00
Eli Friedman
48f0f1d77e Fix assertion failure on tests.
Swift SVN r1168
2012-03-05 19:58:06 +00:00
Chris Lattner
d3b8e8b09e Now that we have a list of all argument uses in a closure,
eliminate BindAndValidateClosureArgs and replace a tree
walk with a simple linked list traversal.



Swift SVN r1163
2012-03-05 11:23:26 +00:00
Chris Lattner
7b2660db69 Whenever a AnonClosureArgExpr is parsed, immediately add it to a
list on the containing and owning closure.


Swift SVN r1161
2012-03-04 17:53:33 +00:00
Chris Lattner
4fde79bfac have the parser keep track of the current explicit closure and diagnose when an
argument is found outside any closure.


Swift SVN r1160
2012-03-04 05:37:13 +00:00
Chris Lattner
477b614e05 diagnose a mismatch of a closure body with its inferred return type. For
example:

t.swift:2:39: error: invalid conversion from type 'double' to 'int'
var closure5 : (double) -> int = { $0 + 1.0 }
                                   ~~~^~~~~
t.swift:2:34: note: while converting closure body to inferred return type 'int'
var closure5 : (double) -> int = { $0 + 1.0 }
                                 ^ ~~~~~~~~
t.swift:2:1: note: while converting 'var' initializer to declared type '(double) -> int'
var closure5 : (double) -> int = { $0 + 1.0 }
^



Swift SVN r1158
2012-03-04 05:19:07 +00:00
Chris Lattner
2564713a47 Implement parser and the first part of sema support for explicit
closures.  Start by rejecting closures inferred to have non-function type.


Swift SVN r1156
2012-03-04 04:34:45 +00:00
Chris Lattner
6aac93155d add an AST node to represent explicit closures. Not yet created.
Swift SVN r1154
2012-03-03 12:12:57 +00:00
Chris Lattner
3a6e84f82e Add a new "ImplicitClosureExpr" subclass of ClosureExpr to represent the autoclosure case.
Swift SVN r1152
2012-03-03 11:54:43 +00:00
Chris Lattner
c638af658b update comment.
Swift SVN r1149
2012-03-02 00:39:07 +00:00
Chris Lattner
2d7babaf43 clean up some stuff around function argument types.
Swift SVN r1148
2012-03-02 00:25:31 +00:00
Chris Lattner
6641b06283 remove ParenType, which is now dead. Grouping parens are represented
as non-canonical tuple types.


Swift SVN r1147
2012-03-02 00:17:45 +00:00
Chris Lattner
f8b363fc1f enforce a syntactic form that function argument lists must be parenthesized, part of
rdar://10666966


Swift SVN r1144
2012-03-01 23:46:14 +00:00
Chris Lattner
0169b2c764 introduce a new ErrorStmt node to represent invalid code in the AST more
precisely.  Part of rdar://10962837


Swift SVN r1142
2012-03-01 22:40:16 +00:00
Chris Lattner
21c8b4dae9 implement a more-sane floating point literal syntax, adding support for
exponents.  This resolves rdar://10877508


Swift SVN r1140
2012-03-01 21:42:10 +00:00
Chris Lattner
b49cf74af0 doh, make that IntegerLiteralType.
Swift SVN r1139
2012-03-01 19:13:20 +00:00
Chris Lattner
a7cd920b57 rename integer_literal_type -> integerLiteralType.
Swift SVN r1138
2012-03-01 19:11:05 +00:00