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
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
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
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
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
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
60cdb19d02
Add a new ImportDecl to represent imports.
...
Swift SVN r286
2011-03-19 06:22:47 +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
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
Chris Lattner
f0219a37b7
Fix a comment in type.h, allow printing of null types, fix oneof printing.
...
Swift SVN r259
2011-03-13 20:45:45 +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
ddb760bf2b
Remove the concept of an ASTConsumer, add a new TranslationUnitDecl.
...
Swift SVN r255
2011-03-04 22:08:34 +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
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
2e26241a7a
Fix AliasType to point to the TypeAliasDecl instead of replicating its contents.
...
Swift SVN r229
2011-02-22 06:11:48 +00:00