Commit Graph

175 Commits

Author SHA1 Message Date
Joe Groff
481fbb7b91 Drop the non-interface types from SILFunctionType.
There are some straggling references to the context generic param list, but nothing uses the non-interface param or result types anymore!

Swift SVN r13725
2014-02-09 22:39:01 +00:00
Chris Lattner
b581fc916d stop serializing the self decl for ctors and dtors, it is redundant with the
argument pattern that already includes it.


Swift SVN r13707
2014-02-09 17:37:06 +00:00
Chris Lattner
595817bd89 Rename data structures relating to WillSetDidSet properties to call them "Observing"
properties internally to the compiler.  NFC.


Swift SVN r13587
2014-02-06 17:51:45 +00:00
Chris Lattner
91e29d16cf use an enum to make serialized modules more stable against changes to the AST.
This isn't really how we'd like to serialize vardecls in the 2.0 timeframe anyway,
but it helps maintain the existing pattern.


Swift SVN r13373
2014-02-03 21:48:09 +00:00
Chris Lattner
74833d0679 properly serialize stored_objc and willset/didset properties in module files.
Swift SVN r13367
2014-02-03 19:55:07 +00:00
Chris Lattner
3e08673772 Introduce patterns for self arguments to ctors and dtors, making them uniform
with FuncDecls.  This allows us to eliminate special case code for handling
self in various parts of the compiler.

This also improves loc info (debug info and AST info) because 'self' now
has a location instead of being invalid.

I also took the opportunity to factor a bunch of places creating self decls
to use similar patterns and less copy and paste code.



Swift SVN r13196
2014-01-31 02:17:22 +00:00
Doug Gregor
030770a8c2 Make DynamicSelf into its own special type node.
Making DynamicSelf its own special type node makes it easier to opt-in
to the behavior we want rather than opting out of the behavior we
don't want. Some things already work better with this representation,
such as mangling and overriding; others are more broken, such as the
handling of DynamicSelf within generic classes and the lookup of the
DynamicSelf type.


Swift SVN r13141
2014-01-30 05:36:20 +00:00
John McCall
f416dd81a8 Track whether a PatternBindingDecl theoretically
declares storage or not.

Swift SVN r12942
2014-01-24 22:46:22 +00:00
Jordan Rose
af700a1912 [serialization] Include the module name in the serialized AST data.
We don't currently use this for anything, but if we have the module name
available and easy to access in the bitstream, we can drop the wrapper
around the serialized AST that's put into the binary itself for use by LLDB.

Swift SVN r12921
2014-01-24 18:42:06 +00:00
Jordan Rose
f214e2f185 [serialization] Include the module name in the serialized AST data.
We don't currently use this for anything, but if we have the module name
available and easy to access in the bitstream, we can drop the wrapper
around the serialized AST that's put into the binary itself for use by LLDB.

Swift SVN r12919
2014-01-24 18:42:03 +00:00
Joe Groff
0776c4b6b8 SIL: Reorient function type lowering toward interface types.
Lower types for SILDeclRefs from the interface types of their referents, dragging the old type along for the ride so we can still offer the context to clients that haven't been weaned off of it. Make SILFunctionType's interface types and generic signature independent arguments of its  Derive the context types of SILFunctionType from the interface types, instead of the other way around. Do a bunch of annoying inseparable work in the AST and IRGen to accommodate the switchover.

Swift SVN r12536
2014-01-18 19:42:02 +00:00
Doug Gregor
a534f6978a Add a new class attribute requires_stored_property_inits.
This attribute states that all stored properties within the class must
provide initial values. This will allow us to move stored property
initialization into Objective-C's post-allocation initialization hook,
.cxx_construct.

Swift SVN r12228
2014-01-13 16:31:22 +00:00
John McCall
1bc1c669a2 Add the '@unchecked T?' syntactic sugar for UncheckedOptional<T>.
Swift SVN r12128
2014-01-10 19:13:51 +00:00
Doug Gregor
23fff50b69 Use UTF-16 string literals when the (builtin) string literal type supports it.
Make the compiler fully support both UTF-8 and UTF-16 string
literals. A (standard-library-defined) string type (such as String)
that wants UTF-16 string literals should conform to the
BuiltinUTF16StringLiteralConvertible protocol; one that wants UTF-8
string literals should conform to the BuiltinStringLiteralConvertible
protocol.

