mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Introduce a LoadedModule base class for ClangModule and SerializedModule.
This keeps AST insulated from the various module-loading interfaces, which minimizes special-casing of the differences between ClangModule and the (upcoming) SerializedModule. Swift SVN r5096
This commit is contained in:
@@ -234,8 +234,7 @@ ArrayRef<ExtensionDecl*> Module::lookupExtensions(Type T) {
|
||||
return Cache.getExtensions(T->getCanonicalType());
|
||||
}
|
||||
|
||||
assert(isa<ClangModule>(this));
|
||||
return Ctx.getClangModuleLoader()->lookupExtensions(this, T);
|
||||
return cast<LoadedModule>(this)->lookupExtensions(T);
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
@@ -261,9 +260,8 @@ void Module::lookupValue(AccessPathTy AccessPath, Identifier Name,
|
||||
.lookupValue(AccessPath, Name, LookupKind, *TU, Result);
|
||||
}
|
||||
|
||||
assert(isa<ClangModule>(this));
|
||||
return Ctx.getClangModuleLoader()->lookupValue(this, AccessPath,
|
||||
Name, LookupKind, Result);
|
||||
return cast<LoadedModule>(this)->lookupValue(AccessPath, Name, LookupKind,
|
||||
Result);
|
||||
}
|
||||
|
||||
/// lookupVisibleDecls - Find ValueDecls in the module and pass them to the
|
||||
@@ -395,14 +393,29 @@ void TranslationUnit::clearLookupCache() {
|
||||
freeTUExtensionCachePimpl(ExtensionCachePimpl);
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// LoadedModule Implementation
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
void LoadedModule::lookupValue(AccessPathTy accessPath, Identifier name,
|
||||
NLKind lookupKind,
|
||||
SmallVectorImpl<ValueDecl*> &result) {
|
||||
return Owner.lookupValue(this, accessPath, name, lookupKind, result);
|
||||
}
|
||||
|
||||
ArrayRef<ExtensionDecl*> LoadedModule::lookupExtensions(Type T) {
|
||||
return Owner.lookupExtensions(this, T);
|
||||
}
|
||||
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// ClangModule Implementation
|
||||
//===----------------------------------------------------------------------===//
|
||||
ClangModule::ClangModule(ASTContext &ctx, Component *comp,
|
||||
ClangModule::ClangModule(ASTContext &ctx, ModuleLoader &owner, Component *comp,
|
||||
clang::Module *clangModule)
|
||||
: Module(DeclContextKind::ClangModule,
|
||||
ctx.getIdentifier(clangModule->getFullModuleName()),
|
||||
comp, ctx),
|
||||
: LoadedModule(DeclContextKind::ClangModule,
|
||||
ctx.getIdentifier(clangModule->Name),
|
||||
comp, ctx, owner),
|
||||
clangModule(clangModule)
|
||||
{
|
||||
// Clang modules are always well-formed.
|
||||
|
||||
Reference in New Issue
Block a user