Commit Graph

28382 Commits

Author SHA1 Message Date
John McCall
ea5e37e276 Getterize uses of TupleTypeElt. I'm trying to figure out how
parameter attributes should work here.



Swift SVN r1066
2012-01-18 04:05:25 +00:00
Chris Lattner
fa2ea94348 always turn a named reference to a type into an IdentifierType.
This preserving source location info and reduces redundancy in the parser.


Swift SVN r1065
2012-01-18 01:57:44 +00:00
Chris Lattner
1c42e8f6a6 rename DottedNameType to IdentifierType. It captures loc information for random uses of type names, among other things.
Swift SVN r1064
2012-01-18 01:52:28 +00:00
Chris Lattner
2f7cd03c6b switch type lookup to use value lookup for everything. Dead code ahoy.
Swift SVN r1057
2012-01-17 07:36:16 +00:00
Chris Lattner
51e44891af rip out now-dead code from NameBinding. It still generally needs to be beaten
into sense later, but this gets it closer to reasonable.


Swift SVN r1051
2012-01-17 06:35:34 +00:00
Chris Lattner
c8ca11a199 Drop in the new DottedNameType and wire it up in name binding.
This is horribly hack and slash (but enough to pass all tests) for a few reasons:
- I've #if 0'd out the tendrils of the old code 
- This handles *just* what was handled before instead of being more general
- We don't have an llvm::MutableArrayRef type, so there is some really gross
  const_cast'ing and other struggles to deal with its absence.



Swift SVN r1050
2012-01-17 06:32:00 +00:00
Chris Lattner
4f8193956d introduce DottedNameType, which will eventually be used for foo.bar in a type context.
Swift SVN r1049
2012-01-17 01:55:17 +00:00
Chris Lattner
f5e5b411be push OverloadSetRefExpr::createWithCopy through to the rest of the call sites that can
benefit from it, reducing redundancy.


Swift SVN r1045
2012-01-14 07:28:17 +00:00
Chris Lattner
fab4ef8820 introduce a new OverloadSetRefExpr::createWithCopy method to eliminate
some redundancy in the code that always has to create an overload set
or a single declrefexpr depending on what various lookups produce.


Swift SVN r1044
2012-01-14 07:22:25 +00:00
Chris Lattner
f1db6de509 remove the :: token and DCE UnresolvedScopedIdentifierExpr.
Swift SVN r1043
2012-01-14 07:00:45 +00:00
Chris Lattner
c5c81c6f70 Implement dot lookup on module types, allowing things like Builtin.add_int32 to find
the add_int32 member of the Builtin module.  :: is now dead.


Swift SVN r1042
2012-01-14 06:52:38 +00:00
Chris Lattner
9d10d231ea implement support for normal lookup to find module names, and build a
ModuleExpr of the right  type to represent it.  Not tested yet, because
nothing can handle module exprs.


Swift SVN r1041
2012-01-14 06:41:33 +00:00
Chris Lattner
4b8a147952 change the type grammar from qualifying a type with module::typename to module.typename.
Swift SVN r1036
2012-01-13 05:45:59 +00:00
Chris Lattner
be666df09e introduce a ModuleExpr node.
Swift SVN r1035
2012-01-13 05:07:21 +00:00
Chris Lattner
73570ac177 introduce a new ModuleType, which will be the type given to ModuleExpr's.
Swift SVN r1034
2012-01-13 04:51:39 +00:00
Chris Lattner
5ab30d7a88 implement lookup of extension methods with a type as a base, e.g. type.extensionmethod.
This is semantically equivalent (but much more uniform) to C++'s method pointer stuff.


Swift SVN r1032
2012-01-12 23:07:06 +00:00
Chris Lattner
ed47f92c85 remove the ability for a::b to resolve a member 'b' in type 'a'. It now
just works for module references like Builtin::int32.


Swift SVN r1028
2012-01-12 21:54:32 +00:00
Chris Lattner
6db2a3a3b0 implement support for Ty.member to represent the same thing as Ty::member.
Swift SVN r1024
2012-01-12 20:49:57 +00:00
Chris Lattner
82cb8e3b7f change the prototype for semaApplyExpr to allow it to retunr a new
node, allowing it to build ConstructorCallExpr correctly.



