Chris Lattner
f704c58c42
Two significant changes:
...
1. Change the representation of TupleType to contain TupleTypeElt structs instead of PointerUnion<Type*, NameDecl*>
2. Change type canonicalization to not strip field names off tuples, and change type conversion logic to use canonical types again.
Also adds some stuff to the todo list, destined to never be short.
Swift SVN r141
2010-08-04 03:35:53 +00:00
Chris Lattner
807a82cd3d
Resolve a fixme involving precedence of juxtaposition.
...
Swift SVN r140
2010-08-04 00:34:27 +00:00
Chris Lattner
f125062eae
Wire up elementwise type conversion for tuple conversion. This allows us to handle cases like:
...
func funcdecl3() -> int;
func funcdecl4(a : (int->int), b : int);
... funcdecl4(funcdecl3(), 12); ...
Swift SVN r138
2010-08-03 07:10:44 +00:00
Chris Lattner
04f7a08621
add support for tuple field access with ".", e.g.:
...
var a : (int, var f : int, int);
var b = a.field0+a.field1+a.f;
This also eliminates TupleConvertExpr.
Swift SVN r137
2010-08-03 06:55:08 +00:00
Chris Lattner
6858e37cf2
implement a lot more semantic analysis for tuple conversions.
...
Swift SVN r136
2010-08-03 05:25:10 +00:00
Chris Lattner
66897ed42e
Remove a bunch of dead code, it isn't worth keeping it around.
...
Swift SVN r135
2010-08-03 04:44:38 +00:00
Chris Lattner
1bb344c282
strength reduce our handling of dependent types. Now, you can't compose dependent types, there isn't a (dep, int) type, the whole tuple gets dependent type. This simplifies things a bit.
...
Swift SVN r134
2010-08-03 04:36:05 +00:00
Chris Lattner
7a5b428772
start reworking tuple compatibility: two different tuples aren't compatible because their canonical type is the same, they are compatible because one can be converted to the other. I'm just going to rip out canonical type support for now.
...
Swift SVN r133
2010-08-03 04:17:26 +00:00
Chris Lattner
c6499fe1ed
Fixme patrol, clean some up.
...
Swift SVN r131
2010-08-01 07:09:40 +00:00
Chris Lattner
c2fdbb65c6
Tuple types with a single element are now valid. var x : (((int))); is now a triply nested tuple. To make this work, values are allowed to convert to tuples with one element.
...
Swift SVN r130
2010-08-01 07:02:05 +00:00
Chris Lattner
08fead5f63
rework func scope insertion so that recursion works, next up: vars.
...
Swift SVN r127
2010-08-01 05:07:59 +00:00
Chris Lattner
9b30ba0b2c
refactor function body parsing+sema a bit.
...
Swift SVN r126
2010-08-01 04:55:49 +00:00
Chris Lattner
ce30c19dab
Implement the rest of type inference for anondecls. They now work!
...
Swift SVN r125
2010-08-01 00:34:59 +00:00
Chris Lattner
0cfdb773b7
rearrange code, no functionality change.
...
Swift SVN r124
2010-07-31 23:39:54 +00:00
Chris Lattner
06b5f4dd5c
Finish factoring sema routines out of ast building logic.
...
Swift SVN r123
2010-07-31 23:33:32 +00:00
Chris Lattner
eae524427b
start refactoring to allow bottom-up type inference with re-sema. Still much to be done.
...
Swift SVN r122
2010-07-30 23:03:23 +00:00
Chris Lattner
422da5de1f
Give _0 a dependent type and use type inference to determine what it is based on context. Still some "bottom up" type inference logic missing, and we don't infer all the types in the expression tree of things like:
...
func6((_0 4) + _0);
yet.
Swift SVN r121
2010-07-30 22:04:44 +00:00
Chris Lattner
84c765dbc5
Start building out type propagation framework for inferring expression types in specified contexts. To do this, build a simple expr visitor class.
...
Swift SVN r119
2010-07-30 20:56:28 +00:00
Chris Lattner
483b8a242d
Enhance HandleConversionToType to take a conversion reason and to produce diagnostics itself instead of relying on clients to do it.
...
Swift SVN r118
2010-07-30 20:04:57 +00:00
Chris Lattner
b3c9942644
Rework handling of sequence expressions and juxtaposition to eagerly bind arguments to functions. This means that in situations like:
...
foo (_0) bar (_0)
that _0 will be bound properly and individually to foo and bar when they are functions, but if they aren't, then this is just one big 4-element sequence.
Swift SVN r115
2010-07-30 17:53:43 +00:00
Chris Lattner
ba04392294
Tighten up sema of anon closure arguments to reject invalid code like this:
...
func funcdecl6(a : int, b : int) -> (int,int) -> int = _0+_1;
var funcdecl7 : (int,int)->(int,int)->int = _0+_1;
It's not valid to bind anon closure arguments to functions, use named arguments instead.
Swift SVN r112
2010-07-28 06:51:12 +00:00
Chris Lattner
667078650a
Implement support for anonymous closure arguments. For example, we can now compile this:
...
var func6 : ((int,int) -> int) -> (); // Takes a function, returns nothing.
func funcdecl5() {
func6(_0 + _1); // Closure with two named anonymous arguments
}
into:
(apply_expr type='()'
(declref_expr type='(int, int) -> int -> ()' decl=func6)
(closure_expr type='(int, int) -> int'
(anondecl '_0' type='int')
(anondecl '_1' type='int')
(tuple_expr type='int'
(binary_expr '+' type='int'
(declref_expr type='int' decl=_0)
(declref_expr type='int' decl=_1))))))))
However, there are still some problems with this (and we're definitely not doing type inference yet, all anon args are assumed 'int').
Swift SVN r111
2010-07-28 06:25:16 +00:00
Chris Lattner
d022fc6df9
unbreak function prototypes
...
Swift SVN r109
2010-07-27 21:39:38 +00:00
Chris Lattner
9d33ef3616
add infrasturctuer for binding to "named anonymous" arguments.
...
Swift SVN r108
2010-07-27 21:37:29 +00:00
Chris Lattner
4c7ddf3e12
Enhance the auto-closure generating code to handle recursive cases, where multiple levels of application are required to get it. Eventually named arguments will be usable at each level, but not yet.
...
This allows us to sema:
var closure3 : (int,int)->int->(int,int) = (4, 2);
into:
(vardecl 'closure3' type='(int, int) -> int -> (int, int)'
(closure_expr type='(int, int) -> int -> (int, int)'
(closure_expr type='int -> (int, int)'
(tuple_expr type='(int, int)'
(integer_literal type='int' value=4)
(integer_literal type='int' value=2)))))
Swift SVN r107
2010-07-27 20:41:12 +00:00
Chris Lattner
20de997cb3
Implement type checking for func bodies now that autoclosurification is done.
...
Swift SVN r102
2010-07-27 06:32:03 +00:00
Chris Lattner
874421d4ce
Implement AST and Sema support for auto-closures. We now parse:
...
var closure1 : () -> int = 4; // Function producing 4 whenever it is called.
var closure2 : (int,int) -> int = 4; // Has some (dead) arguments.
into:
(vardecl 'closure1' type='() -> int'
(closure_expr type='() -> int'
(integer_literal type='int' value=4)))
(vardecl 'closure2' type='(int, int) -> int'
(closure_expr type='(int, int) -> int'
(integer_literal type='int' value=4)))
Swift SVN r101
2010-07-27 06:27:02 +00:00
Chris Lattner
35328c4921
testing whether rdar://8238427 is reproducible.
...
Swift SVN r99
2010-07-27 05:44:01 +00:00
Chris Lattner
514fe6cd22
test commit
...
Swift SVN r98
2010-07-27 05:43:27 +00:00
Chris Lattner
1afe647841
add basic sema support for funcdecl, not verifying types yet though.
...
Swift SVN r96
2010-07-27 05:38:12 +00:00
Chris Lattner
fef3e71b42
stub out parsing of func declarations.
...
Swift SVN r95
2010-07-27 05:32:16 +00:00
Chris Lattner
da8a6af90a
add a new expression to model sequences instead of hacking up braceexpr to do it.
...
Swift SVN r94
2010-07-25 23:22:29 +00:00
Chris Lattner
b1f00a1f70
Implement sema check for function application to verify that the argument matches the formal parameter type.
...
Swift SVN r93
2010-07-25 23:08:37 +00:00
Chris Lattner
a6b810b3e6
Enforce type rules in SemaExpr::ActOnBinaryExpr, validating that proper types are passed into the LHS/RHS of the operator.
...
Swift SVN r92
2010-07-25 23:04:03 +00:00
Chris Lattner
883efc284b
various cleanups to fixmes. Move a parsing check from sema to parser.
...
Swift SVN r91
2010-07-25 22:48:47 +00:00
Chris Lattner
7e0123c768
Kill off add/sub/mul/div as special AST nodes. Instead, + is just yet-another identifier token and BinaryExpr is a generalized infix call expression.
...
Swift SVN r88
2010-07-25 19:16:45 +00:00
Chris Lattner
6f98156fbe
Implement the 'expression results in unevaluated function' error, so something like this:
...
var func3 : () -> () -> (); // Takes nothing, returns a function.
..
func3();
Produces an error. This could be a candidate to turn into a warning.
Swift SVN r87
2010-07-25 06:24:55 +00:00
Chris Lattner
5562fc3cff
Actually form ApplyExprs. We're not checking that the actual argument matches the formal argument for a function yet, but we can parse some nice stuff like:
...
var func3 : () -> () -> (); // Takes nothing, returns a function.
var call4 = func3()();
into:
(vardecl 'call4' type='()'
(brace_expr type='()'
(apply_expr type='()'
(apply_expr type='() -> ()'
(declref_expr type='() -> () -> ()' decl=func3)
(tuple_expr type='()'))
(tuple_expr type='()'))))
Swift SVN r86
2010-07-25 05:57:53 +00:00
Chris Lattner
6c89184aee
rework sequence handling, we still build an incorrect AST: this time we build a BraceExpr to represent it.
...
Swift SVN r84
2010-07-25 05:27:15 +00:00
Chris Lattner
cd99eee0c6
Add parser support and stub out a SemaExpr callback for sequence exprs, the foundation of function calls.
...
Swift SVN r83
2010-07-24 22:07:23 +00:00
Chris Lattner
dee8d84185
implement semantic analysis checks for the infix attribute.
...
Swift SVN r82
2010-07-24 21:37:26 +00:00
Chris Lattner
9b42d1b273
enhance parenexpr to be tupleexpr. The grouping paren case is just a special case of a tuple literal with one child.
...
Swift SVN r81
2010-07-24 21:24:44 +00:00
Chris Lattner
94110869e0
add support for parsing attribute lists, and add the first attribute, infix=42. It is now parsed and slammed into the AST, but not used.
...
Swift SVN r79
2010-07-24 20:44:56 +00:00
Chris Lattner
2bafb0e8fb
Introduce new NamedDecl and FuncDecl classes. The difference between the two is syntactic sugar, so most clients want NamedDecl. This doesn't implement FuncDecl yet, which isn't a high prio for me in the short term.
...
Swift SVN r77
2010-07-24 19:09:09 +00:00
Chris Lattner
9a0d6c735a
change the handling of nullable so that hte parser actually checks for the error and only invokes sema if the inputs are valid, tidying up some code.
...
Swift SVN r76
2010-07-24 18:52:46 +00:00
Chris Lattner
d7ac94c9da
make use of the new nullable expression result by returning null from some sema errors.
...
Swift SVN r75
2010-07-24 18:49:47 +00:00
Chris Lattner
315107d5c6
Use the new NullablePtr<> class to allow better error recovery when parsing invalid expressions.
...
Swift SVN r74
2010-07-24 18:48:37 +00:00
Chris Lattner
1a74366195
implement semantic analysis support for binops, which amounts to enforcing that the LHS and RHS are both integer operations.
...
Swift SVN r73
2010-07-24 09:40:46 +00:00
Chris Lattner
05730aaef0
Properly treat tuples types with one element as grouping parens. Teach ActOnParenExpr to do the right type propagation.
...
Swift SVN r72
2010-07-24 09:34:38 +00:00
Chris Lattner
06faa365a7
Implement sema support for shadowed declarations.
...
Swift SVN r71
2010-07-24 06:46:48 +00:00