Commit Graph

28382 Commits

Author SHA1 Message Date
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
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
e55e5ca594 Improve error message.
Swift SVN r340
2011-04-02 22:53:53 +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
866a5fdfe3 Minor tidying.
Swift SVN r338
2011-03-27 00:30:44 +00:00
Chris Lattner
85f67d0fc6 NameBinder shouldn't create exprs, it should return decls.
Swift SVN r337
2011-03-27 00:30:24 +00:00
Chris Lattner
d3201b3097 improve diagnostic.
Swift SVN r335
2011-03-26 23:12:54 +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
eb9d1353d2 Allow name binding to bind to struct elements.
Swift SVN r332
2011-03-23 06:36:01 +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
2205513c45 Add a comment acknowledging that conversions are ambiguous and give an example. Simplify some code.
Swift SVN r328
2011-03-23 04:50:15 +00:00
Chris Lattner
2595be1ffa Clean up when type verification fails. This fixes the last testsuite failure! woot.
Swift SVN r327
2011-03-22 22:17:31 +00:00
Chris Lattner
828deb94ba improve wording of a diagnostic.
Swift SVN r326
2011-03-22 22:11:34 +00:00
Chris Lattner
7a04188335 Improve location info and some other diagnostics in a couple cases.
Swift SVN r325
2011-03-22 22:09:22 +00:00
Chris Lattner
8d2e911ba1 Make the type conversion errors *much* more specific, useful, and non-redundant.
Swift SVN r324
2011-03-22 22:03:56 +00:00
Chris Lattner
89a52ec1a1 Fix a crash on invalid where we didn't discard a munged subexpression tree.
Swift SVN r323
2011-03-22 21:36:06 +00:00
Chris Lattner
80b293cda6 Eliminate ConversionReason by having convertToType generate an error and the caller generate a note.
Swift SVN r322
2011-03-22 21:22:58 +00:00
Chris Lattner
72009397d6 Move type conversion routines into SemaCoerceBottomUp.
Swift SVN r321
2011-03-22 06:52:00 +00:00
Chris Lattner
c45bfcff0a Constant prop the IgnoreNonDecls argument to convertToType to be false since it is at all callsites.
Swift SVN r320
2011-03-22 06:44:08 +00:00
Chris Lattner
8c06074e98 rearrange a ton of code in TypeCHecking.cpp
Swift SVN r319
2011-03-22 06:42:30 +00:00
Chris Lattner
cf836f7446 Eliminate a getAs<> by not discarding type info.
Swift SVN r318
2011-03-22 06:30:37 +00:00