Note that BuiltinUTF16StringLiteralConvertible inherits from
BuiltinStringLiteralConvertible, so a string type that wants UTF-16
string literals also has to implement support for UTF-8. The UTF-16
entry point is preferred when the compiler knows that UTF-16 is
supported. This only tends to happen when we have a generic parameter
that is required to conform to StringLiteralConvertible, e.g.,

  func f<T: StringLiteralConvertible>() {
    var t: T = "Hello, World!" // uses UTF-8 entry point
  }

because the UTF-8 entry point is the only one guaranteed to be available.



Swift SVN r12014
2014-01-07 22:55:07 +00:00
Dave Abrahams
ff076dc3f2 [stdlib] "Generator" => "Stream"
This is step 1 of implementing the new Container/Sequence/Stream
protocols.  See test/Prototypes/Container.swift for the complete picture
of where this is headed.

Swift SVN r11924
2014-01-06 16:40:32 +00:00
Joe Groff
8bebb084e6 Rename 'RequirementKind::ValueWitnessMarker' to 'WitnessMarker'.
It's witnessing protocol requirements, not values, and "value witness" has a particular meaning in IRGen.

Swift SVN r11814
2014-01-02 17:47:40 +00:00
Chris Lattner
9ae289de46 Drive the semantic wedge harder into lvalues. Now, instead of having one LValueType
with qualifiers on it, we have two distinct types:
 - LValueType(T) aka @lvalue T, which is used for mutable values on the LHS of an
   assignment in the typechecker.
 - InOutType(T) aka @inout T, which is used for @inout arguments, and the implicit
   @inout self argument of mutable methods on value types.  This type is also used
   at the SIL level for address types.

While I detangled a number of cases that were checking for LValueType (without checking
qualifiers) and only meant @inout or @lvalue, there is more to be done here.  Notably,
getRValueType() still strips @inout, which is totally and unbearably wrong.



Swift SVN r11727
2013-12-29 22:23:11 +00:00
Doug Gregor
1482256a04 Make operator methods to module-scope name lookup.
Fixes the operator name lookup issue in <rdar://problem/15715996>.

Swift SVN r11724
2013-12-29 20:41:07 +00:00
Chris Lattner
d7621b5a7b Remove the concept of a "nonsettable lvalue": Now everything that is
nonsettable is represented as an rvalue.  Yay for one less concept in
the AST.


Swift SVN r11640
2013-12-25 22:20:01 +00:00
Joe Groff
63d08c786d SIL: Handle metatype abstraction differences.
Lower metatype types as @thin or @thick based on whether the type is static and whether the abstraction pattern allows for a thin metatype. Add a '@thick' attribute and require SIL metatypes to always be annotated with either '@thin' or '@thick' to distinguish them from unlowered metatypes.

Swift SVN r11525
2013-12-20 23:06:16 +00:00
Jordan Rose
f1ff340367 Move the "conformances" array from TypeDecl to NominalTypeDecl.
No functionality change, but a nice limiting of scope.

Swift SVN r11489
2013-12-19 23:25:07 +00:00
Jordan Rose
7a30de2efe Disallow inheritance clauses for concrete typealiases.
typealias MyInt: ForwardIndex = Int

There is no real reason to allow this; it's just a static_assert that Int
conforms to ForwardIndex, which would be better spelled some other way.

This only applies to concrete typealiases, i.e. those that simply alias an
underlying type. Associated types can still have both inheritance clauses
and a (default) underlying type.

Swift SVN r11481
2013-12-19 21:13:54 +00:00
Joe Groff
017440165e Fix the weird capitalization of MetaTypeType.
Swift SVN r11475
2013-12-19 18:43:08 +00:00
Doug Gregor
ec4913b0ea Implement default definitions for associated types.
Addresses <rdar://problem/14292873>.


