mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[serialization] Lazily load top-level decls, extensions, and operators.
This switches from simple lists of decls to name-based on-disk hash tables, which allows decls to be loaded lazily when doing simple lookup (but not code completion, at least not yet). The on-disk hash table implementation is borrowed from Clang; eventually it will be pushed down to LLVM's Support library. (Fortunately the implementation is header-only.) This breaks a few tests that rely on magic protocols like IntegerLiteralConvertible, because the type checker won't have seen the types that conform to those protocols yet. This will be fixed by doing an additional "hey, modules, got any of these?" lookup. Swift SVN r7259
This commit is contained in:
@@ -137,8 +137,8 @@ Module *SerializedModuleLoader::loadModule(SourceLoc importLoc,
|
||||
}
|
||||
assert(inputFile);
|
||||
std::string DebugModuleName = inputFile->getBufferIdentifier();
|
||||
|
||||
llvm::OwningPtr<ModuleFile> loadedModuleFile;
|
||||
|
||||
std::unique_ptr<ModuleFile> loadedModuleFile;
|
||||
ModuleStatus err = ModuleFile::load(std::move(inputFile), loadedModuleFile);
|
||||
switch (err) {
|
||||
case ModuleStatus::FallBackToTranslationUnit:
|
||||
@@ -169,7 +169,8 @@ Module *SerializedModuleLoader::loadModule(SourceLoc importLoc,
|
||||
if (loadedModuleFile) {
|
||||
bool success = loadedModuleFile->associateWithModule(module);
|
||||
if (success) {
|
||||
LoadedModuleFiles.push_back(std::move(loadedModuleFile));
|
||||
LoadedModuleFiles.emplace_back(std::move(loadedModuleFile),
|
||||
Ctx.getCurrentGeneration());
|
||||
} else {
|
||||
assert(loadedModuleFile->getStatus() == ModuleStatus::MissingDependency);
|
||||
|
||||
@@ -260,3 +261,13 @@ SerializedModuleLoader::lookupVisibleDecls(const Module *module,
|
||||
|
||||
moduleFile->lookupVisibleDecls(accessPath, consumer, lookupKind);
|
||||
}
|
||||
|
||||
void SerializedModuleLoader::loadExtensions(NominalTypeDecl *nominal,
|
||||
unsigned previousGeneration) {
|
||||
for (auto &modulePair : LoadedModuleFiles) {
|
||||
if (modulePair.second <= previousGeneration)
|
||||
continue;
|
||||
modulePair.first->loadExtensions(nominal);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user