Commit Graph

459 Commits

Author SHA1 Message Date
Chris Lattner
c3c602f9d3 Reimplement processing of dot expressions to have their base resolved as part of Type checking of SequenceExprs. This ensures that we can establish a proper base expression for the value.
Swift SVN r363
2011-04-11 05:20:21 +00:00
Chris Lattner
3b4a8b03d2 1. With overloading in play, SemaDecl should never resolve unqualified lookup that hits at translation unit scope to a DeclRefExpr. Doing so can break overloading.
2. This exposed a bug: when parsing structs, we weren't adding all decls to the translation unit, we were just adding the type alias.
3. This exposed that TypeChecking wasn't handling OneOfElementDecl.
4. Introduce a new NLKind enum in NameLookup instead of passing around a bool.
5. Have unqualified lookup that returns an overload set form a new OverloadSetRefExpr, which has dependent type.
6. Enhance various stuff to handle OverloadSetRefExpr.  It's still not fully handled yet though, so it can't be used for anything useful.
7. Change Expr.cpp to print types with << instead of T->print(OS) which is simpler and correct in the face of null.

Swift SVN r351
2011-04-10 05:57:10 +00:00
Chris Lattner
5e28a6fcdd Finally get around to doing a major type system refactoring, where we introduce Type as a "smart pointer" and rename the existing Type class to TypeBase.
This prevents use of isa/dyn_cast/etc on Type*'s and means we just pass around Type by value instead of having to use Type* everywhere.

Swift SVN r343
2011-04-05 01:06:57 +00:00
Chris Lattner
e85928e6f5 Split dollar identifier processing out to its own method.
Swift SVN r336
2011-03-26 23:57:43 +00:00
Chris Lattner
1fda8dd71d Fix a scoping problem with my recent "make oneof constructors have the right typealias name" patch.
Swift SVN r305
2011-03-21 22:56:00 +00:00
Chris Lattner
0d9da2b967 Improve diagnostics for oneof decls by making the constructors for the elements use the named type for the oneof decl instead of the underlying (unnamed) oneof type.
Swift SVN r302
2011-03-21 21:55:46 +00:00
Chris Lattner
c9eb885752 Introduce top-level expressions and simplify TranslationUnitDecl (and various things that hack on it) by making it hold a single BraceExpr instead of a list of exprs and decls.
Swift SVN r293
2011-03-20 06:59:37 +00:00
Chris Lattner
d23c2f26f3 Document and implement lexer and parser support for trivial import decls. No Sema/AST support yet.
Swift SVN r285
2011-03-18 22:52:48 +00:00
Chris Lattner
c5506dc66e Capture the structure of a declared VarName in the ast as DeclVarName.
Swift SVN r266
2011-03-14 21:54:21 +00:00
Chris Lattner
1eb17f15dd Stub out a namebinding pass, fix some crash-on-invalid cases in TypeChecking.
Swift SVN r263
2011-03-14 06:07:44 +00:00
Chris Lattner
db236941d0 Check in a massive rewrite of how sema works for expressions in an effort to make way for separate parsing, name binding, type checking phases.
Highlights of this include:
1) most of SemaExpr is gone now, when parsing, all expressions are assigned null types.
2) the introduction of a new TypeChecking pass, which assigns types to expressions, and checks their constraints.
3) ElementRefDecl now properly stores an access path for what it is accessing, and ElementRefDecl's get added to the AST.
4) The parser is much much simpler for expressions now, it just collects lists of primary exprs into SequenceExprs unconditionally.
5) This means that formation of binary expressions, function application etc is now done by TypeChecking.  This is actually simpler, though admittedly surprising.
6) This introduces a new -parse-dump mode which just parses but does not perform name binding or type checking.

I've been working on this for a while and it is still quite broken: it still doesn't handle anondecls at all, doesn't perform conversion checking for default tuple elements, has missing pieces of varname name binding etc.  However, there is no reason to not crash land it now, it's not like I'm going to break anyone else.

Swift SVN r262
2011-03-13 21:52:03 +00:00
Chris Lattner
b3e5c55fbc Change the parser methods to lower case to follow naming conventions.
Swift SVN r256
2011-03-06 23:28:17 +00:00
Chris Lattner
ddb760bf2b Remove the concept of an ASTConsumer, add a new TranslationUnitDecl.
Swift SVN r255
2011-03-04 22:08:34 +00:00
Chris Lattner
291967ceb0 Make ParseIdentifier do the string->identifier conversion, simplifying clients. no functionality change.
Swift SVN r250
2011-03-02 06:55:35 +00:00
Chris Lattner
b233848006 Tidy up and clean up code and error recovery in the parser. Add some templated allocation functions to ASTContext to simplify clients.
Swift SVN r248
2011-03-02 06:15:52 +00:00
Chris Lattner
80e1ae6104 Rework a bunch of stuff in the type system: now the *only* way to name a type is through a 'typealias' and there is no such thing as a OneOfDecl. Instead, we have OneOfType's, which are always anonymous. "oneof declarations" and "struct declarations" are now both just sugar.
This eliminates the NamedTypeDecl class (because there is now only one named type decl), eliminates OneOfDecl, renames AliasTypeDecl to NameAliasTypeDecl for good measure, and introduces OneOfType.

