Commit Graph

28850 Commits

Author SHA1 Message Date
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
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
5c28366864 diagnose invalid code like 'var x : void = 4;'
Swift SVN r60
2010-07-22 06:37:39 +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
2264640f12 fix a fixme by sinking some sema into sema.
Swift SVN r40
2010-07-19 05:15:29 +00:00
Chris Lattner
2eeee5faca give ASTContext a SourceMgr reference, add diagnostic hooks to SemaBase.
Swift SVN r39
2010-07-19 05:13:55 +00:00
Chris Lattner
c5e54442b4 make the parser actually create VarDecl AST nodes.
Swift SVN r38
2010-07-19 05:08:21 +00:00
Chris Lattner
9eb6733531 Exprs have types.
Swift SVN r36
2010-07-19 04:42:58 +00:00
Chris Lattner
a63671f116 add binary expression ast node.
Swift SVN r31
2010-07-19 00:57:54 +00:00
Chris Lattner
17aad28720 set up expression kinds, add ParenExpr ast node.
Swift SVN r30
2010-07-19 00:51:28 +00:00
Chris Lattner
a39a7ec6a2 make the sema methods be prefixed with ActOn
Swift SVN r29
2010-07-19 00:46:09 +00:00
Chris Lattner
66199fa090 implement a new IntegerLiteral ast node, add plumbing for
allocation of exprs from ASTContext.


Swift SVN r28
2010-07-19 00:42:30 +00:00
Chris Lattner
d6edeb7a8b thread Expr* results through the parser and SemaExpr.
Swift SVN r27
2010-07-19 00:15:02 +00:00
Chris Lattner
910f84b6ae thread astcontext from the driver, down through Sema.
Swift SVN r26
2010-07-19 00:07:47 +00:00
Chris Lattner
b45fe8abf5 set up semaexpr and sema base. Give SemaExpr a couple trivial methods.
Swift SVN r24
2010-07-18 23:54:47 +00:00
Chris Lattner
8b9b84fe8e forgot to svn add this.
Swift SVN r23
2010-07-18 23:40:44 +00:00
Chris Lattner
68a2d3a33c stub out the Sema object.
Swift SVN r21
2010-07-18 22:59:13 +00:00