Chris Lattner
6950fa6a2c
Improve expr dumping to not crash on null exprs, print the Arg# for anonexprs.
...
Swift SVN r300
2011-03-21 21:54:34 +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
60cdb19d02
Add a new ImportDecl to represent imports.
...
Swift SVN r286
2011-03-19 06:22:47 +00:00
Chris Lattner
5e44da89af
Change how integer literals get types. Instead of having TypeChecker force them to __builtin_int32_ty, have sema give them integer_literal_type, and expect the library to define what that actually is for a given file.
...
Swift SVN r282
2011-03-18 06:28:38 +00:00
Chris Lattner
3a57e3f661
Reimplement the SemaExpressionTree expression walking logic in terms of Expr->WalkExpr, which already has it. Enhance WalkExpr to allow skipping visitation of subtrees. No functionality change.
...
Swift SVN r279
2011-03-17 06:39:02 +00:00
Chris Lattner
6ab4eec127
Two changes that got mixed up:
...
#1 : Change type conversion errors to print the types involved, making the diagnostic better. We still don't have ranges, but it is progress.
#2 : Reimplement support for anonymous closure arguments (e.g. func($0+$1)) where func takes a closure, step #1 .
- This removes AnonDecl, replacing it with AnonClosureArgExpr. $0 and friends have to be expressions since they don't get a type and don't get resolved until TypeChecking.
- For now we just replace the existing broken support, a future step is to implement type checking support for them.
Swift SVN r278
2011-03-17 06:09:19 +00:00
Chris Lattner
1bd1f1b73d
Implement type checking support for validating tuple types with default values.
...
Swift SVN r269
2011-03-14 23:40:05 +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
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
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
7c774d3ec6
Add a Type::getString() method for diagnostics.
...
Swift SVN r261
2011-03-13 21:28:16 +00:00
Chris Lattner
f0219a37b7
Fix a comment in type.h, allow printing of null types, fix oneof printing.
...
Swift SVN r259
2011-03-13 20:45:45 +00:00
Chris Lattner
71eb272b4a
Build AST nodes for references to unresolved names. These can be resolved after parse time.
...
Swift SVN r258
2011-03-07 00:12:38 +00:00
Chris Lattner
6d98e3f03e
Fix some missing \n's
...
Swift SVN r257
2011-03-07 00:12:04 +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
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
7bbe52b52a
Expand the swift language to allow typealiases, oneof, and struct within a brace expression. This allows us to have shadowing of type names.
...
Swift SVN r236
2011-02-22 07:41:44 +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
cb9b1838a6
Introduce and create a new TypeAliasDecl for typealiases.
...
Swift SVN r227
2011-02-22 05:47:08 +00:00
Chris Lattner
ad4389edc8
Introduce a new TypeAliasDecl class and NamedTypeDecl parent class. We're not creating it yet, but hey it's there.
...
Swift SVN r226
2011-02-22 05:37:01 +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
e488b69182
Implement sema support for TupleExprs with default elements (represented with null), implement support for conversions from scalar to tuples with multiple default elements.
...
Swift SVN r220
2010-11-25 23:02:23 +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
f92a3d56d7
Implement parser support for structs, improve datadecl dumping.
...
Swift SVN r192
2010-10-10 06:38:24 +00:00
Chris Lattner
bffee378d2
Generalize the expression walker to allow rewrites to be implemented.
...
Swift SVN r191
2010-10-10 06:19:16 +00:00
Chris Lattner
a885cd5dc5
Diagnose completely unresolved expressions with an error like this:
...
data.swift:114:10: error: ambiguous expression could not resolve a concrete type
var xx = :Zero;
^
Do this with a very general pre/post-order walking function.
Swift SVN r190
2010-10-10 06:11:47 +00:00
Chris Lattner
272cbcaba3
Implement parser, ast and minimal sema support for :foo expressions, type resolution isn't done yet.
...
Swift SVN r185
2010-10-10 00:15:46 +00:00
Chris Lattner
47e034fb0e
Fix element values to have a proper function type when they take an argument. Now this:
...
data MaybeInt {
None,
Some int
}
var c = MaybeInt::Some 4;
var d = MaybeInt::Some;
-ast-dump's into:
(vardecl 'c' type='MaybeInt'
(apply_expr type='MaybeInt'
(declref_expr type='int -> MaybeInt' decl=Some)
(integer_literal type='__builtin_int32_type' value=4)))
(vardecl 'd' type='int -> MaybeInt'
(declref_expr type='int -> MaybeInt' decl=Some))
Swift SVN r183
2010-10-09 23:51:38 +00:00
Chris Lattner
ad438c55e3
Implement the rest of sema for scoped identifier references (X::Y) we now get a proper DeclRefExpr, and this:
...
var def = DataSearchFlags::None;
-ast-dump's into:
(vardecl 'def' type='DataSearchFlags'
(declref_expr type='DataSearchFlags' decl=None))
Swift SVN r182
2010-10-09 23:46:16 +00:00
Chris Lattner
10e3eacc83
Create a DataElementDecl to represent the elements of a data, and wire up sema support for creating them when the data is defined.
...
Swift SVN r181
2010-10-09 23:24:56 +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
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
0ad8498114
declare DeclData and create it in sema.
...
Swift SVN r174
2010-10-09 20:40:19 +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
91f5abd1e9
Implement parser support for assignment, what a hack :-)
...
Swift SVN r166
2010-09-18 17:26:01 +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
d5f834512e
Next step to allow use of named arguments: Create a new ArgDecl AST node, and have SemaDecl form them. We now correctly diagnose argument name redefinitions (though the diagnostic sucks because we don't have loc info)
...
Swift SVN r159
2010-08-07 20:25:05 +00:00
Chris Lattner
5afc6bdbd0
Add Type::getAs<> and support for minimally desugaring types. Start preserving more type sugar in the type conversion code.
...
Swift SVN r154
2010-08-05 23:05:54 +00:00