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
aeb7c0895e
The isGroupingParen() predicate doesn't make sense since TupleExpr can be used to create tuple expressions out of a scalar when there is a single element involved. In this case, isGroupingParen would return true but the source and dest types would be different.
...
This didn't manifest as a bug yet, but it doesn't make sense to wait until it does. This aspect of grouping parens is a syntactic issue, so make the creator of TupleExpr specify whether the expr is a grouping paren or not and persist this.
Swift SVN r312
2011-03-22 05:04:48 +00:00
Chris Lattner
ae2f026d3f
Use isGroupingParen() in one more place, add a TupleExpr::getElementName helper method.
...
Swift SVN r310
2011-03-22 04:49:47 +00:00
Chris Lattner
20772e3b8e
Add a TupleExpr::isGroupingParen() method and use it in a few places.
...
Swift SVN r309
2011-03-22 04:33:46 +00:00
Chris Lattner
ffb93e65b7
Fix a pretty big issue in typechecking. We were processing things like:
...
func f() {
var x = 4
f()
}
as:
var x = (4 f())
not:
var x = 4; f()
Swift SVN r295
2011-03-20 07:37:43 +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
cb8884e832
Move error reporting for unresolved types from SemaDecl to NameBinding, where it should be. This requires enhancing TranslationUnitDecl to hold a list of unresolved types.
...
Swift SVN r290
2011-03-20 04:45:06 +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
1cc8befa30
Fix a scary and long standing bug which never manifested because vars and funcs had the same data.
...
Swift SVN r273
2011-03-17 04:27:41 +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
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
7c774d3ec6
Add a Type::getString() method for diagnostics.
...
Swift SVN r261
2011-03-13 21:28:16 +00:00
Chris Lattner
3f0af37333
Allow allocating a type of any ArrayRef from ASTContext.
...
Swift SVN r260
2011-03-13 20:46:50 +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
ddb760bf2b
Remove the concept of an ASTConsumer, add a new TranslationUnitDecl.
...
Swift SVN r255
2011-03-04 22:08:34 +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
a37e52624e
Improve error message to list the type name.
...
Swift SVN r246
2011-03-01 08:48:11 +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
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
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
8234b6fd66
Add some sema for tuple elements which are specified with a default value. Still not used for conversions yet.
...
Swift SVN r219
2010-11-25 21:18:48 +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
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
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
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
1bef5bd648
Bertrand prefers $0 to _1 for anonymous closure arguments.
...
Swift SVN r165
2010-09-18 16:57:10 +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