Commit Graph

28404 Commits

Author SHA1 Message Date
Chris Lattner
123c200953 switch more stuff to use enum class, C++'0x needs a :foo operator :)
Swift SVN r438
2011-07-24 18:28:52 +00:00
Chris Lattner
259fab4238 adopt a few more '0x features.
Swift SVN r437
2011-07-24 00:45:51 +00:00
Chris Lattner
096a3e16bc switch to range-based for loops where possible. I'm actually surprised how many
places are blocked by needing an index exposed for other purposes.  Not having a
MutableArrayRef doesn't help either.


Swift SVN r434
2011-07-23 20:47:13 +00:00
Chris Lattner
4f29cc0e8c convert TheUnresolvedType/TheDependentType and the empty tuple type
to be accessors on their respective classes, for consistency.


Swift SVN r429
2011-07-19 06:41:42 +00:00
Chris Lattner
c9ec409046 Context.getNewOneOfType -> OneOfType::getNew
Swift SVN r428
2011-07-19 06:28:36 +00:00
Chris Lattner
a39857ab85 migrate ASTContext::getTupleType -> TupleType::get
Swift SVN r427
2011-07-19 06:26:55 +00:00
Chris Lattner
649a577059 move from ASTContext::getArrayType -> ArrayType::get
Swift SVN r426
2011-07-19 06:22:04 +00:00
Chris Lattner
e106d336cb while I'm in a cleanup mood, move the factory functions from
types off of ASTContext onto the types themselves.  This 
never made sense for clang, and makes the same amount of sense
for swift.  Start with function types.


Swift SVN r425
2011-07-19 06:17:26 +00:00
Chris Lattner
3af81cccbe raw_ostream and NullablePtr. While there are more types that
could be handled in similar ways, this gets the most of them.


Swift SVN r424
2011-07-19 06:09:31 +00:00
Chris Lattner
10017bef15 ArrayRef and SmallVector[Impl]
Swift SVN r423
2011-07-19 06:03:26 +00:00
Chris Lattner
7275ca527a pull in StringRef and Twine.
Swift SVN r422
2011-07-19 06:00:20 +00:00
Chris Lattner
19dbcaa171 pull the casting operators into LLVM.h
Swift SVN r421
2011-07-19 05:57:01 +00:00
Chris Lattner
e647b29339 stop the llvm-namespace-qualification-insanity by caving in and
adding a new swift/AST/LLVM.h file which forward declares and imports
common llvm classes, starting with SMLoc.


Swift SVN r420
2011-07-19 05:49:43 +00:00
Chris Lattner
d6cf48a22d add a "using llvm::SMLoc" to simplify some code,
move "-> ()" inference into Sema.  The boundary
between Parser and Sema* is nebulous at best.


Swift SVN r419
2011-07-19 05:39:06 +00:00
Chris Lattner
434f369023 fix a bunch of failing testcases. I didn't notice this because
lit is not interacting with cmake properly.


Swift SVN r418
2011-07-19 05:38:22 +00:00
Chris Lattner
79b312cfe3 reduce duplication in type checking. Vars/func/method's are all
conceptually the same, vardecl just requires checking the name 
specifier.


Swift SVN r417
2011-07-19 05:29:37 +00:00
Chris Lattner
9e8c82435a implement AST and sema support for methods. The example method in the
testcase now AST's to:

   (methdecl 'print2' type='(this : rect) -> (os : ostream) -> ()'
      (closure_expr type='(this : rect) -> (os : ostream) -> ()'
        (closure_expr type='(os : ostream) -> ()'
          (brace_expr type='()'
            (apply_expr type='int'
              (declref_expr type='(r : rect) -> int' decl=area)
              (tuple_expr type='(r : rect)'
                (declref_expr type='rect' decl=this)))))))

which seems right.  Some cleanups are pending.



Swift SVN r416
2011-07-19 05:26:51 +00:00
Chris Lattner
96103cab95 use the new llvm::TinyPtrVector class, which was derived from this code.
Swift SVN r408
2011-07-18 02:13:37 +00:00
Doug Gregor
50323196b3 Teach module lookup to look first in the directory where the importing
module is located, and then fall back to the current directory if
nothing was found there. This allows us to run the Swift regression
tests from a directory other than "test" (e.g., in the build
directory, as is currently needed by CMake).

The implementation itself is a temporary hack that will eventually
need to be replaced with a proper virtual file system + module
manager.