This preserves all existing syntax, and allows stuff like this:

func test6(checkboxenabled : oneof { Yep, Nope }) {
  test6(:Yep)
}

Which is an anonymous oneof.

Swift SVN r237
2011-02-26 02:03:01 +00:00
Chris Lattner
cb9b1838a6 Introduce and create a new TypeAliasDecl for typealiases.
Swift SVN r227
2011-02-22 05:47:08 +00:00
Chris Lattner
f6d7adc4cb Parse tuple element types as value-specifier's, allowing them to have initializers. Sema isn't wired up yet though.
Swift SVN r218
2010-11-25 20:49:01 +00:00
Chris Lattner
bc616e9fcd Split the initializer syntax from var decls out to their own 'value-specifier' production
Swift SVN r217
2010-11-25 17:00:34 +00:00
Chris Lattner
906ba908fd Rename 'data' to 'oneof', resolving a fixme in the spec. Yay for CLU!
Swift SVN r212
2010-11-11 01:20:36 +00:00
Chris Lattner
154c0c6eb9 Resolve a fixme by eliminating the ; in func decls and making the grammar more restrictive.
Swift SVN r203
2010-10-15 11:07:49 +00:00
Chris Lattner
b9fbd77f58 Fix a bunch of minor bugs found through inspection:
1. Punctuation identifiers were missing some characters.
2. Some parser production and methods were misnamed.
3. Top level var decls don't need a ; after them.
4. Various parser comments were out of date.
5. We now allow any type in a struct decl, e.g. "struct foo int", even though it's weird.

Swift SVN r199
2010-10-12 07:24:33 +00:00
Chris Lattner
26e63c29ac rip out a bunch of special case parsing logic for function arguments now that tuples have a sane syntax.
Swift SVN r197
2010-10-11 21:05:07 +00:00
Chris Lattner
f92a3d56d7 Implement parser support for structs, improve datadecl dumping.
Swift SVN r192
2010-10-10 06:38:24 +00:00
Chris Lattner
43f2d1dfa5 wire up parser and basic sema support for scoped identifier expressions (X::Y).
Swift SVN r180
2010-10-09 23:01:17 +00:00
Chris Lattner
a43a8f27f5 Wire data decls up to -ast-dump. Fix some minor bugs exposed along the way.
Swift SVN r175
2010-10-09 20:46:10 +00:00
Chris Lattner
57c697172a Split NamedDecl into NamedDecl with a ValueDecl subclass that has the type and value of the decl.
Swift SVN r173
2010-10-09 20:28:11 +00:00
Chris Lattner
ecdc8da738 add parser support for type specifiers in data descriptors.
Swift SVN r171
2010-10-09 18:58:18 +00:00
Chris Lattner
17c36aa749 add parser support for simple data declarations
Swift SVN r170
2010-10-09 18:42:54 +00:00
Chris Lattner
19e5390b78 twinify more diagnostics.
Swift SVN r168
2010-10-09 17:50:40 +00:00
Chris Lattner
d2abfde434 introduce a new builtin type to represent the result of the else binary operator (which is a temporary hack until we get user defined types).
Use it to define ife/else.  Fix some precedence/parsing bugs that implementing else exposed. 

Swift SVN r162
2010-08-08 22:37:56 +00:00
Chris Lattner
45610c0ecc rework func argument parsing to be more consistent across ->'s.
Swift SVN r161
2010-08-08 21:36:26 +00:00
Chris Lattner
025143611f implement support for tuple expressions with names specified for the elements.
Swift SVN r157
2010-08-07 06:51:12 +00:00
Chris Lattner
bf63029ecd rework tuple element parsing to not use ParseDeclVar, since tuple elements are fundamentally different. While we're at it, switch to an arguably more natural syntax for field elements, naming them with .x : type instead of var x : type
Swift SVN r150
2010-08-05 05:03:55 +00:00
Chris Lattner
34a1beac31 inline ParseTypeOrDeclVar and ParseExprOrDeclVar into their single callers and simplify the code around them.
Swift SVN r149
2010-08-05 04:42:13 +00:00
Chris Lattner
43a526f1f5 a step towards parsing richer names. I need to do some refactoring of var parsing before going further.
Swift SVN r148
2010-08-05 04:28:32 +00:00
Chris Lattner
8f86874c19 add parser support for typealiases, we have to be able to exercise the canonical type system somehow.
Swift SVN r143
2010-08-04 04:42:13 +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
fef3e71b42 stub out parsing of func declarations.
Swift SVN r95
2010-07-27 05:32:16 +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
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
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
1103ff5227 Implement basic parser support for brace expressions.
Swift SVN r69
2010-07-23 18:33:49 +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
669c129ab0 introduce new ASTConsumer interface, have parser invoke methods
on it.


Swift SVN r41
2010-07-19 05:50:41 +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
9e8489a042 make the parser build type asts.
Swift SVN r34
2010-07-19 04:37:51 +00:00