Chris Lattner
b9e7823656
Implement lexing and parsing support for a proper if expression. There
...
is no AST building or typechecking support yet. Document the intended
semantics in LangRef. This is clearly subject to change, but is a starting
point.
Swift SVN r393
2011-06-05 02:03:48 +00:00
Chris Lattner
de094d7cde
Introduce i1/i8/i16/i64 types, and switch int to be 64-bit.
...
Swift SVN r390
2011-05-31 03:48:36 +00:00
Chris Lattner
79ba41c1fe
add a specialization of AllocateCopy to help out argument deduction a bit,
...
simplifying some code.
Swift SVN r385
2011-04-29 07:18:11 +00:00
Chris Lattner
56b3a5e6ab
introduce a new TupleShuffleExpr expression kind, which will be used to eliminate the ASDAG.
...
Swift SVN r384
2011-04-29 07:10:32 +00:00
Chris Lattner
6720390c84
Implement a first, very simple cut at ranking conversions for overload sets. This is important because we previously required exact type matching for overload resolution, and (int) != (.x : int) so no arguments with names would match up with anonymous values.
...
We still don't use ranking for binary operators etc.
Swift SVN r379
2011-04-29 00:14:20 +00:00
Chris Lattner
687bb2c8ce
Move the getTupleFieldForScalarInit helper function out of TypeChecking.cpp into TupleType::getFieldForScalarInit.
...
Simplify the code handling conversion of grouping parens, and other minor cleanups. No functionality change.
Swift SVN r378
2011-04-28 23:10:55 +00:00
Chris Lattner
d3d1278c7e
John points out that struct foo { ... } is more consistent with oneof and generally makes more sense than struct foo (...). Switch!
...
Swift SVN r372
2011-04-22 06:12:21 +00:00
Chris Lattner
91fb8351b7
Implement support for overloaded binary operators.
...
Swift SVN r366
2011-04-11 05:59:23 +00:00
Chris Lattner
c3c602f9d3
Reimplement processing of dot expressions to have their base resolved as part of Type checking of SequenceExprs. This ensures that we can establish a proper base expression for the value.
...
Swift SVN r363
2011-04-11 05:20:21 +00:00
Chris Lattner
a6ccf69bc6
Implement support for overloading in .-style name lookup. This is not super useful yet because we don't have conversion ranking, but it's progress.
...
Swift SVN r356
2011-04-10 16:48:31 +00:00
Chris Lattner
da28ba8072
Completely disable equality comparisons of Type.
...
Swift SVN r355
2011-04-10 06:30:57 +00:00
Chris Lattner
936f3654c9
Implement equality testing (ignoring sugar) for types.
...
Implement simple context sensitive type inference for overload sets.
Swift SVN r352
2011-04-10 06:06:53 +00:00
Chris Lattner
3b4a8b03d2
1. With overloading in play, SemaDecl should never resolve unqualified lookup that hits at translation unit scope to a DeclRefExpr. Doing so can break overloading.
...
2. This exposed a bug: when parsing structs, we weren't adding all decls to the translation unit, we were just adding the type alias.
3. This exposed that TypeChecking wasn't handling OneOfElementDecl.
4. Introduce a new NLKind enum in NameLookup instead of passing around a bool.
5. Have unqualified lookup that returns an overload set form a new OverloadSetRefExpr, which has dependent type.
6. Enhance various stuff to handle OverloadSetRefExpr. It's still not fully handled yet though, so it can't be used for anything useful.
7. Change Expr.cpp to print types with << instead of T->print(OS) which is simpler and correct in the face of null.
Swift SVN r351
2011-04-10 05:57:10 +00:00
Chris Lattner
e071e0f159
add a helper, tweak a comment.
...
Swift SVN r347
2011-04-10 03:07:32 +00:00
Chris Lattner
ea53191985
properly initialize an ivar.
...
Swift SVN r346
2011-04-09 21:16:41 +00:00
Chris Lattner
55f553305e
Disallow comparison of Type's. You can still compare type pointers if you know what you're doing.
...
Swift SVN r344
2011-04-05 01:12:20 +00:00
Chris Lattner
5e28a6fcdd
Finally get around to doing a major type system refactoring, where we introduce Type as a "smart pointer" and rename the existing Type class to TypeBase.
...
This prevents use of isa/dyn_cast/etc on Type*'s and means we just pass around Type by value instead of having to use Type* everywhere.
Swift SVN r343
2011-04-05 01:06:57 +00:00
Chris Lattner
85579ef131
Inline a bunch of trivial SemaExpr routines into parser. No need for the additional indirection/layering.
...
Swift SVN r342
2011-04-04 23:41:44 +00:00
Chris Lattner
5e2346492e
Implement basic "dot syntax" for applying functions to values. size.area now applies size to area when area is defined as a global function.
...
Swift SVN r341
2011-04-02 23:10:55 +00:00
Chris Lattner
7530ec988c
Add a error to reject foo() when foo is not a function type. Previously we allowed it because these are two valid top-level values, but we now reject them because they are almost certainly a bug. This can be disabled by putting a space between them if this is useful for some reason.
...
Swift SVN r339
2011-03-27 02:56:47 +00:00
Chris Lattner
e85928e6f5
Split dollar identifier processing out to its own method.
...
Swift SVN r336
2011-03-26 23:57:43 +00:00
Chris Lattner
ed7b06c6ff
Move semantic analysis of scoped identifiers (x::a) to typechecking, allowing forward referencing of types. This introduces a new UnresolvedScopedIdentifierExpr node to represent the unresolved form.
...
Swift SVN r334
2011-03-26 22:35:05 +00:00
Chris Lattner
b1ea095995
Factor a OneOf predicate into a helper method.
...
Swift SVN r331
2011-03-23 06:28:09 +00:00
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
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
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
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
0d9da2b967
Improve diagnostics for oneof decls by making the constructors for the elements use the named type for the oneof decl instead of the underlying (unnamed) oneof type.
...
Swift SVN r302
2011-03-21 21:55:46 +00:00
Chris Lattner
8f073c56d3
This went with the previous patch.
...
Swift SVN r299
2011-03-21 21:53:59 +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
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
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
ca1b16b9df
Cleanup SemaExpr::ActOnDotIdentifier.
...
Swift SVN r275
2011-03-17 04:31:55 +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