本文整理汇总了C++中AST::getImport方法的典型用法代码示例。如果您正苦于以下问题:C++ AST::getImport方法的具体用法?C++ AST::getImport怎么用?C++ AST::getImport使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AST
的用法示例。
在下文中一共展示了AST::getImport方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: assert
bool C2Builder::checkModuleImports(ParseHelper& helper, Component* component, Module* module, ImportsQueue& queue, const LibInfo* lib) {
if (!module->isLoaded()) {
assert(lib);
if (options.verbose) log(COL_VERBOSE, "parsing (%s) %s", component->getName().c_str(), lib->c2file.c_str());
if (!helper.parse(*component, module, lib->c2file, (options.printAST0 && options.printASTLib))) {
return false;
}
}
if (options.verbose) log(COL_VERBOSE, "checking imports for module (%s) %s", component->getName().c_str(), module->getName().c_str());
bool ok = true;
const AstList& files = module->getFiles();
for (unsigned a=0; a<files.size(); a++) {
AST* ast = files[a];
for (unsigned u=1; u<ast->numImports(); u++) { // NOTE: first import is module decl
ImportDecl* D = ast->getImport(u);
const std::string& targetModuleName = D->getModuleName();
// handle c2 pseudo-module
if (targetModuleName == "c2") {
createC2Module();
D->setModule(c2Mod);
continue;
}
const LibInfo* target = libLoader.findModuleLib(targetModuleName);
if (!target) {
helper.Diags.Report(D->getLocation(), clang::diag::err_unknown_module) << targetModuleName;
ok = false;
continue;
}
D->setModule(target->module);
if (target->component != component) {
// check that imports are in directly dependent component (no indirect component)
if (!component->hasDep(target->component)) {
helper.Diags.Report(D->getLocation(), clang::diag::err_indirect_component)
<< component->getName() << target->component->getName() << targetModuleName;
ok = false;
continue;
}
}
if (target->module->isLoaded()) continue;
queue.push_back(targetModuleName);
}
}
return ok;
}
示例2: writeAST
void DepGenerator::writeAST(const AST& ast, StringBuilder& output, unsigned indent) const {
if (showExternals) {
for (unsigned i=0; i<ast.numImports(); i++) {
const ImportDecl* U = ast.getImport(i);
QualType Q = U->getType();
const ModuleType* T = cast<ModuleType>(Q.getTypePtr());
const Module* P = T->getModule();
assert(P);
if (P->isExternal()) addExternal(P);
}
}
for (unsigned i=0; i<ast.numTypes(); i++) {
writeDecl(ast.getType(i), output, indent);
}
for (unsigned i=0; i<ast.numVars(); i++) {
writeDecl(ast.getVar(i), output, indent);
}
for (unsigned i=0; i<ast.numFunctions(); i++) {
writeDecl(ast.getFunction(i), output, indent);
}
}