Commit Graph

1958 Commits

Author SHA1 Message Date
John McCall
b2bd8e12a7 Introduce the idea of a DeclContext.
Swift SVN r623
2011-08-25 19:26:50 +00:00
Chris Lattner
b04c19e647 introduce a enw AST/AST.h umbrella header and use it to
simplify #includes.



Swift SVN r578
2011-08-22 21:02:44 +00:00
Chris Lattner
1dc200c973 introduce an official ErrorType. This is to be used when a type is incorrectly
constructed.  When put on a decl, this should cause all uses of the decl to 
collapse away into badness during type checking.


Swift SVN r514
2011-08-12 05:42:20 +00:00
Chris Lattner
10f5c2fc66 remove the UnresolvedType, representing it with a null Type() instead. There is no need to
have two different ways to represent the same thing.  This has the pleasant bonus that stuff
crashes when you do things with unresolved types.


Swift SVN r513
2011-08-12 05:19:52 +00:00
Chris Lattner
3a059605e7 convert TypeKind and WalkOrder to scoped enums
Swift SVN r441
2011-07-24 19:24:55 +00:00
Chris Lattner
096a3e16bc switch to range-based for loops where possible. I'm actually surprised how many
places are blocked by needing an index exposed for other purposes.  Not having a
MutableArrayRef doesn't help either.


Swift SVN r434
2011-07-23 20:47:13 +00:00
Chris Lattner
dc32e37ac5 enable c++'0x for the makefiles and adopt it in a trivial case.
Swift SVN r433
2011-07-23 20:15:04 +00:00
Chris Lattner
4f29cc0e8c convert TheUnresolvedType/TheDependentType and the empty tuple type
to be accessors on their respective classes, for consistency.


Swift SVN r429
2011-07-19 06:41:42 +00:00
Chris Lattner
c9ec409046 Context.getNewOneOfType -> OneOfType::getNew
Swift SVN r428
2011-07-19 06:28:36 +00:00
Chris Lattner
a39857ab85 migrate ASTContext::getTupleType -> TupleType::get
Swift SVN r427
2011-07-19 06:26:55 +00:00
Chris Lattner
649a577059 move from ASTContext::getArrayType -> ArrayType::get
Swift SVN r426
2011-07-19 06:22:04 +00:00
Chris Lattner
e106d336cb while I'm in a cleanup mood, move the factory functions from
types off of ASTContext onto the types themselves.  This 
never made sense for clang, and makes the same amount of sense
for swift.  Start with function types.


Swift SVN r425
2011-07-19 06:17:26 +00:00
Chris Lattner
10017bef15 ArrayRef and SmallVector[Impl]
Swift SVN r423
2011-07-19 06:03:26 +00:00
Chris Lattner
7275ca527a pull in StringRef and Twine.
Swift SVN r422
2011-07-19 06:00:20 +00:00
Chris Lattner
19dbcaa171 pull the casting operators into LLVM.h
Swift SVN r421
2011-07-19 05:57:01 +00:00
Chris Lattner
e647b29339 stop the llvm-namespace-qualification-insanity by caving in and
adding a new swift/AST/LLVM.h file which forward declares and imports
common llvm classes, starting with SMLoc.


Swift SVN r420
2011-07-19 05:49:43 +00:00
Chris Lattner
de094d7cde Introduce i1/i8/i16/i64 types, and switch int to be 64-bit.
Swift SVN r390
2011-05-31 03:48:36 +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
fd2bf74f06 Move getCanonicalType from being a method on ASTContext to being a method on Type.
Swift SVN r314
2011-03-22 05:23:51 +00:00
Chris Lattner
44ac12cb21 Remove some old code, add an assert to get an assert instead of null pointer deref on invalid call.
Swift SVN r268
2011-03-14 23:39:13 +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
40d4fedcb8 Make it invalid to call getCanonicalType before name binding is fully completed. This *will* cause assertion failures on valid code at this point because too much sema stuff happens at parse time.
Swift SVN r253
2011-03-02 08:02:44 +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
272d9e8dad Propagate "there were errors in the input" out to the exit code of the swift app by adding a "HadError" bool to ASTContext.
Swift SVN r244
2011-03-01 07:59:53 +00:00
Chris Lattner
dd2e2d8df3 Introduce UnresolvedType, make ASTContext have the singleton, update getCanonicalType to do the "right" thing.
Swift SVN r239
2011-02-26 02:33: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
50b3fcc3d1 Switch TupleType to hold its elements with an llvm::ArrayRef instead of manually doing it.
Swift SVN r235
2011-02-22 07:15:54 +00:00
Chris Lattner
f9673bb44a Remove the type symbol table from ASTContext, using the scoped hash table in SemaDecl instead. We resolve a bunch of fixmes (types now give a "previous definition here" diag), remove weird mutating state from ASTContext, and allow us to have shadowed types.
Swift SVN r234
2011-02-22 07:02:00 +00:00
Chris Lattner
2e26241a7a Fix AliasType to point to the TypeAliasDecl instead of replicating its contents.
Swift SVN r229
2011-02-22 06:11:48 +00:00
Chris Lattner
93eea9c8bc Simplify ASTContext's transforming of NamedTypeDecls into types. It now doesn't unique them, the decls do for themselves. ASTContext still has the type symbol table.
Swift SVN r228
2011-02-22 06:07:32 +00:00
Chris Lattner
818cd27748 Implement tuple to tuple conversions that involve default element values.
Swift SVN r221
2010-11-27 17:17:57 +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
6f7564235d Wire up sema support for creating array types.
Swift SVN r207
2010-10-17 13:12:47 +00:00
Chris Lattner
ff38a2db1b AST Support for arrays.
Swift SVN r206
2010-10-17 12:56:04 +00:00
Chris Lattner
09a023c3cd Now that we have simple user defined data types, remove the __builtin_else_hack type. woot.
Swift SVN r179
2010-10-09 22:06:13 +00:00
Chris Lattner
ac855b690b Move ActOnTypeAlias to SemaDecl since a type alias *is* a decl that *installs* a type. Add some fixme's and rename some junk in ASTContext relating to the typemap. Diagnose redefinitions of named types. Install a typemap entry when a data declaration is defined.
We can now declare variables to be of data type.

Swift SVN r178
2010-10-09 22:01:25 +00:00
Chris Lattner
9ba168ace5 Fix Alias uniquing to reuse the already-uniqued identifier object instead of being a string map. Make getAliasType fail if a redefinition happens and make getNamedType return datatype's as well.
Swift SVN r177
2010-10-09 21:30:56 +00:00
Chris Lattner
aefb083fed Make the DataType class, wire it into ASTContext.
Swift SVN r176
2010-10-09 21:11:27 +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
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
c1294622bf Cleanup type stuff.
Swift SVN r147
2010-08-04 06:35:54 +00:00
Chris Lattner
e1e335610f int is no longer a keyword, it is a type alias for the new __builtin_int32_type type.
Swift SVN r146
2010-08-04 05:27:45 +00:00
Chris Lattner
a8916a6106 implement semantic analysis and AST representation for AliasType (aka typedefs in C).
Swift SVN r144
2010-08-04 05:14:57 +00:00
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
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
9107a90d55 add support for representing dependent types.
Swift SVN r117
2010-07-30 18:18:28 +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
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
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
d6c8f0b621 make the AST representation of void just be ().
Swift SVN r53
2010-07-22 05:49:57 +00:00