Commit Graph

581 Commits

Author SHA1 Message Date
Jordan Rose
3087e8d5ea Add the notion of "re-exported" modules, and use that where it makes sense.
Rather than automatically re-exporting or not re-exporting every import in
a TranslationUnit, we'll eventually want to control which imports are local
(most of them) and which imports are shared with eventual module loaders.
It's probably not worth implementing this for TranslationUnit, but
LoadedModule can certainly do something here.

Currently, a LoadedModule is even more permissive than a TranslationUnit:
all imports are re-exported. We can lock down on this once we have a
re-export syntax.

Swift SVN r6523
2013-07-23 23:10:17 +00:00
Jordan Rose
110d644297 Provide a skeleton for re-exports from serialized modules...
...and use it for shadowed modules (e.g. the Clang module "Foundation"
referenced by the Swift module "Foundation"), so that we can actually
find "NSString" when building AppKit.

Additionally, record shadowed modules as dependencies, so that they can
be loaded when the adapter module is loaded.

Swift SVN r6522
2013-07-23 23:10:13 +00:00
Jordan Rose
3e606010ee [serialization] Silence an unused variable warning in Release builds.
Swift SVN r6520
2013-07-23 23:10:08 +00:00
Jordan Rose
6547b9790a [serialization] Allow references to Clang-imported values.
This unfortunately duplicates the hack of directly referencing the Clang
module loader if a cross-reference points to the current module; ideally
we'd have some kind of module chain, but I'd settle for a refactoring of
the code to share with NameBinding.

Additionally, Clang nodes are not actually validated to be from the right
module, which could be problematic for extensions or any case of actual
name collision.

Swift SVN r6519
2013-07-23 23:10:05 +00:00
Jordan Rose
36138474d1 [serialization] Fix another cursor-clobbering mistake.
When reading trailing records, make sure we don't go off and read something
else in the mean time...

Swift SVN r6518
2013-07-23 23:10:02 +00:00
Jordan Rose
b619a125a1 [serialization] Make sure accessors are correctly associated with a subscript.
Trivial fix. Undetected for a long time because most accesses go from
subscript to accessors, rather than the other way around.

Swift SVN r6517
2013-07-23 23:10:00 +00:00
Jordan Rose
be6c5b3707 [serialization] Preserve the implicit bit for patterns.
This is used by code completion to determine if curried
arguments are implicit, e.g. for method calls.

Swift SVN r6516
2013-07-23 23:09:56 +00:00
Jordan Rose
5689d1a4a4 [serialization] Set the type of the FuncExpr in a FuncDecl.
Swift SVN r6515
2013-07-23 23:09:53 +00:00
Joe Groff
10f290a01d AST: Add slot for substitutions for generic witnesses.
If a protocol requirement is satisfied by a generic method, we'll need to save the substitutions necessary to call that method from the witness thunk. This patch adds the spot in the ProtocolConformance::Mapping to save the substitutions; for now, always leave it empty and update the code for the type change.

Swift SVN r6399
2013-07-20 00:08:43 +00:00
Anna Zaks
74bc6f05b2 Add "noreturn" attribute : stage 1
- Add the attribute to AnyFunctionType::ExtInfo.
- Propagate the attributes from DeclAttributes to AnyFunctionType for
  FuncDecls in TypeCheckDecl.cpp.
- Make sure the new attribute is serialized.

The main missing pieces are checking the applicability of the type attributes
on the FuncDecl and teaching typechecker about conversions on types with
noreturn.

Swift SVN r6359
2013-07-18 22:57:22 +00:00
Anna Zaks
92e07c6a54 Use ExtInfo struct to pass around call related info in FunctionType and PolymorphicFunctionType getters.
Swift SVN r6358
2013-07-18 22:57:21 +00:00
Doug Gregor
ad1a9ac2c3 Eliminate default argument expressions from the type system.
Elements of a tuple type now know if there is a default argument, and
what kind of default argument it is (callee side, __FILE__, __LINE__,
__COLUMN__), but they don't have an actual expression. There are a
number of cleanups this enables that will follow. 

Note that the serialization support is as-yet-untested.


