Commit Graph

186 Commits

Author SHA1 Message Date
Chris Lattner
c9ee19e269 Implement parser, sema, doc, and name lookup support for refined import declarations. You can still only do top level references, but that's because we don't have namespaces or anything else interesting yet.
This allows "import swift.int" for example. 

Swift SVN r329
2011-03-23 05:18:29 +00:00
Chris Lattner
a1cf13d201 Switch ActOnTupleType to take an ArrayRef, simplifying it.
Swift SVN r311
2011-03-22 04:54:13 +00:00
Chris Lattner
1fda8dd71d Fix a scoping problem with my recent "make oneof constructors have the right typealias name" patch.
Swift SVN r305
2011-03-21 22:56:00 +00:00
Chris Lattner
8f073c56d3 This went with the previous patch.
Swift SVN r299
2011-03-21 21:53:59 +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
6807ad7fb1 Move some type validity checking to SemaDecl::handleEndOfTranslationUnit, out of NameBinding.
Swift SVN r287
2011-03-19 06:41:26 +00:00
Chris Lattner
d23c2f26f3 Document and implement lexer and parser support for trivial import decls. No Sema/AST support yet.
Swift SVN r285
2011-03-18 22:52:48 +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
ca1b16b9df Cleanup SemaExpr::ActOnDotIdentifier.
Swift SVN r275
2011-03-17 04:31:55 +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
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
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
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
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
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
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
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
6f8dd4cf32 add parser support for array indexes
Swift SVN r209
2010-10-17 14:15:33 +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
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
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
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
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
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
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
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
807a82cd3d Resolve a fixme involving precedence of juxtaposition.
Swift SVN r140
2010-08-04 00:34:27 +00:00
Chris Lattner
04f7a08621 add support for tuple field access with ".", e.g.:
var a : (int, var f : int, int);
  var b = a.field0+a.field1+a.f;

This also eliminates TupleConvertExpr.

Swift SVN r137
2010-08-03 06:55:08 +00:00