mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Accept swiftmodule files on the command line as partial AST inputs.
Each loaded file gets added to the main module, rather than being a standalone separate module. In theory, this will be used to assemble several partial ASTs into a complete module. In practice, there's still a ways to go...but this can already round-trip a single module file. This also factors out the FileUnit-creating part of SerializedModuleLoader, which should help clients like SourceKit that don't need to search for a swiftmodule file associated with a particular import. Swift SVN r10952
This commit is contained in:
@@ -54,7 +54,7 @@ class ModuleFile {
|
||||
Module *ShadowedModule = nullptr;
|
||||
|
||||
/// The module file data.
|
||||
llvm::OwningPtr<llvm::MemoryBuffer> InputFile;
|
||||
std::unique_ptr<llvm::MemoryBuffer> InputFile;
|
||||
|
||||
/// The reader attached to InputFile.
|
||||
llvm::BitstreamReader InputReader;
|
||||
@@ -175,7 +175,7 @@ private:
|
||||
ModuleStatus Status;
|
||||
|
||||
/// Constructs an new module and validates it.
|
||||
ModuleFile(llvm::OwningPtr<llvm::MemoryBuffer> &&input);
|
||||
ModuleFile(std::unique_ptr<llvm::MemoryBuffer> input);
|
||||
|
||||
/// Convenience function for module loading.
|
||||
void error(ModuleStatus issue = ModuleStatus::Malformed) {
|
||||
@@ -251,7 +251,7 @@ public:
|
||||
/// \param[out] module The loaded module.
|
||||
/// \returns Whether the module was successfully loaded, or what went wrong
|
||||
/// if it was not.
|
||||
static ModuleStatus load(llvm::OwningPtr<llvm::MemoryBuffer> &&input,
|
||||
static ModuleStatus load(std::unique_ptr<llvm::MemoryBuffer> input,
|
||||
std::unique_ptr<ModuleFile> &module) {
|
||||
module.reset(new ModuleFile(std::move(input)));
|
||||
return module->getStatus();
|
||||
@@ -390,51 +390,6 @@ public:
|
||||
maybeReadConformance(Type conformingType, llvm::BitstreamCursor &Cursor);
|
||||
};
|
||||
|
||||
/// A file-unit loaded from a serialized AST file.
|
||||
class SerializedASTFile final : public LoadedFile {
|
||||
public:
|
||||
ModuleFile &File;
|
||||
|
||||
SerializedASTFile(Module &M, ModuleFile &file)
|
||||
: LoadedFile(FileUnitKind::SerializedAST, M), File(file) {}
|
||||
|
||||
virtual void lookupValue(Module::AccessPathTy accessPath,
|
||||
Identifier name, NLKind lookupKind,
|
||||
SmallVectorImpl<ValueDecl*> &results) const override;
|
||||
|
||||
virtual OperatorDecl *lookupOperator(Identifier name,
|
||||
DeclKind fixity) const override;
|
||||
|
||||
virtual void lookupVisibleDecls(Module::AccessPathTy accessPath,
|
||||
VisibleDeclConsumer &consumer,
|
||||
NLKind lookupKind) const override;
|
||||
|
||||
virtual void lookupClassMembers(Module::AccessPathTy accessPath,
|
||||
VisibleDeclConsumer &consumer) const override;
|
||||
|
||||
virtual void
|
||||
lookupClassMember(Module::AccessPathTy accessPath, Identifier name,
|
||||
SmallVectorImpl<ValueDecl*> &decls) const override;
|
||||
|
||||
virtual void getTopLevelDecls(SmallVectorImpl<Decl*> &results) const override;
|
||||
|
||||
virtual void
|
||||
getImportedModules(SmallVectorImpl<Module::ImportedModule> &imports,
|
||||
bool includePrivate) const override;
|
||||
|
||||
virtual void
|
||||
collectLinkLibraries(Module::LinkLibraryCallback callback) const override;
|
||||
|
||||
virtual StringRef getFilename() const override;
|
||||
|
||||
static bool classof(const FileUnit *file) {
|
||||
return file->getKind() == FileUnitKind::SerializedAST;
|
||||
}
|
||||
static bool classof(const DeclContext *DC) {
|
||||
return isa<FileUnit>(DC) && classof(cast<FileUnit>(DC));
|
||||
}
|
||||
};
|
||||
|
||||
} // end namespace swift
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user