Commit Graph

1958 Commits

Author SHA1 Message Date
Chris Lattner
71f351e0b6 fix the autoclosure bit to be properly canonicalized and preserved when building functiontypes.
Swift SVN r1190
2012-03-11 14:00:05 +00:00
Chris Lattner
145d926548 Perform sema of FunctionType's that have auto_closure behavior, building a bit in FunctionType.
Swift SVN r1187
2012-03-11 13:15:03 +00:00
John McCall
b2a2027a43 Revert r1144, r1145, and r1146. These changes (which removed ParenType
in favor of a single-element non-canonical TupleType) broke the type
system, in that supposed sugar (the TupleType) supported a different
set of operations from the canonical type.  For example, a
single-element unlabelled tuple type supports elementwise projection
(foo.$0), but the underlying element does not (or supports it
differently).

The IR-gen failure was due to a very related problem:  IR-gen
was not updated to reflect that a single unlabelled tuple element
is the same type as its element type, and therefore it was giving
different representations to these types ({ %foo } and %foo,
respectively), which broke widespread assumptions.

The removal of ParenType was done in pursuit of an AST invariant
that's not actually particularly interesting in the first place
and which, furthermore, is problematic to attain.

Swift SVN r1182
2012-03-11 09:15:21 +00:00
Chris Lattner
6641b06283 remove ParenType, which is now dead. Grouping parens are represented
as non-canonical tuple types.


Swift SVN r1147
2012-03-02 00:17:45 +00:00
Chris Lattner
2b65dcaf24 Change how we handle grouping parens. Instead of (x) being ParenType(x),
it is now a single element TupleType(x).  In order to preserve sane behavior,
we force grouping parens to be non-canonical and have them desugar down to
their underlying element type.