Swift SVN r6351
2013-07-18 18:49:32 +00:00
Argyrios Kyrtzidis
7476762dae Remove IdentifierType from the type system.
Swift SVN r6327
2013-07-17 14:57:38 +00:00
Jordan Rose
87689d1c84 [serialization] Handle references to generic parameters.
Generic parameters are implemented using specially-tagged TypeAliasDecls.
Unlike normal ValueDecls, their names are not resilient, and so cross-
module references shouldn't refer to them by name. Instead, use an index
into the generic parameter list of their context.

Since generic parameters can appear within extensions, this new kind isn't
mutually exclusive with the just-introduced ExtensionValue. Change that to
be a separate flag that applies to both Values and GenericParameters.

Swift SVN r6304
2013-07-16 23:10:56 +00:00
Jordan Rose
c15653f645 [serialization] Add support for asmname.
We were actually ignoring this completely because DeclAttributes::isEmpty
wasn't taking them into account.

Swift SVN r6302
2013-07-16 23:10:43 +00:00
Jordan Rose
6e4f36cab2 [serialization] Handle cross-module references to values in extensions.
Previously, cross-references used a simple access path to refer to values
in other modules, but extensions have no name. They also accidentally
picked up values in extensions anyway, because lookupDirect includes
members in extensions. Now, we filter out values that don't come from
the referenced module, which may not be the same module the base type
comes from.

Swift SVN r6301
2013-07-16 23:10:33 +00:00
Doug Gregor
423abc5038 Codify the default argument hack for __FILE__/__LINE__/__COLUMN__.
Teach TuplePatternElt to keep track of the kind of the default
argument: none, normal (provided by calling into the appropriate
callee generator), __FILE__, __LINE__, or __COLUMN__. For the latter
three cases, the type checker forms the appropriate argument as part
of the call. 

The actual default argument expression will only be held in the tuple
pattern element when we've parsed it; it won't be serialized or
deserialized, because only the defining module cares. This is a step
toward eliminate the initialization expression from tuple types.

