Commit Graph

188 Commits

Author SHA1 Message Date
Joe Groff
df53d4bd80 Summon the eldritch horror "EagerDeserializationDecls" from the bowels of history.
Adding explicit constructors to Clang-imported structs in the previous commits exposes a latent phase ordering issue between the Clang importer and SIL deserialization. Deserializing the standard library SIL ends up pulling in additional Clang decls which never get type-checked before we attempt to emit their code. Work around this by bringing back the "EagerDeserializedDecls" block in the serialization format, and adding any cross-referenced decls that get referenced in SILSerializeAll mode to it, so that we ensure they're available before SILGen. We also have to type-check external decls after doing so, since when only importing a module, we wouldn't do any type-checking at all otherwise.

Swift SVN r23728
2014-12-05 05:31:25 +00:00
Michael Gottesman
9311672c33 Move ModuleFile.h, ModuleFormat.h, and DeclTypeRecordNodes.def to include/swift/Serialization.
This allows for a secondary tool to access the deserialized Module inside the SerializedASTFile's ModuleFile.

Swift SVN r14173
2014-02-20 22:03:55 +00:00
Joe Groff
0bafd1f084 Bump module format version.
Swift SVN r14110
2014-02-19 22:53:54 +00:00
Doug Gregor
a1673d7c8f Add an Objective-C metatype representation spelled with @objc_metatype.
This representation is just a placeholder at the moment.


Swift SVN r14076
2014-02-19 07:21:38 +00:00
Doug Gregor
c54f98fbc9 Convert thick/thin metatype bool to an enumeration. NFC
Swift SVN r14075
2014-02-19 06:05:48 +00:00
Doug Gregor
8bc87bbe1e fromRaw() witnesses can only be synthesized when the raw type is Equatable.
Swift SVN r14067
2014-02-19 01:09:43 +00:00
Chris Lattner
28903887e7 Rename the internal compiler lexicon from let -> val.
Swift SVN r13992
2014-02-17 16:48:21 +00:00
Dmitri Hrybenko
571c9b3c5e Split 'type' keyword into 'static' and 'class'
rdar://15911697


Swift SVN r13908
2014-02-14 14:50:32 +00:00
Doug Gregor
1fa4612eb8 Implement (de-)serialization for open_existential[_ref].
Swift SVN r13898
2014-02-14 05:01:18 +00:00
Dave Abrahams
5063c33cbb Rename "Stream" protocol back to "Generator"
The name Stream didn't seem to be working out as intended; we kept
gravitating back to calling it Generator, which is precedented in other
languages.  Also, Stream seems to beg for qualification as Input or
Output.  I think we'd like to reserve Stream for things that are more
bulk-character-API-ish.

Swift SVN r13893
2014-02-14 01:48:52 +00:00
Chris Lattner
a6640a1b12 Rework has .sil files handle computed vardecls and subscripts.
Previously, we would just parse vars and subscripts with no definitions,
then let getters and setters be referenced arbitrarily later.  This was
problematic for a number of reasons, not least of which, the .sil file
might be invalid.

Instead, change sil to require that a protocol style definition indicate
whether a vardecl/subscript is computed or not, and whether it is both 
get-able and set-able, e.g. like "var x : Int { get }".  Change the 
sil printer to print decls in this form, and change the SILParser to 
make SILDeclRef::Func values instead of ::Getter/Setter values.

One thing that this exposed is that we weren't correctly serializing the
accessor state in modules, so accessors would get detatched from their
AbstractStorageDecls when deserialized (and in fact, their ASD never got
deserialized at all in some cases).  Fix this in the serialization of
the accessors.

NFC, other than the SIL printer and parser.



Swift SVN r13884
2014-02-14 00:57:04 +00:00
Jordan Rose
f7977e6807 [serialization] Reject modules with a different version number.
From now on, /any/ changes to SIL or AST serialization must increment
VERSION_MINOR in ModuleFormat.h.

The original intent of VERSION_MAJOR/VERSION_MINOR was that VERSION_MAJOR
would only increment when backwards-incompatible changes are introduced,
and VERSION_MINOR merely indicates whether to expect additional information.
However, the module infrastructure currently isn't forgiving enough to accept
even backwards-compatible changes to the record schemas, and the SIL
serialization design might not be compatible with that at all.

So for now, treat any version number 0.x as incompatible with any other 0.y.
We can bump to 1 when we hit stability.

<rdar://problem/15494343>

Swift SVN r13841
2014-02-12 21:33:45 +00:00
Joe Groff
b19cfb27ea Drop the context generic params from SILFunctionType.
SILFunctionType is now 100% context free!

Swift SVN r13775
2014-02-11 04:21:20 +00:00
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