Commit Graph

28382 Commits

Author SHA1 Message Date
Chris Lattner
29c2cd0ea2 Rearrange a bunch of type checking conversion code to be forceful and not tolerate failure. Get rid of "try this, then this, then this" sort of conversion checking.
Swift SVN r317
2011-03-22 06:28:51 +00:00
Chris Lattner
a93a1f640b Rearrange some cases, only try to-tuple conversion if a tupleexpr isn't a grouping paren.
Swift SVN r315
2011-03-22 05:42:30 +00:00
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
e51f356bd6 Improve comments.
Swift SVN r313
2011-03-22 05:13:37 +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
a1cf13d201 Switch ActOnTupleType to take an ArrayRef, simplifying it.
Swift SVN r311
2011-03-22 04:54:13 +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
e759c9c086 Fix bottom-up processing of tuple exprs in two ways:
1. Single-element tuples with names are not grouping parens.
2. Redo Sema of a tuple if we do propagate a type into it.

Also, remove the previous hack for trying to make:
  var e : ZeroOneTwoThree = :Three(1, 2, 3)

Unambiguous.  While it would be nice, it isn't essential and it clutters the model.


Swift SVN r308
2011-03-22 04:23:34 +00:00
Chris Lattner
094bbaae7d On second blush, this fix isn't a great one. Add a fixme and disable it for now so a test continues to fail.
Swift SVN r307
2011-03-21 23:15:56 +00:00
Chris Lattner
db44f883c9 Don't shave off "excess" elements of a body until the first element has a non-dependent type. Dependent types may resolve to functions and slicing of their bodies isn't a good idea.
Swift SVN r306
2011-03-21 23:00:20 +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
7406f8b201 Fix a case to look through typealiases where it should.
Swift SVN r304
2011-03-21 22:55:16 +00:00
Chris Lattner
bbac24c68e Improve struct declarations to use their TypeAlias for the constructor results. In the testcase we now get:
error: cannot convert initializer type 'CGPoint' to explicitly specified type 'int'
  var d : int = CGPoint(.y = 1, .x = 2);   // Using injected name.
                ^

instead of:
error: cannot convert initializer type 'oneof { CGPoint : (x : int, y : int)}' to explicitly specified type 'int'
  var d : int = CGPoint(.y = 1, .x = 2);   // Using injected name.
                ^


Swift SVN r298
2011-03-21 21:09:23 +00:00
Chris Lattner
024b479b76 Fix a crash on invalid: we can't produce null elements of brace exprs.
Swift SVN r297
2011-03-20 07:52:09 +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
a1e6e7bfc3 implement name binding support (including looking through imports) for types! We can now have a swift standard library.
Swift SVN r292
2011-03-20 05:26:50 +00:00
Chris Lattner
968339faf0 Integer literals should refer to the integer_literal_type type alias decl, not to unresolvedtype directly!
Swift SVN r291
2011-03-20 05:26:26 +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
097248057f Add a todo comment, use a note instead of warning in one case.
Swift SVN r289
2011-03-20 04:32:13 +00:00
Chris Lattner
204ffac987 Implement import for value names!
Swift SVN r288
2011-03-19 19:43:54 +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
60cdb19d02 Add a new ImportDecl to represent imports.
Swift SVN r286
2011-03-19 06:22:47 +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
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
4d5d33ddd4 Rework the argument binding logic to do the type application on the fly.
Swift SVN r281
2011-03-18 06:08:39 +00:00
Chris Lattner
78d6a6d5c6 Implement resolution and type assignment of Anonymous closure argument expressions
Swift SVN r280
2011-03-17 07:25:00 +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
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