Commit Graph

28404 Commits

Author SHA1 Message Date
Eli Friedman
80b55617ba Start of computing captures for CapturingExprs in the AST; only works for ExplicitClosureExprs so far. Per previous discussion, anything which can be captured goes through the relevant codepath in Parser::actOnIdentifierExpr.
Swift SVN r1251
2012-03-22 02:37:57 +00:00
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
618cfc4b21 Build VarDecls and a Pattern for the paramters for an explicit closure. Not used yet.
Swift SVN r1242
2012-03-20 01:24:52 +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
8aafdda9f6 after an epic refactoring fest, finally implement ivar/method lookup in methods, resolving rdar://10682135.
There are still problems in the field of name lookup, but this is progress at least.


Swift SVN r1235
2012-03-19 06:08:57 +00:00
Chris Lattner
388eb650aa move construction of ast for dot syntax out to NameLookup. No functionality change.
Swift SVN r1234
2012-03-19 06:01:09 +00:00
Chris Lattner
ce717d2c7c teach IRGenFunction::emitIgnored to handle expressions of module and metattype type.
Teach Expr::getSemanticsProvidingExpr to look through DotSyntaxBaseIgnoredExpr.
Start generating DotSyntaxBaseIgnoredExpr for all dot syntax exprs where the base is
ignored (e.g. "Builtin.mul_i32"), which preserves a lot more source location information
and is general goodness for the AST.


Swift SVN r1232
2012-03-19 05:33:29 +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
92f3d6a431 checkpoint, nothing useful here.
Swift SVN r1228
2012-03-19 05:15:59 +00:00
Chris Lattner
f986dbaf95 Add a new file to handle name lookup tasks, implement a bunch of
stuff that will eventually be centralized "dot" lookup mechanics.


Swift SVN r1227
2012-03-18 01:17:32 +00:00
Chris Lattner
1ecef669b4 elimiante TC member.
Swift SVN r1226
2012-03-18 01:16:17 +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
60d9b2a570 intermediate progress on rdar://10682135, nothing particularly useful so far.
Swift SVN r1207
2012-03-11 23:57:09 +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
636ba08a4d eliminate some manual forwarding that is now redundant.
Swift SVN r1198
2012-03-11 14:56:58 +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
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
630dc9c0f5 implement semantic analysis for autoclosure functiontypes, building ImplicitClosure
as appropriate.


Swift SVN r1191
2012-03-11 14:00:35 +00:00
Chris Lattner
cd108afcce reject auto_closure on decls.
Swift SVN r1189
2012-03-11 13:23:15 +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
787e21233e Diagnose all attempts to immediately load from an explicit
l-value.

Swift SVN r1183
2012-03-11 09:15:25 +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
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
862646c1dd Perform conversion to bool in conditionals by repeatedly calling ".getLogicValue()" on the value until we reach Builtin.Int1, instead of using convertToLogicValue(). <rdar://problem/10100856>.
Swift SVN r1173
2012-03-10 00:02:36 +00:00
Eli Friedman
adcf0bc6c2 Expand out radix detection in applyTypeToLiteral so it uses the same rules as the lexer, instead of using StringRef's autosensing rules. This makes octal literals work correctly. Finishes <rdar://problem/10700832>.
Swift SVN r1171
2012-03-07 04:12:16 +00:00
Eli Friedman
8f02e3f032 Make sure we correctly apply lvalue-to-rvalue conversions for CallExprs. <rdar://problem/10934313>.
Swift SVN r1169
2012-03-05 21:52:30 +00:00
Eli Friedman
ddffb633eb Fix build errors with clang-421.
Swift SVN r1167
2012-03-05 19:31:12 +00:00
Chris Lattner
22df6953d7 Tighten up some logic, finishing off rdar://10666917 - Anonymous closure arguments must be in {}'s
Swift SVN r1166
2012-03-05 12:09:57 +00:00
Chris Lattner
5f7679ef4d restrict autoclosure to only happening when the destination function type has an
empty tuple as an argument.  This should be restricted even more (rdar://10983400)
but this eliminates the most surprising cases at least.


Swift SVN r1165
2012-03-05 12:06:55 +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
82d73b0385 move visitExplicitClosureExpr out of line, remove the
now-dead IgnoreAnonDecls argument to SemaCoerce::convertToType


Swift SVN r1162
2012-03-04 17:57:13 +00:00
Chris Lattner
0cf1e5e1f2 update testcase to use {} with $42 arguments. Remove binding of anon closure arguments
from implicit auto-closure.


Swift SVN r1159
2012-03-04 05:26:21 +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
c9a0aa66c4 bind anonymous closure arguments in an explicit closure.
Swift SVN r1157
2012-03-04 05:11: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
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
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
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
Chris Lattner
dd5df2915a rename convert_from_integer_literal -> convertFromIntegerLiteral to follow the naming convention,
part of rdar://10962528


Swift SVN r1136
2012-03-01 18:54:29 +00:00
Chris Lattner
aa39667cae disallow destructuring a struct with a var, e.g.:
struct point { x : int, y : int }
var (a, b) = foo()  // when foo returns a 'point'

allowing this breaks our fragility model (e.g. members can be added/removed from the struct) and this generally needs to be integrated with our pattern matching stuff.  rdar://10934540



Swift SVN r1135
2012-03-01 18:45:15 +00:00