Swift SVN r11422
2013-12-18 06:24:53 +00:00
Chris Lattner
51862b91fd rename the inout decl attribute (not the type attribute) to @mutating.
Swift SVN r11416
2013-12-18 04:44:56 +00:00
Jordan Rose
531b240ca0 [serialization] Rework cross-references to be more general / more robust.
Previously, cross-references just carried a chain of identifiers and a
top-level module, plus a type to validate against, a generic parameter index,
or an operator fixity. However, referencing "the first generic parameter
of the prefix function ++ that takes a ForwardIndex" requires /all three/
of these filters to unambiguously select the right declaration.

Now, cross-references consist of a chain of trailing records, one for each
link in the path. There are (currently) five kinds of links:

Type: a declaration that cannot have overloads
Value: a declaration that can have overloads (filtered by type)
Extension: filter to decls within extensions on another module
Operator:
- as the first path piece, an operator declaration
- as a later path piece, a fixity filter for operator functions
Generic Param: an indexed generic parameter of the previous result

This should allow us to uniquely cross-reference any Swift declaration we
need to.

Swift SVN r11399
2013-12-17 23:03:34 +00:00
Joe Groff
44dcc43fa9 ClangImporter: Make NS_OPTIONS imports conform to RawOptionSet.
This makes the bitwise operations &|^~ work with NS_OPTIONS.

Swift SVN r11349
2013-12-16 19:22:27 +00:00
Doug Gregor
07c0793e30 Construct the type witnesses of SpecializedProtocolConformance lazily.
A SpecializedProtocolConformance intentionally contains all of the
information we need to synthesize the type witnesses from the
underlying (generic) conformance. Do so lazily rather than eagerly,
because we won't always need all of them.

As a nice side effect, we no longer need to serialize the witnesses of
these specialized protocol conformances, so we can save some space in
the Swift module file.


Swift SVN r11303
2013-12-14 06:20:44 +00:00
Chris Lattner
281cd524b7 recommit @inout attributes, now with serialization support.
Swift SVN r11286
2013-12-14 01:17:35 +00:00
Jordan Rose
f29f083fcb [serialization] Stop eagerly deserializing decls with conversion functions.
There shouldn't ever be a reason to do this: if a conversion function is
ever selected by the type-checker, it's because the type the conversion
lives on was suggested by another constraint, which means we can do a
normal lookup for the conversion function.

This is actually the only thing being eagerly deserialized, so remove the
notion of eager deserialization altogether.

Swift SVN r11220
2013-12-12 23:31:16 +00:00
Chris Lattner
698380d6d3 Introduce a new bit in VarDecl, "isLet". Teach Sema that 'isLet' properties
are not settable (like get-only ones).  Set the 'isLet' bit in various 
places, but not the particularly interesting or useful places yet.



Swift SVN r11121
2013-12-11 06:45:40 +00:00
Jordan Rose
fac5659813 [serialization] Sprinkle PrettyStackTrace throughout deserialization code.
Since we don't have soft-failure yet from deserialization, it's helpful to
at least know where to start looking when something crashes. There are some
rough edges here but it should be much better than nothing.

This also pulls the list of record nodes out into a separate file, so that
we can avoid repeating it.

Example crash:
1.	While reading from ./CTypes.swiftmodule
2.	While deserializing 'CBool' (StructDecl)
3.	While deserializing decl #26 (XREF)
4.	Cross-reference to 'LogicValue' in swift
(don't worry, this is an example where I'm tweaking things)

<rdar://problem/14838332>

Swift SVN r11057
2013-12-10 00:23:40 +00:00
Argyrios Kyrtzidis
55e2792f10 Serialize @IBLiveView attribute.
Swift SVN r10959
2013-12-07 00:41:58 +00:00
Argyrios Kyrtzidis
345564380c Rename 'ibaction/iboutlet' attributes to 'IBAction/IBOutlet'.
Swift SVN r10953
2013-12-07 00:14:51 +00:00
Joe Groff
0ff977d407 Add a 'WitnessMethod' enumerator to AbstractCC.
We'll use this to represent the slightly-different polymorphic calling convention used for passing Self into protocol witnesses.