Swift SVN r1022
2012-01-12 20:08:19 +00:00
John McCall
59bed696a5 Introduce a ParenExpr to represent the special case of
a tuple with one element and no labels.  This form is
treated specially in essentially every case, so it might
as well be its own expression kind.



Swift SVN r1021
2012-01-12 19:55:06 +00:00
Chris Lattner
472256440c fix enough to get MetaType constructor calls to be able to resolve slices of oneof's.
In this case we're resolving ZeroOneTwoThree(1) to ZeroOneTwoThree::One(1)


Swift SVN r1017
2012-01-12 08:02:33 +00:00
Chris Lattner
4c050c0e52 Fix a nasty type checking bug (exposed by my next patch), where we would lose a
required type conversion in the presence of integer literals and dependent types.


Swift SVN r1016
2012-01-12 07:16:42 +00:00
Chris Lattner
e3a97a5b36 enhance type checking of apply exprs to handle application of an
argument list to a metatype.  No functionality change since nothing 
injects metatype'd values into a scope that can be looked up yet.


Swift SVN r1009
2012-01-12 06:10:02 +00:00
Chris Lattner
9f5d37dd2f introduce a new ConstructorCallExpr node, which is sugar node used to represent
the syntactic form of an argument list applied to a metatype.  Semantically,
this is yet-another ApplyExpr.


Swift SVN r1008
2012-01-12 05:43:07 +00:00
Chris Lattner
37cb633b12 Change TypeAliasDecl to be a ValueDecl, whose type is MetaTypeType.
Swift SVN r1004
2012-01-11 07:13:32 +00:00
Chris Lattner
e22a30a130 revert r995: "introduce MetaTypeDecl (though nothing creates it yet)".
After some pondering on this, I can just use DeclRefExpr(TypeAliasDecl) to
represent a named metatype, there is not need to have yet-another decl.  I'm
glad about this, because it didn't seem right.



Swift SVN r999
2012-01-11 05:42:22 +00:00
Chris Lattner
f204abf010 introduce MetaTypeDecl (though nothing creates it yet)
Swift SVN r997
2012-01-06 20:50:56 +00:00
Chris Lattner
527c58f846 implement MetaTypeType, the type system representation of a metatype.
Swift SVN r996
2012-01-06 19:51:50 +00:00
John McCall
a87944a69f Per discussion with Chris, this assertion is over-aggressive.
Swift SVN r995
2012-01-06 11:19:09 +00:00
John McCall
7e2b5e5410 Missing cases.
Swift SVN r994
2012-01-06 04:12:41 +00:00
John McCall
d559794e73 Introduce a new kind of sugar, ParenType. A tuple with one
anonymous member is actually one of these.

A func decl is curried over all of its parameter clauses,
as long as they're written without parentheses.  So the body
of a func is the body of the "most curried" function:
  func foo(x:int) -> (y:int) -> int {
    // This is the body of the function that takes 'y'.
    // It returns an int.
  }
  func bar(x:int) -> ((y:int) -> int) {
    // This is the body of the function that takes 'x'.
    // It returns a functon of type (y:int) -> int.
  }



Swift SVN r993
2012-01-06 04:10:32 +00:00
John McCall
bf932b359f When type-checking a return, walk down through parameter clauses the
same way we do when setting up the scope.  This makes us check extensions
correctly, but breaks other tests;  more design is required.



Swift SVN r992
2012-01-05 21:52:28 +00:00
John McCall
05495d67d9 Check that assignments are to l-values. It really is this easy.
Now back to debugging the crashing test.



Swift SVN r990
2012-01-05 07:59:41 +00:00
John McCall
b2569c7786 Provide PrettyStackTraceEntries for Expr* and Stmt* as well,
and type-check functions within the former.



Swift SVN r989
2011-12-23 03:53:23 +00:00
John McCall
5022a636ee Aggressive dead code elimination.
Swift SVN r988
2011-12-23 02:50:50 +00:00
John McCall
0138e451a1 Look through extension decls here, too. It's not clear to me why
we can't just the normal walker for this top-level walking.



