mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[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
This commit is contained in:
@@ -757,6 +757,10 @@ ModuleFile::ModuleFile(llvm::OwningPtr<llvm::MemoryBuffer> &&input)
|
||||
assert(scratch.empty());
|
||||
SourcePaths.push_back(blobData);
|
||||
break;
|
||||
case input_block::IMPORTED_MODULE:
|
||||
assert(scratch.empty());
|
||||
Dependencies.push_back(blobData);
|
||||
break;
|
||||
default:
|
||||
// Unknown input kind, possibly for use by a future version of the
|
||||
// module format.
|
||||
@@ -885,6 +889,30 @@ ModuleFile::ModuleFile(llvm::OwningPtr<llvm::MemoryBuffer> &&input)
|
||||
return error();
|
||||
}
|
||||
|
||||
bool ModuleFile::associateWithModule(Module *module) {
|
||||
assert(!ModuleContext && "already associated with an AST module");
|
||||
assert(Status == ModuleStatus::Valid && "invalid module file");
|
||||
|
||||
ASTContext &ctx = module->Ctx;
|
||||
bool missingDependency = false;
|
||||
for (auto &dependency : Dependencies) {
|
||||
assert(!dependency.Mod && "already loaded?");
|
||||
Identifier ID = ctx.getIdentifier(dependency.Name);
|
||||
// FIXME: Provide a proper source location.
|
||||
dependency.Mod = ctx.getModule(std::make_pair(ID, SourceLoc()));
|
||||
if (!dependency.Mod)
|
||||
missingDependency = true;
|
||||
}
|
||||
|
||||
if (missingDependency) {
|
||||
error(ModuleStatus::MissingDependency);
|
||||
return false;
|
||||
}
|
||||
|
||||
ModuleContext = module;
|
||||
return true;
|
||||
}
|
||||
|
||||
void ModuleFile::buildTopLevelDeclMap() {
|
||||
// FIXME: be more lazy about deserialization by encoding this some other way.
|
||||
for (DeclID ID : RawTopLevelIDs) {
|
||||
|
||||
Reference in New Issue
Block a user