Swift SVN r10898
2013-12-06 01:32:35 +00:00
Dave Abrahams
4c0e6eec4a [stdlib] Rename Enumerable => Sequence
Swift SVN r10857
2013-12-05 13:18:41 +00:00
Joe Groff
b06afcbf55 Ensure 'isStatic' bit of PatternBindingDecls is always initialized.
And that it gets serialized.

Swift SVN r10382
2013-11-12 23:12:16 +00:00
Joe Groff
4f2adbe7ed AST: Include 'static' bit in VarDecls.
And track the 'static' SourceLoc in the PatternBindingDecl. This lets isInstanceMember return the right thing for static vars.

Swift SVN r10369
2013-11-12 06:16:48 +00:00
Doug Gregor
dcb87f163c (De-)serialize @optional attributes.
Swift SVN r9996
2013-11-06 19:03:25 +00:00
Jordan Rose
63731584b6 [serialization] Introduce ModuleID, with codes for special modules.
ModuleID is compatible with IdentifierID, but uses 0 to mean “the builtin module”
and 1 to mean “the current module”. Anything else is a top-level module name,
as an identifier. As an implementation detail, 1 is now never a valid IdentifierID.
(0 remains “the empty string”.)

Using this, simplify the encoding of the owner of a conformance.

Swift SVN r9944
2013-11-04 23:50:46 +00:00
Manman Ren
c2188c8328 SIL Serializer: vtable can trigger serialiation of a SILFunction declaration.
Also add serialization of resilience attributes: Fragile, InherentlyFragile
and Resilient. Serialize VTables before SILFunctions because it may trigger
serializations of non-transparent SILFunctions.

Update funcOrOffset and vTableOrOffset when a SILFunction or a VTable is
de-serialized.

rdar://15165644


Swift SVN r9926
2013-11-04 18:17:34 +00:00
Chris Lattner
68af974227 Remove 'axle' related code and build machinery. It turns out that we
will not be pursuing this project in the immediate future.



Swift SVN r9901
2013-11-03 16:04:27 +00:00
Doug Gregor
f342493144 Give every declaration an interface type.
For declarations that aren't generic and aren't in a generic context,
the interface type is the same as the normal type.


Swift SVN r9847
2013-10-31 17:38:42 +00:00
Doug Gregor
6201b72561 Give typealias declarations interface types.
Swift SVN r9781
2013-10-30 04:33:04 +00:00
Doug Gregor
03ebb9e4df Give interface types to subscript declarations.
Swift SVN r9731
2013-10-28 21:33:40 +00:00
Doug Gregor
45c78503b4 Compute interface types for enum elements.
Swift SVN r9710
2013-10-28 17:20:44 +00:00
Doug Gregor
9ea280e822 Assign interface types to instance variables/properties of generic types.
Swift SVN r9688
2013-10-26 03:02:36 +00:00
Doug Gregor
d7a1d536b4 Introduce value witness markers into the generic set of requirements.
Value witness markers note the location within a generic function
type's list of requirements where the value witness table will be
placed when calling a generic function with that type. It allows one
to get the same effect from walking the requirements of a generic
function that one would get from walking all levels of a
GenericParamList, with all archetypes of each generic parameter list,
along with all of the protocols to which each archetype conforms,
which SILGen and IRGen both do.

AST verification ensures that the property above holds; we're not
making use of it just yet.


Swift SVN r9509
2013-10-19 00:19:01 +00:00
Joe Groff
5721bdda01 Don't pretend we can parse enum case refined types.
There's no way we'll be able to fully implement GADTs anytime soon.

Swift SVN r9477
2013-10-18 01:34:25 +00:00
Jordan Rose
7277b129b5 [serialization] Handle @transparent on constructors and extensions as well.
Thanks for catching this, Dmitri and Joe.

Swift SVN r9354
2013-10-15 18:02:49 +00:00