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
9107a90d55
add support for representing dependent types.
...
Swift SVN r117
2010-07-30 18:18:28 +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
9d33ef3616
add infrasturctuer for binding to "named anonymous" arguments.
...
Swift SVN r108
2010-07-27 21:37:29 +00:00
Chris Lattner
ce55229f0f
Allow arbitrary expressions as the body of a function, don't require brace-expr.
...
Swift SVN r103
2010-07-27 06:36:04 +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
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
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
fa78da101b
implement lazy construction of canonical types, ala clang. This only affect tuples at the moment, but will affect type aliases someday.
...
Swift SVN r90
2010-07-25 22:41:05 +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
12fa92e146
Add a new ApplyExpr expression AST node for function application.
...
Swift SVN r85
2010-07-25 05:37:45 +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
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
4a2ea23b23
Enhance the parser to parse infix decls. The AST it constructs is still not correct though. We have no way to represent function calls yet!
...
Swift SVN r80
2010-07-24 20:59:00 +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
769c4a034a
fix a bug in my refactoring.
...
Swift SVN r78
2010-07-24 20:13:26 +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
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
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
Chris Lattner
64ecbb8a9c
Implement AST and trivial Sema support for brace expressions.
...
Swift SVN r70
2010-07-23 19:39:51 +00:00
Chris Lattner
1103ff5227
Implement basic parser support for brace expressions.
...
Swift SVN r69
2010-07-23 18:33:49 +00:00
Chris Lattner
58185415a1
now that we have name lookup, we can implement references to
...
other values. crazzay.
Swift SVN r67
2010-07-23 05:48:20 +00:00
Chris Lattner
82ea1aefd6
eliminate unneeded complexity.
...
Swift SVN r66
2010-07-23 04:38:44 +00:00
Chris Lattner
f248ffb53a
Introduce a scope abstraction, the next step to implementing
...
name lookup.
Swift SVN r65
2010-07-23 04:37:16 +00:00
Chris Lattner
7ff4cc6e21
split the decl processing stuff in Sema out into a new
...
SemaDecl class where it belongs. Tidy up headers a bit.
Swift SVN r64
2010-07-23 04:13:53 +00:00
Chris Lattner
ed1be4f17a
add printing support for Identifier, switch VarDecl to have an
...
identifier instead of a stringref.
Swift SVN r63
2010-07-23 03:50:09 +00:00
Chris Lattner
8bf327b648
add a new AST/Identifier class which represents a uniqued string.
...
Add support to ASTContext to unique strings into identifiers.
Swift SVN r62
2010-07-23 03:40:02 +00:00
Chris Lattner
d8c6da6a3c
tweak comments. void is no longer in the AST, but it shouldn't even
...
be a keyword
Swift SVN r61
2010-07-22 06:51:03 +00:00
Chris Lattner
a860fe44db
implement support for printing types, add them to -ast-dump
...
Swift SVN r58
2010-07-22 06:33:03 +00:00
Chris Lattner
34602d5d22
Make Expr::Kind public.
...
Swift SVN r57
2010-07-22 06:10:31 +00:00
Chris Lattner
92354781f9
implement support for isa/dyncast of types.
...
Swift SVN r56
2010-07-22 06:06:40 +00:00
Chris Lattner
7f9b3612aa
follow the predominant pattern of making const ivars const and
...
public instead of private with accessors.
Swift SVN r55
2010-07-22 06:03:20 +00:00
Chris Lattner
ac1200cda5
rename Token::getLocation() to Token::getLoc()
...
Swift SVN r54
2010-07-22 05:55:04 +00:00
Chris Lattner
d6c8f0b621
make the AST representation of void just be ().
...
Swift SVN r53
2010-07-22 05:49:57 +00:00
Chris Lattner
fba7359c9c
eliminate a #include from ASTContext.h
...
Swift SVN r52
2010-07-22 05:47:33 +00:00
Chris Lattner
842821d541
add FunctionType, have sema create it and have ASTContext
...
unique it.
Swift SVN r51
2010-07-22 05:44:17 +00:00
Chris Lattner
49b3c52843
implement parser support for function types.
...
Swift SVN r50
2010-07-22 02:11:49 +00:00
Chris Lattner
c363b58ea1
Introduce TupleType, an AST representation of tuples.
...
Swift SVN r49
2010-07-22 01:58:01 +00:00
Chris Lattner
b1d25371e3
type things as VarDecl instead of as Decl, return things by value from
...
void parse methods.
Swift SVN r48
2010-07-22 00:47:53 +00:00
Chris Lattner
aa126e87f9
add a new SemaType module, add parser support for tuples.
...
Add lexer support for ->. Expand the testcase.
Swift SVN r47
2010-07-21 07:17:43 +00:00
Chris Lattner
f7c8e53359
implement isa/dyncast and dumping support for exprs.
...
We can now parse and print this:
var x3 = 4+5*4+12/97;
into:
(vardecl 'x3'
(binary_expr
(binary_expr
(integer_literal 4)
(binary_expr
(integer_literal 5)
(integer_literal 4)))
(binary_expr
(integer_literal 12)
(integer_literal 97))))
Swift SVN r46
2010-07-19 06:52:08 +00:00
Chris Lattner
547b2a8003
implement vardecl dumping and Casting.h support for decls.
...
Swift SVN r45
2010-07-19 06:39:56 +00:00
Chris Lattner
cea9a29739
fix some include guards and an uninitialized member
...
Swift SVN r43
2010-07-19 06:11:19 +00:00