Swift SVN r405
2011-07-14 19:16:45 +00:00
Doug Gregor
86ab76d624 Introduce a CMake build system for Swift.
This CMake-based build system is based on the one in Clang, simplified
and tweaked slightly to better support building a smaller Xcode
project that links against an existing LLVM (rather than importing all
of LLVM into this project).



Swift SVN r403
2011-07-14 17:58:33 +00:00
Chris Lattner
f72055598a improve diagnostic from:
error: invalid conversion from type 'int' to '__builtin_int1_type'

to:

error: expression of type 'int' is not legal in a condition



Swift SVN r398
2011-06-05 04:09:56 +00:00
Chris Lattner
464d255a2d Implement AST building and type checking for if expressions, these now work per-documentation, though the diagnostics are awful.
Swift SVN r397
2011-06-05 04:02:24 +00:00
Chris Lattner
3b80f42a0b The condition of an expression is converted to a logic value with
convertToLogicValue, at least right now.


Swift SVN r395
2011-06-05 02:18:51 +00:00
Chris Lattner
8d0aec7634 Rip out a really terrible hack introduced as a short-term workaround
when overloading was implemented, which was only needed to support
the if/else expression nodes. Now that if/else is a proper language
construct, this hack dissolves.



Swift SVN r394
2011-06-05 02:08:36 +00:00
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
0b068577bd Use TupleShuffleExpr to finally eliminate the last remenants of the
ASDAG.  Our AST is actually a tree again.  The testcase compiles into:
...
          (vardecl 'c' type='(a : int, b : int)')
          (vardecl 'd' type='(b : int, a : int)'
            (tuple_shuffle type='(b : int, a : int)' Elements=[1, 0]
              (declref_expr type='(a : int, b : int)' decl=c))))))



Swift SVN r387
2011-04-29 07:22:33 +00:00
Chris Lattner
4bf1feaeec use new AllocateCopy method.
Swift SVN r386
2011-04-29 07:19:29 +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
09d1be4041 Completely remove the ability to do elementwise conversion of tuple values
to compatible-but-different tuple types, unless the tuple value is a tuple
literal (syntactically a paren expression).  This is both unnecessary except
in insane cases (see the testcase) and breaks some invariants that we'd like
to keep (like the AST being a tree).  Reordering of elements is still fine.


Swift SVN r383
2011-04-29 06:56:35 +00:00
Chris Lattner
d781810791 Use conversion ranking in binary expression overloading.
Swift SVN r380
2011-04-29 00:24:00 +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
c5eeb2c01c Fix overload resolution in function application to not just pick the first match that matches the input argument type. If there are multiple pieces to the function then multiple candidates can have the same input type.
Swift SVN r367
2011-04-11 06:12:11 +00:00
Chris Lattner
91fb8351b7 Implement support for overloaded binary operators.
Swift SVN r366
2011-04-11 05:59:23 +00:00
Chris Lattner
d923da6dc6 Throw in a terrible hack to make "var x7 = x1.search(42).width;" work. The parsing hacks to allow if/else to work should be ripped out and if/else should be added to the grammar properly.
Swift SVN r365
2011-04-11 05:38:39 +00:00
Chris Lattner
c588ee21b4 Reject any attempt to form an overload set with binary operators that have different precedence levels. It doesn't make sense for + of ints to have a different level than + of floats.
Swift SVN r364
2011-04-11 05:37:56 +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
dec08ecf64 Check for floating tuple literals that look like argument lists only after an entire SequenceExpr is done being processed. This allows:
var x6 = x1.search(42)
to work right.

Swift SVN r362
2011-04-11 00:17:11 +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
3e66832959 Implement selection of an overload function based on its argument.
Swift SVN r354
2011-04-10 06:27:58 +00:00
Chris Lattner
1450aaec38 Fix a bug preventing ov_var+4 from resolving.
Swift SVN r353
2011-04-10 06:12:31 +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
2810c91dd2 Implement lookup of overloaded values through import decls.
Swift SVN r350
2011-04-10 03:35:13 +00:00
Chris Lattner
ce8c32d388 Diagnose redefinition of a binop with a nonbinop and visaversa.
Swift SVN r349
2011-04-10 03:15:18 +00:00
Chris Lattner
229141ab80 Start adding support for value overloading. Right now we allow overloaded definitions (at top level only), and name binding just takes the first value of a name.
Swift SVN r348
2011-04-10 03:08:27 +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