Commit Graph

7976 Commits

Author SHA1 Message Date
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
Chris Lattner
7897dde07f Substantially refactor tuple type inference so that the code works for both the bottom-up and the top-down cases. Also make it rewrite tuple exprs in place where it can (which is required by the new code).
Swift SVN r188
2010-10-10 05:22:54 +00:00
Chris Lattner
4537b3a25d refactor code into a visitor, no functionality change.
Swift SVN r187
2010-10-10 02:47:18 +00:00
Chris Lattner
a7f3e05b62 Hook up enough sema support to get things like this working:
func test3(a : MaybeInt) {
  test3(:None);
}


Swift SVN r186
2010-10-10 02:28:53 +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
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
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
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
3ea5878390 add scafolding for sema of datas.
Swift SVN r172
2010-10-09 19:33:50 +00:00
Chris Lattner
19e5390b78 twinify more diagnostics.
Swift SVN r168
2010-10-09 17:50:40 +00:00
Chris Lattner
51b9de2931 update to build with llvm mainline (twinification of SourceMgr)
Swift SVN r167
2010-10-09 17:44:21 +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
1bef5bd648 Bertrand prefers $0 to _1 for anonymous closure arguments.
Swift SVN r165
2010-09-18 16:57:10 +00:00
Chris Lattner
29503975d2 Enhance juxtaposition binding handling to handle binary operators and functions in a more fine-grained way, allowing if/else to work without braces.
Swift SVN r163
2010-09-04 19:25:56 +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
b927b55863 Finally get around to allowing *use* of a named incoming function argument. The first step is to set up a scope for them and walk the argument names, keeping track of access path info.
Swift SVN r158
2010-08-07 20:10:19 +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
4fe0a17457 Fix a problem where we didn't bind anondecls early enough which prevented them from getting their types when in nested closures. For example,
var test : int->int->int = _0;

now sema's to:

(vardecl 'test' type='int -> int -> int'
 (closure_expr type='int -> int -> int'
   (anondecl '_0' type='int')
   (closure_expr type='int -> int'
     (declref_expr type='int' decl=_0))))


Swift SVN r155
2010-08-05 23:14:57 +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
Chris Lattner
429ecb81da Finish ast and sema support for name binding elements of tuples in var decls.
Swift SVN r152
2010-08-05 22:22:22 +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