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
07b8860f71
Implement name binding for forward referenced values, and diagnose references to undefined decls. This properly implements the rest of name-binding! Since we don't have import statements yet, we don't have to worry about types. SemaDecl still does all the heavy lifting for them.
...
Swift SVN r276
2011-03-17 05:02:50 +00:00
Chris Lattner
ca1b16b9df
Cleanup SemaExpr::ActOnDotIdentifier.
...
Swift SVN r275
2011-03-17 04:31:55 +00:00
Chris Lattner
7759b4b211
Diagnose invalid name binding, such as:
...
var callee1 : () -> (:int,:int,:int);
...
var (m, n) = callee1()
which now produces:
error: name specifier matches '(int, int, int)' which requires 3 names, but has 2
Swift SVN r274
2011-03-17 04:29:02 +00:00
Chris Lattner
bcc4f47332
Fix previous patch.
...
Swift SVN r271
2011-03-15 00:22:10 +00:00
Chris Lattner
25c1d7be9b
Fix some issues handling rewalks of the same expression when something was found to be invalid.
...
Swift SVN r270
2011-03-15 00:15:49 +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
d6d92deeb7
Wire DiagnoseUnresolvedType back up and clean up handling of vardecls. This now causes us to explode on tuples with default values so temporarily remove the tests. This also causes us to reject more anondecl tests since those aren't (re)implemented yet.
...
Swift SVN r267
2011-03-14 22:16:50 +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
b15573e907
Implement type checking of ElementRefDecl's in SemaExpressionTree, diagnosing an invalid case and propagating types further.
...
Swift SVN r265
2011-03-14 06:30:04 +00:00
Chris Lattner
770b9cbb87
Fix tests so that top level variables have types, even if they have initializers.
...
Swift SVN r264
2011-03-14 06:19:28 +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
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
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
abb710acaa
Minor code tidying + comments, add some expected error tests.
...
Swift SVN r252
2011-03-02 07:59:48 +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
61d62179ee
Improve consistency by pushing Identifiers into Sema instead of StringRefs.
...
Swift SVN r249
2011-03-02 06:50:13 +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
553e276139
Wire up support for completing types that are used but not yet defined!
...
Swift SVN r241
2011-03-01 07:25:51 +00:00
Chris Lattner
ffef30f2c3
Change name lookup of types to always succeed: if a type is used before it is defined, just cons up a new TypeAliasDecl for the unresolved type and return it. Diagnose these at the end of the translation unit instead of at their first use.
...
Swift SVN r240
2011-02-27 20:49:29 +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
5a74864a71
Add a scoped hash table for type names to SemaDecl, make Scope push it along with the value scoped hash table.
...
Nothing is added to the type symtab yet though.
Swift SVN r232
2011-02-22 06:45:30 +00:00
Chris Lattner
6a1416b3b8
Revert my last patch. Instead of having a TypeScope and ValueScope, we'll just make Scope do both!
...
Swift SVN r231
2011-02-22 06:36:52 +00:00
Chris Lattner
e6f00fe1cc
Rename the Scope class to ValueScope
...
Swift SVN r230
2011-02-22 06:30:18 +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
1a97122ba0
Update to build with mainline LLVM.
...
Swift SVN r225
2011-02-04 06:24:41 +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
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
28789d43d2
Resolve a fixme: use foo.$1 instead of foo.field1
...
Swift SVN r216
2010-11-11 23:04:29 +00:00
Chris Lattner
3bd8a85784
Fix weirdness in the lang spec by making $123 be a special type of implementation identifier token, handling it uniformly in the grammar in the few places that it is valid.
...
Swift SVN r215
2010-11-11 22:27:39 +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
2f0d96885a
Move field exprs to their own section in langref. Document subscript exprs. Still no sema support.
...
Swift SVN r210
2010-10-18 06:34:46 +00:00
Chris Lattner
6f8dd4cf32
add parser support for array indexes
...
Swift SVN r209
2010-10-17 14:15:33 +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
fd54c7f5a0
add parser support for array types, no sema or ast yet.
...
Swift SVN r205
2010-10-15 11:54:34 +00:00
Chris Lattner
7d86d0b680
Wire up sema support for field access of single element data declarations. This allows Foo.X to work with structs.
...
Swift SVN r195
2010-10-10 07:05:05 +00:00
Chris Lattner
ba39ed014c
add another example, fix a sema bug found by inspection.
...
Swift SVN r194
2010-10-10 06:47:34 +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
55f104be1d
Handle context sensitive type inference of function-like data constructors.
...
Swift SVN r189
2010-10-10 05:48:12 +00:00