The extension to TupleShuffleExpr is a hack, which will also be
replicated in ScalarToTupleExpr, until we finally rework the
representation of TupleShuffleExpr (<rdar://problem/12340004>).


Swift SVN r6299
2013-07-16 22:52:38 +00:00
Argyrios Kyrtzidis
37dc84e13c Remove VarargBaseType from TuplePatternElt and introduce a bit in TuplePattern to indicate if there is a vararg.
The semantics of varargs (only for the last element) make it more appropriate as a property of the TuplePattern.
Also free the Parser from needing to construct synthetic types (ArraySlice for type of vararg element) to
accommodate the TypeChecker and move the logic to the TypeChecker. This will be more beneficial when the parser stops
creating types in general.

Swift SVN r6271
2013-07-15 20:21:30 +00:00
Jordan Rose
4376b1aa93 [serialization] Serialize protocols alongside conformances.
Turns out the typechecker uses these for resolving literals and such.

Swift SVN r6244
2013-07-13 19:37:14 +00:00
Jordan Rose
c01b7fb2fd [serialization] Fix another scary use of stack memory.
...instead of ASTContext-allocated memory.

Swift SVN r6243
2013-07-13 19:37:05 +00:00
Jordan Rose
1712ee6661 [serialization] Handle overloaded decls.
Swift SVN r6230
2013-07-13 00:03:14 +00:00
Jordan Rose
9a180ea9c6 [serialization] Relax assertions to allow reentrant deserialization.
As long as we don't create an entity twice, it's actually okay to be
re-entrant. This makes it simpler to deserialize members -- trying to
do so will deserialize the parent instead, which will then initialize
each of the members including the one that was asked for.

Swift SVN r6228
2013-07-12 23:29:57 +00:00
Jordan Rose
4db68ed617 [serialization] Record nominal types in the module table ASAP.
Deserializing a nominal decl often ends up referring to the nominal's type,
so if we're /already/ serializing the type, we should finish that as soon
as we have a decl. Accomplish this by adding a callback that is called
right after a nominal decl is recorded in the module's decl table, so that
the type can be immediately recorded as well.

Swift SVN r6227
2013-07-12 23:29:45 +00:00
Argyrios Kyrtzidis
b7817e4879 Remove VarargBaseTy field from TupleTypeElt.
Use a bit to indicate whether the element is a vararg one and infer the
VarargBase type via the element type.

Swift SVN r6220
2013-07-12 22:24:31 +00:00
Joe Groff
d956fdbd9e Update 'oneof' syntax.
Give oneof bodies syntax consistent with other NominalTypes. Give oneof elements first-class declaration syntax using the 'case' introducer, as suggested by Jordan. Oneofs can contain 'case' decls, functions, properties, and constructors, but not physical ivars. Non-oneof scopes cannot contain 'case' decls. Add some QoI to the oneof 'case' parser to also parse and complain about things that resemble switch 'case' labels inside decl contexts.

Swift SVN r6211
2013-07-12 20:42:19 +00:00
Jordan Rose
c699b84cfa [serialization] Add support for destructors.
With this commit, we can now serialize all of stdlib_core!
(Deserializing still has a few issues.)

Swift SVN r6188
2013-07-11 23:35:34 +00:00
Jordan Rose
e0301b6037 [serialization] Add support for UnboundGenericTypes.
I had previously thought these didn't appear in public decls, but they're
used when you extend a generic class without generic arguments.

Swift SVN r6187
2013-07-11 23:35:25 +00:00
Jordan Rose
37d9ae4e09 [serialization] Add support for extensions.
Currently, we are eagerly deserializing extensions. This probably isn't
what we want to do in the long run, but until lookup settles down a bit
it's not worth optimizing.

Swift SVN r6186
2013-07-11 23:35:19 +00:00
Jordan Rose
d1163afb4b [serialization] Add support for [conversion] methods.
Take advantage of the fact that a function can never be both a conversion
method and an assignment operator to pack both flags into the same bit in
the serialized record.

Swift SVN r6185
2013-07-11 23:35:12 +00:00
Jordan Rose
0afaa86bcc [serialization] Add support for subscript decls.
For consistency purposes, VarDecls in the subscript pattern now have the
enclosing nominal as their decl context, rather than no decl context at all.

Swift SVN r6177
2013-07-11 21:22:08 +00:00
Jordan Rose
9b7ae1aa50 [serialization] Handle archetypes unified by a constraint.
Turns out we actually have to serialize the name of an archetype, because
it may be different from the declaration in a context where it has been
unified with another archetype. Found on attempting to emit a module for
the standard library.

(This is actually the commit that uses the two-container for_each
introduced in the last commit.)

Swift SVN r6172
2013-07-11 21:12:46 +00:00
Jordan Rose
e3999dde36 [serialization] Handle absent protocol conformances.
These still need to be serialized, because they are one-to-one with the
type's protocol list, but don't actually require any data. Found on
attempting to emit a module for the standard library.

Most of the churn here is moving Interleave.h to a more general STLExtras.h.

Swift SVN r6167
2013-07-11 18:38:50 +00:00
Doug Gregor
bb2046c37b (De-)serialized ProtocolConformance::DefaultedDefinitions.
Swift SVN r6166
2013-07-11 18:34:03 +00:00
Jordan Rose
ca6f08164f [serialization] Add support for oneofs.
Since SILGen support is so poor, the test just uses -parse.

Swift SVN r6136
2013-07-10 23:26:00 +00:00
Jordan Rose
1564fa7f10 [serialization] Fix potential fall-off-the-end issues.
The way llvm::BitstreamCursor works is that reading an end-of-block
code will pop the current block off the stack, along with all its
record abbreviation codes. This means we’d no longer know how to
read any records. Fix this by telling the cursor not to auto-pop blocks
any time we’re doing a tentative read.

Swift SVN r6135
2013-07-10 23:25:52 +00:00
Jordan Rose
b4fe4f098c [serialization] Handle computed properties with a getter /and/ setter.
Since accessor FuncDecl have a backreference to the VarDecl they are
attached to, we were getting re-entrant deserialization issues. Fix
this by just not serializing the backreference and relying on the
property being deserialized first.

Swift SVN r6134
2013-07-10 23:25:39 +00:00
Jordan Rose
9a67bc597e [serialization] Add support for classes.
Classes are exactly like structs except that they may have a base class.
However, this type will show up in the inheritance list. That means we
don't actually need to serialize it twice; we can just grab the base class
from the inheritance list.

Swift SVN r6133
2013-07-10 23:25:34 +00:00
John McCall
f4f164cb9e Add deserialization and stable encodings for ReferenceStorageType.
Jordan, please review.

Swift SVN r6111
2013-07-10 09:00:36 +00:00
Jordan Rose
ad9875c19e [serialization] Add support for ArrayTypes.
...in a quest for completeness. ArrayTypes don't actually work yet
(single-dimensional arrays are typed as slices), but when they do the test
that is currently XFAIL'd should start passing.

With this, all non-transient types can now be serialized and deserialized.

Swift SVN r6101
2013-07-09 23:45:46 +00:00
Jordan Rose
fdd5b36dfc [serialization] Handle fixity and assignment function attributes.
With this change we should be able to round-trip all of Policy.swift.

Swift SVN r6085
2013-07-09 00:45:05 +00:00
Jordan Rose
aa230234eb [serialization] Remove "isNeverLValue" flag.
This isn't worth serializing; any public decl can't meaningfully use this flag.

Swift SVN r6084
2013-07-09 00:44:56 +00:00
Jordan Rose
bec3b0a216 [serialization] Add support for infix operators.
Swift SVN r6081
2013-07-09 00:02:15 +00:00
Jordan Rose
2b0e969647 [serialization] Use lookupDirect to resolve cross-references to members.
...and add a test for this.

Also, fix a cursor invalidation bug for TypeAliasDecl deserialization.

Swift SVN r6079
2013-07-08 23:41:14 +00:00
Jordan Rose
929d86bb16 [serialization] Add support for prefix and postfix operators.
This includes adding an operator lookup table to ModuleFile. Operators are
keyed by a (name, fixity) pair.

Swift SVN r6078
2013-07-08 23:41:06 +00:00
Jordan Rose
03f7c3ef2c [serialization] Add support for slice types and variadic functions.
This is the first time reaching the case where the module refers to a type
that also appears in the TU and tries to modify it. This shouldn't be a
problem for any of the other types we currently serialize besides
BoundGenericType and ArraySliceType because we either don't try to modify
them after creation or are guaranteed a new type object.

Swift SVN r6060
2013-07-08 19:57:04 +00:00
Jordan Rose
aa2d1b2a64 [serialization] Handle PolymorphicFunctionTypes more carefully.
PolymorphicFunctionTypes are built on GenericParamLists, which are
owned by decls that introduce generic parameters. This made deserializing
them a pain, because they /cannot/ be recreated in isolation -- the decl
provides some context. Rather than try to come up with a very generic way
to serialize these, this patch just records the GenericParamList of every
decl, allowing the type to be serialized with a reference to the decl
instead of to the param list. Deserialization can then just pluck the list
back out of the decl.

According to Doug and Joe, PolymorphicFunctionType's due for a refresh
anyway, so this kind of hackery / kludgery is acceptable.

With this change, we can now handle generic structs and generic functions
inside generic structs.

Swift SVN r6032
2013-07-06 00:20:04 +00:00
Jordan Rose
eb9a1feaf3 [serialization] Handle oneof and class types (but not decls).
This allows us to reference Bool.

Swift SVN r6030
2013-07-06 00:19:40 +00:00
Jordan Rose
ce9c5c1d13 [serialization] Add support for generic structs (and constructors).
Swift SVN r5989
2013-07-04 00:20:38 +00:00
Jordan Rose
820c5a1404 [serialization] Serialize conformances for typealiases and protocols too.
Swift SVN r5988
2013-07-04 00:20:34 +00:00
Jordan Rose
0054e58935 [serialization] Serialize protocol conformances instead of ignoring them.
For some reason this didn't actually affect any testing, but it's going to
be necessary very soon.

Swift SVN r5987
2013-07-04 00:20:31 +00:00