本文整理汇总了C++中SgScopeStatement::lookup_variable_symbol方法的典型用法代码示例。如果您正苦于以下问题:C++ SgScopeStatement::lookup_variable_symbol方法的具体用法?C++ SgScopeStatement::lookup_variable_symbol怎么用?C++ SgScopeStatement::lookup_variable_symbol使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SgScopeStatement
的用法示例。
在下文中一共展示了SgScopeStatement::lookup_variable_symbol方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: name
SgSymbol * ClangToSageTranslator::GetSymbolFromSymbolTable(clang::NamedDecl * decl) {
if (decl == NULL) return NULL;
SgScopeStatement * scope = SageBuilder::topScopeStack();
SgName name(decl->getNameAsString());
#if DEBUG_SYMBOL_TABLE_LOOKUP
std::cerr << "Lookup symbol for: " << name << std::endl;
#endif
if (name == "") {
return NULL;
}
std::list<SgScopeStatement *>::reverse_iterator it;
SgSymbol * sym = NULL;
switch (decl->getKind()) {
case clang::Decl::Typedef:
{
it = SageBuilder::ScopeStack.rbegin();
while (it != SageBuilder::ScopeStack.rend() && sym == NULL) {
sym = (*it)->lookup_typedef_symbol(name);
it++;
}
break;
}
case clang::Decl::Var:
case clang::Decl::ParmVar:
{
it = SageBuilder::ScopeStack.rbegin();
while (it != SageBuilder::ScopeStack.rend() && sym == NULL) {
sym = (*it)->lookup_variable_symbol(name);
it++;
}
break;
}
case clang::Decl::Function:
{
SgType * tmp_type = buildTypeFromQualifiedType(((clang::FunctionDecl *)decl)->getType());
SgFunctionType * type = isSgFunctionType(tmp_type);
ROSE_ASSERT(type);
it = SageBuilder::ScopeStack.rbegin();
while (it != SageBuilder::ScopeStack.rend() && sym == NULL) {
sym = (*it)->lookup_function_symbol(name, type);
it++;
}
break;
}
case clang::Decl::Field:
{
SgClassDeclaration * sg_class_decl = isSgClassDeclaration(Traverse(((clang::FieldDecl *)decl)->getParent()));
ROSE_ASSERT(sg_class_decl != NULL);
if (sg_class_decl->get_definingDeclaration() == NULL)
std::cerr << "Runtime Error: cannot find the definition of the class/struct associate to the field: " << name << std::endl;
else {
scope = isSgClassDeclaration(sg_class_decl->get_definingDeclaration())->get_definition();
// TODO: for C++, if 'scope' is in 'SageBuilder::ScopeStack': problem!!!
// It means that we are currently building the class
while (scope != NULL && sym == NULL) {
sym = scope->lookup_variable_symbol(name);
scope = scope->get_scope();
}
}
break;
}
case clang::Decl::CXXRecord:
case clang::Decl::Record:
{
it = SageBuilder::ScopeStack.rbegin();
while (it != SageBuilder::ScopeStack.rend() && sym == NULL) {
sym = (*it)->lookup_class_symbol(name);
it++;
}
break;
}
case clang::Decl::Label:
{
// Should not be reach as we use Traverse to retrieve Label (they are "terminal" statements) (it avoids the problem of forward use of label: goto before declaration)
name = SgName(((clang::LabelDecl *)decl)->getStmt()->getName());
it = SageBuilder::ScopeStack.rbegin();
while (it != SageBuilder::ScopeStack.rend() && sym == NULL) {
sym = (*it)->lookup_label_symbol(name);
it++;
}
break;
}
case clang::Decl::EnumConstant:
{
name = SgName(((clang::EnumConstantDecl *)decl)->getName());
it = SageBuilder::ScopeStack.rbegin();
while (it != SageBuilder::ScopeStack.rend() && sym == NULL) {
sym = (*it)->lookup_enum_field_symbol(name);
it++;
}
break;
}
case clang::Decl::Enum:
{
name = SgName(((clang::EnumDecl *)decl)->getName());
//.........这里部分代码省略.........