Commit Graph

22474 Commits

Author SHA1 Message Date
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
Chris Lattner
17ea0a6670 finish my pass over LangRef, updating it and changing it and the parser to keep the grammars in sync.
Swift SVN r1132
2012-03-01 16:55:09 +00:00
John McCall
00b97b38af Grab-bag of materialization-related changes:
- introduce the concept of qualifiers on l-value types
  - teach overload resolution and coercion how to drop explicitness
  - require explicitness on normal [byref] arguments
  - make 'this' [byref(implicit)]
  - special-case '&' as a unary operator in the parser to make it
    produce an expression which type-checks as turning implicit l-values
    into explicit ones.

Obvious missing pieces:
  - updating LangRef
  - we should really complain about ever trying to rvalue-convert an
    explicit l-value
  - maybe qualification should play a part in overload resolution
  - we should diagnose attempts to declare unary '&' operators
  - there's a test case in expressions.swift which suggests my logic is
    slightly off

But I am out of time, and these will have to wait.

Swift SVN r1119
2012-02-22 06:43:33 +00:00
John McCall
a9120cf1bf Stop storing the lvalue-projection bit on TupleElementExpr and
LookThroughOneofExpr.

Swift SVN r1114
2012-02-16 01:57:07 +00:00
Chris Lattner
01a53ac0d5 improve comment.
Swift SVN r1113
2012-02-13 22:27:52 +00:00
John McCall
2b65cf22d1 Make 'this' implicitly [byref] when the container type does
not have reference semantics.  Deciding whether the container
type has reference semantics requires us to perform
some amount of limited name-binding and type-checking first,
which introduces a few complexities.

Also, fix a bug in uncurried call emission.

Methods work now.



Swift SVN r1112
2012-02-11 07:37:57 +00:00
John McCall
7b29a420f6 Design and implement the [byref] attribute, checking that
it doesn't appear in places it shouldn't.  The only limits on
this checking right now is the inadequacy of location information
for types, which is something we ought to fix.

Fix type-checking of byref applications.  Fix IR generation
of byref variables.  Whole lotta fixin' goin' on.

But hey, byref calls work.



Swift SVN r1111
2012-02-10 09:42:50 +00:00
John McCall
7f60469fdf Introduce the notion of a "fully-typed" type, necessary
because tuple types can have defaulted elements.  Check for
it and complain in function signatures.



Swift SVN r1109
2012-02-07 03:48:23 +00:00
John McCall
5a3567ff01 Diagnose attempts to declare operators with anything
except 'func'.  It doesn't make any sense to me for operators
to have variable semantics, and it's unnecessary complexity
in the type-checker.



Swift SVN r1108
2012-02-06 22:54:32 +00:00
John McCall
d0f4d86f3e Use LValueType everywhere instead of the l-value value kind.
Kill off TypeJudgement.  Various fixes and improvements.



Swift SVN r1107
2012-02-06 22:47:08 +00:00
John McCall
5f1bcd7b7e Move all the side-allocated members of ASTContext to a single
side-allocation.  This is both easier to work with and extend
and slightly more efficient.



Swift SVN r1106
2012-02-02 01:13:33 +00:00
John McCall
6ff9afb6f5 Introduce LValueType.
Swift SVN r1105
2012-02-02 00:57:10 +00:00
John McCall
6d8837dc8d Macro metaprogramming for types.
Swift SVN r1104
2012-02-01 22:37:59 +00:00
John McCall
76ad8fff02 Add more parentheses to Types.h.
Swift SVN r1103
2012-01-31 04:32:37 +00:00
John McCall
e66c13cfe7 Change the 'walk' APIs to use virtual function dispatch
instead .
1,2d
1i
Change the 'walk' APIs to use virtual dispatch instead of
blocks.  This makes it much easier to thread information
through the API, as well to extend the API to handle
recursive visiting of other structures (e.g., Decls
and Patterns).



Swift SVN r1101
2012-01-26 04:31:38 +00:00
John McCall
ce7780af04 I don't think we're really getting anything out of ArgDecl
at the moment.  We can put it back if I'm wrong.



Swift SVN r1100
2012-01-26 02:08:52 +00:00
John McCall
16f8b2e656 Revise the language design for function argument clause syntax.
A function argument clause is now one or more patterns (which
must be parenthesized and explicitly type all positions) not
separated by arrows;  the first arrow then separates off the
return type.

Revisions to language reference forthcoming.



Swift SVN r1099
2012-01-26 01:25:26 +00:00
John McCall
14aa93a382 Publicize an API for printing out a source location for
debugging purposes.  Add a PrettyStackTraceLocation for
noting that we're currently processing a fixed location.



Swift SVN r1096
2012-01-26 00:07:05 +00:00
John McCall
ecb7bbc790 Basic ASTs for pattern-matching. We're going to generate
these for FuncExpr signatures.



Swift SVN r1095
2012-01-24 22:27:06 +00:00
Chris Lattner
bab9ca384c switch TupleExpr to use MutableArrayRef.
Swift SVN r1090
2012-01-19 06:54:43 +00:00