Swift SVN r985
2011-12-23 02:36:14 +00:00
Chris Lattner
19b7a934a1 rename BuiltinFloatingPointType to BuiltinFloatType.
Swift SVN r980
2011-12-23 00:07:58 +00:00
Chris Lattner
926a3fe671 completely reimplement floating point literals to follow the model of integer literals.
Among other things, this gives us the amazing power to accept "var x : float = 0.0"



Swift SVN r978
2011-12-22 23:50:03 +00:00
Chris Lattner
c91c1d9db1 generalize builtin floating point types to support all of the FP types
that LLVM supports.  The standard library still only exports float and double,
but the swift core should be more general.  Yay for PPC128 :)


Swift SVN r973
2011-12-22 22:01:07 +00:00
Chris Lattner
9d112b5270 Switch our predicate that checks for too large integers as StringRef::getAsInteger
isn't guaranteed to return a minimally fit APInt.  Add test so that both sides
of the fencepost are covered.


Swift SVN r969
2011-12-22 07:44:36 +00:00
Chris Lattner
6a51dbba34 Remove hard coded list of integer types from ASTContext, making BuiltinIntegerType have a "plus" factory method to create them like other types.
Swift SVN r966
2011-12-22 07:07:01 +00:00
Chris Lattner
98c5f5fad4 change BuiltinIntegerType to keep its width as an ivar, eliminating the
number of switches scattered through the compiler.


Swift SVN r964
2011-12-22 06:50:34 +00:00
Chris Lattner
9c3ad3eb30 include types we're trying to convert to in a few diagnostics.
Swift SVN r962
2011-12-22 06:27:54 +00:00
Chris Lattner
ac0662003c add a note to clarify a potentially confusing case of an improperly defined conversion function. In this case we now produce:
test/expressions.swift:316:4: error: inferred type 'bool' is not compatible with integer literals
   4 //expected-error {{inferred type 'bool' is not compatible with integer literals}}
   ^
test/expressions.swift:312:3: note: while processing argument of conversion function to inferred type 'int_test5'
  plus func convert_from_integer_literal(val : bool) -> int_test5 {}  // expected-note {{while processing argument of conversion function to inferred type 'int_test5'}}
  ^
test/expressions.swift:315:1: note: while converting 'var' initializer to declared type
var il_g : int_test5 = // expected-note {{while converting 'var' initializer}}
^



Swift SVN r961
2011-12-22 06:25:50 +00:00
Chris Lattner
a2ee92258f make a diagnostic more precise and useful.
Swift SVN r960
2011-12-22 06:17:02 +00:00
Chris Lattner
b126ed5bef generalize integer literals to allow conversion functions to go
through 1 level of indirection in literal conversions.  This allows the
testcase to define its "convert_from_integer_literal" function in terms
of the library 'int' type instead of requiring them to always be defined
in terms of Builtin:: types.  We get the expected chained conversion calls 
in the AST.
 


Swift SVN r957
2011-12-22 06:08:01 +00:00
Chris Lattner
46f701f997 build the final, happy AST for integer literals. For example, this:
import swift
var c : int8 = 4 

becomes:

(translation_unit
  (brace_stmt
    (import_decl 'swift')
    (var_decl 'c' type='int8'
      (call_expr type='int8'
        (declref_expr type='(val : int8) -> int8' decl=convert_from_integer_literal)
        (integer_literal_expr type='int8' value=4)))))    <<- this is Builtin::int8

... which is finally great.  The only problem is that it causes massive explosions 
in IRGen, which isn't expecting this yet.  I'll look at this this evening if John
doesn't beat me to it :)


Swift SVN r954
2011-12-22 00:44:39 +00:00
Chris Lattner
c08263a843 rejigger things so that applyTypeToInteger can return a new and different AST on success.
Swift SVN r953
2011-12-22 00:37:12 +00:00
Chris Lattner
98703ab7d2 switch the convert_from_integer_literal function to being a plus function and check its new type constraints.
Swift SVN r951
2011-12-22 00:19:53 +00:00
Chris Lattner
8ce4737534 implement "a.b" AST and type checker support. Semantics are that 'a' is evaluated and discard. 'b' is evaluated and returned.
Swift SVN r950
2011-12-21 23:49:30 +00:00