Commit Graph

171 Commits

Author SHA1 Message Date
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
960141eb8e [serialization] Don't keep a ModuleFile around when missing dependencies.
All we need is the skeleton Module to let us know not to try again. This
was previously leading to a use-after-free, caught by Guard Malloc.
Thanks, Argyrios!

Swift SVN r6267
2013-07-15 18:36:22 +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
Dmitri Hrybenko
cb98234d67 Allow the parser to persist after parseIntoTranslationUnit() returns
Swift SVN r6102
2013-07-10 00:25:37 +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
764dff4bc6 [serialization] Add the HasBuiltinModuleAccess hack to fallback modules too.
This only affects people with SWIFT_USE_LIBRARY_MODULES turned on, i.e. me.

Swift SVN r5956
2013-07-01 23:10:10 +00:00
Chris Lattner
1c0a1c4953 Every client that does type checking also does name binding. Doug wants to pull the later into
the former anyway, so simplify the clients by not exposing name binding to them.


Swift SVN r5903
2013-06-30 18:05:21 +00:00
Chris Lattner
c03d4454a0 implement support for a new [stdlib] attribute that can be slapped on an import decl.
This causes the SourceLoader to recursively parse the imported module in standard 
library mode, giving it access to the Builtin module.

This is all a terrible hack and should be ripped out with great victory someday, but 
until we have binary modules that persist the build setting used to produce the 
module, this is the best we can do.



Swift SVN r5847
2013-06-27 21:31:15 +00:00
Jordan Rose
0e4f6c6a12 [serialization] Record dependencies on other modules.
When loading a module, we now try to load its dependencies as well.
If one of those dependencies can't be loaded, we emit an error message.

Swift SVN r5796
2013-06-25 00:47:48 +00:00
Chris Lattner
e8bf1dd6f5 expand the TranslationUnit kind to handle "standard library", and
plumb it through the compiler a bit.  This simplifies some code
in the driver, but should not induce any behavior change (yet).


Swift SVN r5740
2013-06-21 17:42:37 +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
6a0609d169 Use .swiftmodule instead of .sm for serialized modules.
We can bikeshed on this later, but for now we can use a very explicit
extension that has no chance of stepping on any existing extension.

Swift SVN r5239
2013-05-20 22:50:40 +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
Doug Gregor
8114ce16f8 Use the list of extensions of a nominal type for name lookup into that type.
This replaces the obscure, inefficient lookup into extensions with
something more straightforward: walk all of the known extensions
(available as a simple list), then eliminate any declarations that
have been shadowed by other declarations. The shadowing rules still
need to consider the module re-export DAG, but we'll leave that for
later.

As part of this, keep track of the last time we loaded extensions for
a given nominal type. If the list of extensions is out-of-date with
respect to the global generation count (which tracks resolved module
imports), ask the modules to load any additional extensions. Only the
Clang module importer can currently load extensions in this manner.


Swift SVN r5223
2013-05-20 18:06:51 +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
Jordan Rose
ebcff9685f [serialization] Hook up a module loader that just builds a TranslationUnit.
The writer stores the paths to the .swift files, the reader just loads
those .swift files. Fun!

No version validation yet. No separate ModuleReader class yet. No use of
the SerializedModule architecture yet, except for creating a dummy module
when the .sm file is corrupted.

Swift SVN r5164
2013-05-13 21:41:23 +00:00
Jordan Rose
b8cf3497a2 [serialization] Change file signature to something non-ASCII.
Based on feedback by Doug. This signature is fairly arbitrary: it's the
UTF-8 encoding of U+2828 SPARKLES, followed by the number 14 to represent
2014. (Hopefully the format will have stabilized by 2014.)

(Why not 0x00 or 0x01 for the last byte? Because it's more likely we'll
collide with someone else being cute. Why not 0x0D / 13? Because that's
\r and could conceivably appear in real Unicode text. No one uses 0x0E
these days.)

Swift SVN r5134
2013-05-09 22:58:08 +00:00
Jordan Rose
1d2dfdb498 [serialization] Push record layout info into a private header.
The reader and writer will need to share this information, but there's no
reason anyone else will need it.

Swift SVN r5133
2013-05-09 22:58:07 +00:00
Jordan Rose
73b6269484 [serialization] Add a trivial Swift module loader.
Currently, the Swift module loader just looks for a .sm file, verifies the
signature "SMod", and produces an empty DeclContext.

Swift SVN r5126
2013-05-09 20:49:29 +00:00