Commit Graph

114 Commits

Author SHA1 Message Date
Jordan Rose
dbf41543f5 [serialization] Add support for TupleTypes.
These are implementing using trailing TUPLE_TYPE_ELT records after the
initial TUPLE_TYPE record. This is the next step towards function decls.

Element initializers are silently ignored for now.

Also, do serialize a record for IdentifierTypes, even though we're not
including the components yet, so that we don't serialize the underlying
type more than once.

Swift SVN r5683
2013-06-19 18:19:41 +00:00
Jordan Rose
ce84b185ea [serialization] Add support for ParenType.
This is a simple wrapper type. It was trivial to implement.

Swift SVN r5682
2013-06-19 18:19:35 +00:00
Jordan Rose
eb8657f2ac [serialization] Unique identifiers and serialize them into a blob table.
This removes the egregious NAME_HACK records that trailed various named
decls, and replaces them with proper identifier IDs. The identifiers
themselves are serialized into a blob as null-terminated strings, with no
particular optimization (i.e. no substring matching or anything). We can
revisit this format later, but this at least allows identifiers to be
referenced inline within a record, which will be much more convenient for
function parameter patterns (upcoming).

Swift SVN r5638
2013-06-18 00:32:56 +00:00
Jordan Rose
44cde3ae0a [serialization] Serialize DeclContexts, VarDecls, and StructTypes.
Unlike Clang, Swift's DeclContexts are not all Decls. However, I believe
each DeclContext that is /serialized/ will be either a decl, a
TranslationUnit, or a FuncExpr for a function with an actual declaration.
This might turn out to be wrong if (a) SIL needs proper DeclContexts for
variables in function bodies, or (b) we need to serialize anonymous
closure default arguments.

Along with an extension of the ConstructorDecl placeholder code, this allows
us to round-trip empty structs.

Swift SVN r5532
2013-06-08 00:18:24 +00:00
Jordan Rose
8bd38abdff [serialization] Blaze a straight-line path for no-arg constructors.
Ignore everything else. Unfortunately, even this requires VarDecls...

Swift SVN r5531
2013-06-08 00:18:22 +00:00
Jordan Rose
413b2ae485 [serialization] Sketch out struct serialization.
This serializes structs, but not any of their members. Unfortunately, all
structs have members (the implicit constructor at the very least), so this
doesn't actually do anything at all and is completely untested.

Immediate goal: round-tripping an empty struct.

Swift SVN r5530
2013-06-08 00:18:21 +00:00
Jordan Rose
c8958a232e Replace PointerIntUnion with a PointerUnion-compatible Fixnum type.
Per discussion on swift-dev, we'd prefer to have a "pointer-like" integer
with limited bit width, to reuse all the existing infrastructure for
pointer-like types, rather than invent another new data structure.

Swift SVN r5529
2013-06-08 00:18:19 +00:00
Jordan Rose
7a13e58b38 [serialization] Hook up basic name lookup for imported modules.
Also, explicitly list the top-level decls in a module. Eventually this
will be a proper lazily-loaded identifier-DeclID map, but for now it's
just a flat list of IDs to deserialize as soon as a lookup is
requested.

We can now parse and typecheck a file that imports typealiases of builtin
types.

Swift SVN r5325
2013-05-25 01:34:57 +00:00
Jordan Rose
76b19d53c4 [serialization] Deserialize typealiases and builtin types.
This includes the reading half of BCRecordLayout metaprogramming, and
then a fairly straightforward deserialize-and-cache implementation in
ModuleFile. Once again, this is based on Clang's module implementation:
decls and types are referred to by an ID, which is used as an index into
an array, which contains offsets to the definitions of the decl/type in
the "decls-and-types" block in the serialized module.

In order to test the feature, the code is currently eagerly deserializing
all declarations. This will be partially fixed in the next commit.

Swift SVN r5324
2013-05-25 01:34:56 +00:00
Jordan Rose
9b712a2fe9 [serialization] Remove skeleton for sharing module decl/type IDs.
Clang modules have a clever way to share decl and type IDs, by saying
"this range of IDs comes from this other module". Swift modules have to
be resilient, however, and so this is not a viable solution.

We still use 0 as a special ID for null decls and types, when applicable.

Swift SVN r5323
2013-05-25 01:34:55 +00:00
Jordan Rose
965035dc2a [serialization] Load the decl and type offset arrays from the module.
...but don't do anything with them yet. This does check that they're being
correctly serialized, though.

This introduces a new ADT, PointerIntUnion, which like PointerUnion is an
efficient variant type using the lowest bit of data as a discriminator.
By default, the union can store any pointer-bits-minus-one-sized integer,
but both the integer type and the underlying storage type can be
customized.

Swift SVN r5321
2013-05-25 01:34:52 +00:00
Jordan Rose
ea0d5031ab [serialization] Codify the bringup hack with a special note in the module file.
The bringup hack, again, is to just process the module source files as a
TranslationUnit if the module doesn't accurately represent the original
source. Currently this happens if the module is not empty, or if it imports
/anything/, since we don't actually serialize anything yet.

This also cleans up the decl/type serialization skeleton a bit.

Swift SVN r5238
2013-05-20 22:50:39 +00:00
Jordan Rose
f9c4046896 [serialization] Validate the control block -- is the module too new?
Not so interesting right now, but eventually we'll be validating other
things as well, and it's best not to have FIXMEs lying around.

Swift SVN r5175
2013-05-16 00:23:13 +00:00
Jordan Rose
3109d8c830 [serialization] Pull bitstream processing of modules into its own file.
Like Clang, ModuleFile contains state about reading the serialized module,
while SerializedModuleLoader takes the place of ASTReader in tracking
cross-module data. I'm diverging from Clang's architecture a bit here by
pushing the actual deserialization logic into ModuleFile.

No functionality change.

Swift SVN r5174
2013-05-16 00:23:11 +00:00