本文整理汇总了C++中SourceFile::clearLookupCache方法的典型用法代码示例。如果您正苦于以下问题:C++ SourceFile::clearLookupCache方法的具体用法?C++ SourceFile::clearLookupCache怎么用?C++ SourceFile::clearLookupCache使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SourceFile
的用法示例。
在下文中一共展示了SourceFile::clearLookupCache方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: performNameBinding
/// performNameBinding - Once parsing is complete, this walks the AST to
/// resolve names and do other top-level validation.
///
/// At this parsing has been performed, but we still have UnresolvedDeclRefExpr
/// nodes for unresolved value names, and we may have unresolved type names as
/// well. This handles import directives and forward references.
void swift::performNameBinding(SourceFile &SF, unsigned StartElem) {
// Make sure we skip adding the standard library imports if the
// source file is empty.
if (SF.ASTStage == SourceFile::NameBound || SF.Decls.empty()) {
SF.ASTStage = SourceFile::NameBound;
return;
}
// Reset the name lookup cache so we find new decls.
// FIXME: This is inefficient.
SF.clearLookupCache();
NameBinder Binder(SF);
SmallVector<std::pair<ImportedModule, ImportOptions>, 8> ImportedModules;
// Do a prepass over the declarations to find and load the imported modules
// and map operator decls.
for (auto D : llvm::makeArrayRef(SF.Decls).slice(StartElem)) {
if (ImportDecl *ID = dyn_cast<ImportDecl>(D)) {
Binder.addImport(ImportedModules, ID);
} else if (auto *OD = dyn_cast<PrefixOperatorDecl>(D)) {
insertOperatorDecl(Binder, SF.PrefixOperators, OD);
} else if (auto *OD = dyn_cast<PostfixOperatorDecl>(D)) {
insertOperatorDecl(Binder, SF.PostfixOperators, OD);
} else if (auto *OD = dyn_cast<InfixOperatorDecl>(D)) {
insertOperatorDecl(Binder, SF.InfixOperators, OD);
}
}
SF.addImports(ImportedModules);
// FIXME: This algorithm has quadratic memory usage. (In practice,
// import statements after the first "chunk" should be rare, though.)
// FIXME: Can we make this more efficient?
SF.ASTStage = SourceFile::NameBound;
verify(SF);
}
示例2: performNameBinding
/// performNameBinding - Once parsing is complete, this walks the AST to
/// resolve names and do other top-level validation.
///
/// At this point parsing has been performed, but we still have
/// UnresolvedDeclRefExpr nodes for unresolved value names, and we may have
/// unresolved type names as well. This handles import directives and forward
/// references.
void swift::performNameBinding(SourceFile &SF, unsigned StartElem) {
SharedTimer timer("Name binding");
// Make sure we skip adding the standard library imports if the
// source file is empty.
if (SF.ASTStage == SourceFile::NameBound || SF.Decls.empty()) {
SF.ASTStage = SourceFile::NameBound;
return;
}
// Reset the name lookup cache so we find new decls.
// FIXME: This is inefficient.
SF.clearLookupCache();
NameBinder Binder(SF);
SmallVector<SourceFile::ImportedModuleDesc, 8> ImportedModules;
// Do a prepass over the declarations to find and load the imported modules
// and map operator decls.
for (auto D : llvm::makeArrayRef(SF.Decls).slice(StartElem)) {
if (auto *ID = dyn_cast<ImportDecl>(D)) {
Binder.addImport(ImportedModules, ID);
} else if (auto *OD = dyn_cast<PrefixOperatorDecl>(D)) {
insertOperatorDecl(Binder, SF.PrefixOperators, OD);
} else if (auto *OD = dyn_cast<PostfixOperatorDecl>(D)) {
insertOperatorDecl(Binder, SF.PostfixOperators, OD);
} else if (auto *OD = dyn_cast<InfixOperatorDecl>(D)) {
insertOperatorDecl(Binder, SF.InfixOperators, OD);
} else if (auto *PGD = dyn_cast<PrecedenceGroupDecl>(D)) {
insertPrecedenceGroupDecl(Binder, SF, PGD);
}
}
SF.addImports(ImportedModules);
SF.ASTStage = SourceFile::NameBound;
verify(SF);
}