This does cause an IRGen testcase failure that looks like it was just working
accidentally before (though I don't really understand what is going on).  I
filed rdar://10967479 to track it.


Swift SVN r1146
2012-03-02 00:13:56 +00:00
John McCall
00b97b38af Grab-bag of materialization-related changes:
- introduce the concept of qualifiers on l-value types
  - teach overload resolution and coercion how to drop explicitness
  - require explicitness on normal [byref] arguments
  - make 'this' [byref(implicit)]
  - special-case '&' as a unary operator in the parser to make it
    produce an expression which type-checks as turning implicit l-values
    into explicit ones.

Obvious missing pieces:
  - updating LangRef
  - we should really complain about ever trying to rvalue-convert an
    explicit l-value
  - maybe qualification should play a part in overload resolution
  - we should diagnose attempts to declare unary '&' operators
  - there's a test case in expressions.swift which suggests my logic is
    slightly off

But I am out of time, and these will have to wait.

Swift SVN r1119
2012-02-22 06:43:33 +00:00
John McCall
d0f4d86f3e Use LValueType everywhere instead of the l-value value kind.
Kill off TypeJudgement.  Various fixes and improvements.



Swift SVN r1107
2012-02-06 22:47:08 +00:00
John McCall
5f1bcd7b7e Move all the side-allocated members of ASTContext to a single
side-allocation.  This is both easier to work with and extend
and slightly more efficient.



Swift SVN r1106
2012-02-02 01:13:33 +00:00
John McCall
6ff9afb6f5 Introduce LValueType.
Swift SVN r1105
2012-02-02 00:57:10 +00:00
Chris Lattner
599e4b2528 switch to using the new llvm::MutableArrayRef class, this requires llvm r148463
Swift SVN r1088
2012-01-19 06:39:07 +00:00
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
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
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
82bf169d90 implement ModuleType::get.
Swift SVN r1040
2012-01-14 06:40:39 +00:00
Chris Lattner
173df8794d implement the construction for MetaTypeType's and plug a leak of the ParenTypes map.
Swift SVN r1002
2012-01-11 06:59:14 +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
Chris Lattner
b737b112e7 modernize ProtocolType a bit to follow the form of OneOfType
Swift SVN r991
2012-01-05 21:51:48 +00:00
Chris Lattner
19b7a934a1 rename BuiltinFloatingPointType to BuiltinFloatType.
Swift SVN r980
2011-12-23 00:07:58 +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
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
6315b94e6b split out integer types to their own subclass of BuiltinType.
Swift SVN r932
2011-12-14 21:49:08 +00:00
Chris Lattner
5f1f4d8ce9 simplify code in Parser::actOnOneOfType now that oneof's always have names.
Give OneOfType an ivar for its TypeAlias.  It already knew its DeclContext.



Swift SVN r923
2011-12-13 01:41:19 +00:00
Chris Lattner
212b56afec actually, the ASTStage should be on Translation unit. There can be multiple modules in a context and they can all be in different phases of translation.
Swift SVN r902
2011-12-06 00:51:56 +00:00
Chris Lattner
02c9d9a3f1 Make the AST "phase" part of ASTContext, this is generally useful for assertions.
Swift SVN r900
2011-12-06 00:32:00 +00:00
Chris Lattner
0ca79b1075 rename ASTContext::BuiltinModule -> TheBuiltinModule for consistency with
the other ASTContext members.


Swift SVN r799
2011-11-01 04:18:23 +00:00
Chris Lattner
8e1c6c8ac6 flatten ModuleKind discriminator into DeclContext's one. Now Module is an
abstract class and we have an actual AST-level concept of the builtin module.


Swift SVN r798
2011-11-01 04:07:57 +00:00
Chris Lattner
9298082ebb move Diagnostics header to include/swift/AST to match .cpp files.
Swift SVN r782
2011-10-22 00:47:35 +00:00
Chris Lattner
f92f616aaf remove hte ASTContext::hadError bool.
Swift SVN r778
2011-10-22 00:32:39 +00:00
Chris Lattner
51680e3fdc remove the deprecated error/warning/note methods, finally.
Swift SVN r776
2011-10-22 00:26:34 +00:00
Chris Lattner
9f906da738 sink (a copy of) HadError into DiagnosticEngine, so that errors produced by it trigger error returns from main().
Swift SVN r768
2011-10-20 20:55:22 +00:00
Chris Lattner
7aaf0c5e0c rework the canonical type system a bit to make it so that all Types can access
their ASTContext without bloating everything.  Basically, now instead of having
a canonical type point to itself when canonical, it points to the ASTContext 
when canonical.  This means that Canonical types always have direct access to
their context and non-canonical ones just indirect through the canonical type
pointer to get to it (so it's two jumps away) by using a PointerUnion.

This should make type manipulation more straight-forward.

While we're at it, we actually memoize type canonicalization.  Before we 
forgot to remember the result in the canonical type pointer in Type.


Swift SVN r755
2011-10-18 22:32:56 +00:00
Chris Lattner
55651745b5 remove helper method, it is the same as T->isEqual(S, Ctx)
Swift SVN r752
2011-10-18 21:47:08 +00:00
Chris Lattner
a7c7d64fa0 Switch swift to use SourceLoc instead of SMLoc.
Also use the new getAdvancedLoc() method instead of hacking
on SMLoc directly.

Also fix the warning/note/error methods to forward through ASTContext
instead of being replicated everywhere.



Swift SVN r750
2011-10-18 01:22:29 +00:00
Doug Gregor
3d15bf3d55 Introduce a diagnostic-formatting engine and port most of the parser's
diagnostics over to it.

There are a few differences between this diagnostic engine and Clang's
engine:
  - Diagnostics are specified by a .def file (Diagnostics.def), rather
  than via tblgen, which drastically simplifies the build and makes
  code completion work when you add a new diagnostic.
  - Calls to the "diagnose()" method are safely typed based on the
  argument types specified in the .def file, so it's harder to write a
  diagnostic whose expected arguments (in the string) and whose actual
  arguments (in the code) don't match.
  - It uses variadic templates, so it hangs with the cool kids.



Swift SVN r734
2011-09-26 23:46:28 +00:00
John McCall
05459eced0 Add a convenience method for checking whether two types are
equivalent.



Swift SVN r729
2011-09-24 03:34:15 +00:00
John McCall
c61c807589 Mangle types for all declarations. Save the names of modules and mangle
those in, too.



Swift SVN r713
2011-09-18 09:21:42 +00:00
Chris Lattner
77237852d2 implement a.x syntax for using elements of a protocol.
Swift SVN r704
2011-09-11 17:39:45 +00:00
John McCall
54ff2ccf4a Lop the last word off ModuleDecl and TranslationUnitDecl.
Swift SVN r693
2011-09-06 21:43:46 +00:00
Chris Lattner
f2ae02a7b2 switch a couple of files to use AST.h umbrella header. Swift eagerly awaits clang modules...
Swift SVN r691
2011-09-06 07:01:03 +00:00
John McCall
ccb2d4e98f Framework for builtin lookup.
Swift SVN r685
2011-09-03 06:51:34 +00:00
Chris Lattner
0090c43b80 all members of a protocol have to be NamedDecl's, tighten up
typing.  Various tidying up.


Swift SVN r678
2011-09-02 00:58:38 +00:00
Chris Lattner
34ec8bc4aa implement support for var members of protocols.
Swift SVN r672
2011-09-01 21:57:35 +00:00
Chris Lattner
a838f412f4 eliminate ProtocolFuncElementDecl, just use FuncDecl instead.
Swift SVN r668
2011-09-01 18:17:12 +00:00
Chris Lattner
70bbb65241 make ProtocolType a DeclContext, add AST and trivial sema support for
ProtocolFuncElementDecl, the first thing we will allow in a protocol.


Swift SVN r664
2011-08-31 23:31:42 +00:00
Chris Lattner
cd66133b48 simplify interface to OneOfType::getNew.
Swift SVN r663
2011-08-31 23:11:05 +00:00
Chris Lattner
74b804a03a rearrange DeclContext arguments so that they are at the end, not the beginning.
Swift SVN r661
2011-08-31 23:05:51 +00:00
John McCall
6dfa91282d 'float' -> 'float32', 'double' -> 'float64'
Swift SVN r654
2011-08-31 19:57:52 +00:00
Chris Lattner
f9b024adb0 implement parser and AST support for trivial (empty) protocol types.
Swift SVN r652
2011-08-31 19:43:06 +00:00
John McCall
58b81c8da0 Add builtin float and double types.
Swift SVN r650
2011-08-31 18:43:22 +00:00