本文整理汇总了C++中SgScopeStatement::sage_class_name方法的典型用法代码示例。如果您正苦于以下问题:C++ SgScopeStatement::sage_class_name方法的具体用法?C++ SgScopeStatement::sage_class_name怎么用?C++ SgScopeStatement::sage_class_name使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SgScopeStatement
的用法示例。
在下文中一共展示了SgScopeStatement::sage_class_name方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: while
// SgScopeStatement*
SgNode*
SourceLocationInheritedAttribute::getParentScope() const
{
SgScopeStatement* scope = NULL;
int numberOfScopes = scopeList.size();
// ROSE_ASSERT (numberOfScopes > 0);
// printf ("In SourceLocationInheritedAttribute::getParentScope(): numberOfScopes = %d \n",numberOfScopes);
if (numberOfScopes > 1)
{
scope = scopeList[numberOfScopes-2];
// We don't want to return a for loop statement as a parent scope statement since insert_statement
// is not well defined for such scope statements.
// if (scope->variantT() == V_SgForStatement)
int i = 1;
while (scope->variantT() == V_SgForStatement)
{
ROSE_ASSERT (numberOfScopes-(2+i) >= 0);
scope = scopeList[numberOfScopes-(2+i)];
i++;
}
}
else
{
scope = isSgGlobal( getGlobalScope() );
}
printf ("In SourceLocationInheritedAttribute::getParentScope(): parent scope is %s \n",scope->sage_class_name());
ROSE_ASSERT (scope->variantT() != V_SgForStatement);
ROSE_ASSERT (scope != NULL);
return scope;
}
示例2: isSgScopeStatement
void
FixupAstSymbolTables::visit ( SgNode* node )
{
// DQ (6/27/2005): Output the local symbol table from each scope.
// printf ("node = %s \n",node->sage_class_name());
SgScopeStatement* scope = isSgScopeStatement(node);
if (scope != NULL)
{
#if 0
printf ("AST Fixup: Fixup Symbol Table for %p = %s at: \n",scope,scope->class_name().c_str());
#endif
SgSymbolTable* symbolTable = scope->get_symbol_table();
if (symbolTable == NULL)
{
#if 0
printf ("AST Fixup: Fixup Symbol Table for %p = %s at: \n",scope,scope->class_name().c_str());
scope->get_file_info()->display("Symbol Table Location");
#endif
SgSymbolTable* tempSymbolTable = new SgSymbolTable();
ROSE_ASSERT(tempSymbolTable != NULL);
// name this table as compiler generated! The name is a static member used to store
// state for the next_symbol() functions. It is meaningless to set these.
// tempSymbolTable->set_name("compiler-generated symbol table");
scope->set_symbol_table(tempSymbolTable);
// reset the symbolTable using the get_symbol_table() member function
symbolTable = scope->get_symbol_table();
ROSE_ASSERT(symbolTable != NULL);
// DQ (2/16/2006): Set this parent directly (now tested)
symbolTable->set_parent(scope);
ROSE_ASSERT(symbolTable->get_parent() != NULL);
}
ROSE_ASSERT(symbolTable != NULL);
if (symbolTable->get_parent() == NULL)
{
printf ("Warning: Fixing up symbolTable, calling symbolTable->set_parent() (parent not previously set) \n");
symbolTable->set_parent(scope);
}
ROSE_ASSERT(symbolTable->get_parent() != NULL);
// Make sure that the internal hash table used in the symbol table is also present!
if (symbolTable->get_table() == NULL)
{
// DQ (6/27/2005): There are a lot of these built, perhaps more than we really need!
#if 0
printf ("AST Fixup: Building internal Symbol Table hash table (rose_hash_multimap) for %p = %s at: \n",
scope,scope->sage_class_name());
scope->get_file_info()->display("Symbol Table Location");
#endif
rose_hash_multimap* internalHashTable = new rose_hash_multimap();
ROSE_ASSERT(internalHashTable != NULL);
symbolTable->set_table(internalHashTable);
}
ROSE_ASSERT(symbolTable->get_table() != NULL);
SgSymbolTable::BaseHashType* internalTable = symbolTable->get_table();
ROSE_ASSERT(internalTable != NULL);
// DQ (6/23/2011): Note: Declarations that reference types that have not been seen yet may be placed into the
// wronge scope, then later when we see the correct scope we have a symbol in two or more symbol tables. The
// code below detects and fixes this problem.
// DQ (6/16/2011): List of symbols we need to remove from symbol tables where they are multibily represented.
std::vector<SgSymbol*> listOfSymbolsToRemove;
// DQ (6/12/2011): Fixup symbol table by removing symbols that are not associated with a declaration in the current scope.
int idx = 0;
SgSymbolTable::hash_iterator i = internalTable->begin();
while (i != internalTable->end())
{
// DQ: removed SgName casting operator to char*
// cout << "[" << idx << "] " << (*i).first.str();
ROSE_ASSERT ( (*i).first.str() != NULL );
ROSE_ASSERT ( isSgSymbol( (*i).second ) != NULL );
// printf ("Symbol number: %d (pair.first (SgName) = %s) pair.second (SgSymbol) sage_class_name() = %s \n",
// idx,(*i).first.str(),(*i).second->sage_class_name());
SgSymbol* symbol = isSgSymbol((*i).second);
ROSE_ASSERT ( symbol != NULL );
// We have to look at each type of symbol separately! This is because there is no virtual function,
// the reason for this is that each get_declaration() function returns a different type!
// ROSE_ASSERT ( symbol->get_declaration() != NULL );
switch(symbol->variantT())
{
case V_SgClassSymbol:
{
SgClassSymbol* classSymbol = isSgClassSymbol(symbol);
ROSE_ASSERT(classSymbol != NULL);
ROSE_ASSERT(classSymbol->get_declaration() != NULL);
SgDeclarationStatement* declarationToFindInScope = NULL;
//.........这里部分代码省略.........
示例3: timer
//.........这里部分代码省略.........
printf ("SgTemplateInstantiationMemberFunctionDecl: *i = %p = %s \n",*i,(*i)->unparseToString().c_str());
// Call the AST's copy mechanism
SgShallowCopy shallow;
SgNode * forwardDeclarationNode = templateInstantiationMemberFunctionDeclaration->copy(shallow);
SgTemplateInstantiationMemberFunctionDecl* forwardDeclaration = isSgTemplateInstantiationMemberFunctionDecl(forwardDeclarationNode);
ROSE_ASSERT(forwardDeclaration != NULL);
// find the template declaration of the class contining the member function
SgClassDeclaration* classDeclaration = templateInstantiationMemberFunctionDeclaration->get_class_scope()->get_declaration();
ROSE_ASSERT(classDeclaration != NULL);
SgTemplateInstantiationDecl* templateInstantiationDeclaration = isSgTemplateInstantiationDecl(classDeclaration);
ROSE_ASSERT(templateInstantiationDeclaration != NULL);
SgTemplateDeclaration* templateDeclaration = templateInstantiationDeclaration->get_templateDeclaration();
ROSE_ASSERT (templateDeclaration != NULL);
// Reset the file info object so that we can mark this as compiler generated (copy builds a new Sg_File_Info object)
// ROSE_ASSERT (forwardDeclaration->get_file_info() != NULL);
// forwardDeclaration->set_file_info(new Sg_File_Info(*(forwardDeclaration->get_file_info())));
ROSE_ASSERT(forwardDeclaration->get_file_info() != templateInstantiationMemberFunctionDeclaration->get_file_info());
// Both of these may be set (implemented as bit flags internally)
forwardDeclaration->get_file_info()->setCompilerGenerated();
forwardDeclaration->get_file_info()->setTransformation();
// Remove the shallow copy of the function definition
forwardDeclaration->set_definition(NULL);
// Mark the declaration as a forward declarations
forwardDeclaration->setForward();
// Mark this function as a specialization (should be done within copy function)
// forwardDeclaration->set_specialization(SgTemplateInstantiationMemberFunctionDecl::e_specialization);
ROSE_ASSERT(forwardDeclaration->isSpecialization() == true);
ROSE_ASSERT(forwardDeclaration->isPartialSpecialization() == false);
// Now insert the forwardDeclaration after the templateDeclaration!
// templateDeclaration.insert_statement(forwardDeclaration,true);
SgScopeStatement* templateDeclarationScope = templateDeclaration->get_scope();
ROSE_ASSERT (templateDeclarationScope != NULL);
printf ("BEFORE loop: Insert before: templateDeclarationScope = %p = %s \n",templateDeclarationScope,templateDeclarationScope->sage_class_name());
// Trace back through the scopes to find a non class declaration scope into which to put the forward declaration
// Does this then work with nested template classes?????
while (isSgTemplateInstantiationDefn(templateDeclarationScope) != NULL)
{
templateDeclarationScope = templateDeclarationScope->get_scope();
printf ("In loop templateDeclarationScope = %p = %s \n",templateDeclarationScope,templateDeclarationScope->sage_class_name());
}
ROSE_ASSERT (templateDeclarationScope != NULL);
printf ("AFTER loop: Insert before: templateDeclarationScope = %p = %s \n",templateDeclarationScope,templateDeclarationScope->sage_class_name());
templateDeclaration->get_file_info()->display("templateDeclaration");
templateDeclarationScope->get_file_info()->display("templateDeclarationScope");
int insertBeforeStatement = false;
// printf ("Calling templateDeclarationScope->insert_statement() \n");
// templateDeclaration->insert_statement ( templateDeclaration, forwardDeclaration, insertBeforeStatement );
SgTemplateInstantiationDefn *templateClassDefinition = isSgTemplateInstantiationDefn(templateDeclarationScope);
if (templateClassDefinition != NULL)
{
SgDeclarationStatementPtrList::iterator start = templateClassDefinition->get_members().begin();
SgDeclarationStatementPtrList::iterator end = templateClassDefinition->get_members().end();
printf ("templateDeclaration unparsed = %s \n",templateDeclaration->unparseToString().c_str());
printf ("templateDeclaration name = %s string = %s \n",
templateDeclaration->get_name().str(),templateDeclaration->get_string().str());
for (SgDeclarationStatementPtrList::iterator i = start; i != end; i++)
{
string s = (*i)->unparseToString();
printf ("(*i)->unparseToString() = %s \n",s.c_str());
}
ROSE_ASSERT(find(start,end,templateInstantiationMemberFunctionDeclaration) != end);
templateDeclarationScope->insert_statement ( templateInstantiationMemberFunctionDeclaration, forwardDeclaration, insertBeforeStatement );
}
else
{
// ROSE_ASSERT(find(templateDeclarationScope->get_members().begin(),templateDeclarationScope->get_members().end(),templateDeclaration) != templateDeclarationScope->get_members().end() );
templateDeclarationScope->insert_statement ( templateDeclaration, forwardDeclaration, insertBeforeStatement );
}
printf ("forwardDeclaration = %s \n",forwardDeclaration->unparseToString().c_str());
// printf ("DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD \n");
// printf ("Exiting after construction of forward declaration for template instantiation! \n");
// ROSE_ASSERT (false);
}
else
{
// This is a forward declaration (does it have the template arguments!)
printf ("SgTemplateInstantiationMemberFunctionDecl: (forward) *i = %p = %s \n",*i,(*i)->unparseToString().c_str());
}
#endif
i++;
}
}