Turn SerializedModule into SerializedASTFile.

Part of the FileUnit restructuring. A serialized module is now represented as
a TranslationUnit containing a single SerializedASTFile.

As part of this change, the FileUnit interface has been made virtual, rather
than switching on the Kind in every accessor. We think the operations
performed on files are sufficiently high-level that this shouldn't affect us.

A nice side effect of all this is that we now properly model the visibility
of modules imported into source files. Previously, we would always consider
the top-level imports of all files within a target, whether re-exported or
not.

We may still end up wanting to distinguish properties of a complete Swift
module file from a partial AST file, but we can do that within
SerializedModuleLoader.

Swift SVN r10832
This commit is contained in:
Jordan Rose
2013-12-05 01:51:09 +00:00
parent d0d661164d
commit 8b8cc8ee62
30 changed files with 634 additions and 600 deletions

View File

@@ -85,66 +85,11 @@ public:
MemoryBuffers[AccessPath].reset(input.release());
}
/// \brief Look for declarations associated with the given name.
///
/// \param module The module to search.
///
/// \param accessPath The access path used to refer to the name within this
/// (top-level) module.
///
/// \param name The name we're searching for.
///
/// \param lookupKind Whether we're performing qualified vs. unqualified
/// lookup.
///
/// \param result Will be populated with the results of name lookup.
virtual void lookupValue(const Module *module,
Module::AccessPathTy accessPath, Identifier name,
NLKind lookupKind,
SmallVectorImpl<ValueDecl*> &result) override;
/// \brief Look for a declaration of the given operator.
///
/// \returns The operator decl, or null if this module does not define the
/// operator in question.
virtual OperatorDecl *lookupOperator(Module *module, Identifier name,
DeclKind fixity) override;
virtual void getImportedModules(
const Module *module,
SmallVectorImpl<Module::ImportedModule> &imports,
bool includePrivate) override;
virtual void lookupVisibleDecls(const Module *module,
Module::AccessPathTy accessPath,
VisibleDeclConsumer &consumer,
NLKind lookupKind) override;
virtual void lookupClassMembers(const Module *module,
Module::AccessPathTy accessPath,
VisibleDeclConsumer &consumer) override;
virtual void lookupClassMember(const Module *module,
Module::AccessPathTy accessPath,
Identifier name,
SmallVectorImpl<ValueDecl*> &results) override;
virtual void loadExtensions(NominalTypeDecl *nominal,
unsigned previousGeneration) override;
virtual void loadDeclsConformingTo(KnownProtocolKind kind,
unsigned previousGeneration) override;
virtual void getLinkLibraries(const Module *module,
Module::LinkLibraryCallback callback) override;
virtual void getTopLevelDecls(const Module *Module,
SmallVectorImpl<Decl*> &Results) override;
virtual void getDisplayDecls(const Module *module,
SmallVectorImpl<Decl*> &results) override;
StringRef getModuleFilename(const Module *Module) override;
};
/// Describes whether a loaded module can be used.