本文整理汇总了C++中SgLocatedNode::get_file_info方法的典型用法代码示例。如果您正苦于以下问题:C++ SgLocatedNode::get_file_info方法的具体用法?C++ SgLocatedNode::get_file_info怎么用?C++ SgLocatedNode::get_file_info使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SgLocatedNode
的用法示例。
在下文中一共展示了SgLocatedNode::get_file_info方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: visit
void visit ( SgNode* astNode )
{
SgLocatedNode* locatedNode = isSgLocatedNode(astNode);
if (locatedNode != NULL)
{
locatedNode->get_file_info()->setTransformation();
locatedNode->get_file_info()->setOutputInCodeGeneration();
// Uncomment to see the source position information for each SgLocatedNode IR node.
// locatedNode->get_file_info()->display("markAsTransformation(): debug");
}
}
示例2: filename
AST_Graph::nodePartOfGraph::result_type
AST_Graph::nodePartOfGraph::operator()(pair<SgNode*,std::string>& x)
{
result_type functionalReturn;
functionalReturn.addToGraph = true;
functionalReturn.DOTOptions = "";
functionalReturn.DOTLabel = "";
SgLocatedNode* locatedNode = isSgLocatedNode(x.first);
if(locatedNode!=NULL)
{
Sg_File_Info* fileInfo = locatedNode->get_file_info();
std::string filename(Rose::utility_stripPathFromFileName(fileInfo->get_filename()));
if (filename.find("rose_edg_required_macros_and_functions.h") != std::string::npos)
{
functionalReturn.addToGraph = false;
}
if (fileInfo->isCompilerGenerated()==true)
{
// std::cout << "Is compiler generated\n";
functionalReturn.addToGraph = false;
}
}
return functionalReturn;
}
示例3: isSgLocatedNode
void
WalrusGraph::OutputNodes::visit ( SgNode* astNode )
{
int numberOfNodes = node_to_index_map.size();
static int num = 0;
SgLocatedNode* locatedNode = isSgLocatedNode(astNode);
if ((isBinary == true) || (locatedNode != NULL && locatedNode->get_file_info()->isFrontendSpecific() == false))
{
// if (node_to_index_map[astNode] < numberOfNodes-2);
if (num < numberOfNodes-1)
{
printf (" { @id=%d; @value=T; }",node_to_index_map[astNode]);
*outputFilePtr << " { @id=" << node_to_index_map[astNode] << "; @value=T; }";
if (num < numberOfNodes-2)
{
printf (",");
*outputFilePtr << ",";
}
printf ("\n");
*outputFilePtr << endl;
}
num++;
}
}
示例4: unparseMacroCalls
//Replace the unparsing of expanded macro calls with the actual macro call wherever possible
void unparseMacroCalls(SgNode* searchTree)
{
//Traverse AST to find all macro calls and the nodes they are attached to
findPreprocInfo findPre;
findPre.traverse(searchTree, preorder);
std::vector< std::pair<SgNode*, PreprocessingInfo*> >& wherePreprocIsAttached = findPre.wherePreprocIsAttached;
//Replace expanded macro calls with actual macro call from pre-cpp wherever possible
for( std::vector< std::pair<SgNode*, PreprocessingInfo*> >::iterator iItr = wherePreprocIsAttached.begin();
iItr != wherePreprocIsAttached.end(); ++iItr)
{
SgStatement* currentNode = isSgStatement( (*iItr).first );
PreprocessingInfo* curPreproc = (*iItr).second;
ROSE_ASSERT(currentNode != NULL);
std::vector<SgNode*> matchingSubTree;
if ( matchMacroToSubtrees(currentNode->get_scope(), curPreproc, matchingSubTree) )
{
for(unsigned int i = 0; i < matchingSubTree.size(); i++)
{
SgLocatedNode* macroNode = isSgLocatedNode(matchingSubTree[i]);
ROSE_ASSERT(macroNode != NULL);
std::string replacementString = ( i ==0 ? curPreproc->getString() : "" );
if( isSgExpression(macroNode) == NULL )
{
#ifndef USE_ROSE
#ifndef ROSE_SKIP_COMPILATION_OF_WAVE
// If we are using ROSE to compile ROSE source code then the Wave support is not present.
PreprocessingInfo::rose_macro_call* macroCall = curPreproc->get_macro_call();
if(macroCall->expanded_macro.size() > 0 && boost::wave::token_id(macroCall->expanded_macro.back()) != boost::wave::T_COLON)
replacementString +=";";
#endif
#endif
}
std::cout << "Doing line replacement " << macroNode->unparseToString() << " with " << replacementString << std::endl;
#if 0
std::string pos;
curPreproc->display(pos);
std::cout << macroNode->class_name() << " "<< pos << std::endl;
#endif
macroNode->addToAttachedPreprocessingInfo(new PreprocessingInfo(PreprocessingInfo::LineReplacement,
replacementString,macroNode->get_file_info()->get_filenameString(),1,1,1,PreprocessingInfo::before));
}
};
}
};
示例5: getStartPos
source_position roseNode::getStartPos() const
{
source_position pos;
ROSE_ASSERT(mNode!=NULL);
SgLocatedNode* lnode = isSgLocatedNode(mNode);
if (lnode != NULL)
{
pos.line = lnode->get_file_info()->get_line();
pos.column= lnode->get_file_info()->get_col();
}
else
{
pos.line=0;
pos.column=0;
}
return pos;
}
示例6: visit
void visit(SgNode *node) {
SgLocatedNode *located = isSgLocatedNode(node);
if (located) {
fix(located, located->get_file_info());
fix(located, located->generateMatchingFileInfo());
fix(located, located->get_startOfConstruct());
fix(located, located->get_endOfConstruct());
}
}
示例7: preOrderVisit
// Start marking nodes as frontend-specific once we enter an AST that's frontend-specific.
void preOrderVisit(SgNode *node) {
SgLocatedNode *located = isSgLocatedNode(node);
if (located) {
bool in_fes_ast = fes_ast!=NULL ||
is_frontend_specific(located->get_file_info()) ||
is_frontend_specific(located->generateMatchingFileInfo()) ||
is_frontend_specific(located->get_startOfConstruct()) ||
is_frontend_specific(located->get_endOfConstruct());
if (in_fes_ast) {
if (!fes_ast)
fes_ast = node;
fix(located, located->get_file_info());
fix(located, located->generateMatchingFileInfo());
fix(located, located->get_startOfConstruct());
fix(located, located->get_endOfConstruct());
}
}
}
示例8: isSgLocatedNode
void
visitorTraversal::visit (SgNode * n)
{
// On each node look for any comments of CPP directives
SgLocatedNode *locatedNode = isSgLocatedNode (n);
if (locatedNode != NULL)
{
AttachedPreprocessingInfoType *comments =
locatedNode->getAttachedPreprocessingInfo ();
if (comments != NULL)
{
printf ("-----------------------------------------------\n");
printf ("Found an IR node with preprocessing Info attached:\n");
printf ("(memory address: %p Sage type: %s) in file \n%s (line %d column %d) \n",
locatedNode,
locatedNode->class_name ().c_str (),
(locatedNode->get_file_info ()->get_filenameString ()).c_str (),
locatedNode->get_file_info ()->get_line(),
locatedNode->get_file_info ()->get_col() );
int counter = 0;
AttachedPreprocessingInfoType::iterator i;
for (i = comments->begin (); i != comments->end (); i++)
{
printf("-------------PreprocessingInfo #%d ----------- : \n",counter++);
printf("classification = %s:\n String format = %s\n",
PreprocessingInfo::directiveTypeName((*i)->getTypeOfDirective ()). c_str (),
(*i)->getString ().c_str ());
printf ("relative position is = ");
if ((*i)->getRelativePosition () == PreprocessingInfo::inside)
printf ("inside\n");
else
printf ("%s\n", \
((*i)->getRelativePosition () == PreprocessingInfo::before) ? "before" : "after");
}
}
}
}
示例9: filename
//The argument to the function is
filterOnNodes::result_type
filterOnNodes::operator()(filterOnNodes::argument_type x) const
{
AST_Graph::FunctionalReturnType returnValue;
//Determine if the node is to be added to the graph. true=yes
returnValue.addToGraph = true;
//set colors etc. for the graph Node
returnValue.DOTOptions = "shape=polygon,regular=0,URL=\"\\N\",tooltip=\"more info at\\N\",sides=4,peripheries=1,color=\"Blue\",fillcolor=green,fontname=\"7x13bold\",fontcolor=black,style=filled";
if( isSgProject(x.first) != NULL )
returnValue.DOTOptions = "shape=ellipse,regular=0,URL=\"\\N\",tooltip=\"more info at\\N\",sides=4,peripheries=1,color=\"Blue\",fillcolor=yellow,fontname=\"7x13bold\",fontcolor=black,style=filled";
//Filter out SgSymbols from the graph
if ( isSgSymbol(x.first) != NULL )
returnValue.addToGraph = false;
if ( isSgType(x.first) != NULL )
returnValue.addToGraph = false;
//Filter out compiler generated nodes
SgLocatedNode* locatedNode = isSgLocatedNode(x.first);
if ( locatedNode != NULL )
{
Sg_File_Info* fileInfo = locatedNode->get_file_info();
std::string filename(Rose::utility_stripPathFromFileName(fileInfo->get_filename()));
if (filename.find("rose_edg_macros_and_functions_required_for_gnu.h") != std::string::npos)
{
returnValue.addToGraph = false;
}
if (fileInfo->isCompilerGenerated()==true)
{
// std::cout << "Is compiler generated\n";
returnValue.addToGraph = false;
}
}
return returnValue;
}
示例10:
string
AstPDFGeneration_private::get_bookmark_name(SgNode* node)
{
string nodefilename="--not initialized--";
string bookmarktext;
{
ostringstream ss;
ss << node->sage_class_name() << " ";
SgLocatedNode* sgLocNode = dynamic_cast<SgLocatedNode*> (node);
if(sgLocNode)
{
Sg_File_Info* fi = sgLocNode->get_file_info();
if(fi)
{
// ss << "(" << fi->get_line() << "," << fi->get_col() << ") in \"" << fi->get_filename() << "\"";
// nodefilename=string(fi->get_filename());
#if 1
// if (fi->isCompilerGenerated())
// ss << " compilerGenerated ";
if (fi->isTransformation())
ss << " transformation " ;
if (fi->isOutputInCodeGeneration())
ss<< " unparsable ";
ss << "(" << fi->get_line() << "," << fi->get_col() << ") in \"" << fi->get_filename() << "\"";
#endif
nodefilename=string(fi->get_filename());
}
else
{
ss << "(BUG)";
}
}
else
{
ss << ""; // provide no explicit info about the lack of file_info
}
bookmarktext=ss.str();
}
return bookmarktext;
}
示例11: instrumentClassDeclarationIntoTopOfAllSourceFiles
SgClassDeclaration* RtedTransformation::instrumentClassDeclarationIntoTopOfAllSourceFiles(
SgProject* project, SgClassDeclaration* classDecl) {
// **********************
if (RTEDDEBUG) cerr <<"@@@ instrumenting into top "<< endl;
// deep copy the classdecl and make it unparseable
SgClassDeclaration* cd_copy = SageInterface::deepCopy(classDecl);
// cout << ">>>>>> Original ClassType :::: " << classDecl->get_type() << endl;
// cout << ">>>>>> Copied ClassType :::: " << cd_copy->get_type() << endl;
// SgClassType* type_copy = new SgClassType(cd_copy);
//cd_copy->set_type(type_copy);
ROSE_ASSERT(cd_copy);
const SgNodePtrList& nodes2 = NodeQuery::querySubTree(cd_copy, V_SgLocatedNode);
SgNodePtrList::const_iterator nodesIT2 = nodes2.begin();
for (; nodesIT2 != nodes2.end(); ++nodesIT2) {
SgLocatedNode* node = isSgLocatedNode(*nodesIT2);
ROSE_ASSERT(node);
Sg_File_Info* file_info = node->get_file_info();
file_info->setOutputInCodeGeneration();
//cerr << "copying node : " << node->class_name() << endl;
}
if (RTEDDEBUG) cerr << "deep copy of firstnondefining" << endl;
SgClassDeclaration* nondefDecl = isSgClassDeclaration(classDecl->get_firstNondefiningDeclaration());
SgClassDeclaration* cdn_copy = SageInterface::deepCopy(nondefDecl);
ROSE_ASSERT(cdn_copy);
const SgNodePtrList& nodes = NodeQuery::querySubTree(cdn_copy, V_SgLocatedNode);
SgNodePtrList::const_iterator nodesIT = nodes.begin();
for (; nodesIT != nodes.end(); ++nodesIT) {
SgLocatedNode* node = isSgLocatedNode(*nodesIT);
ROSE_ASSERT(node);
Sg_File_Info* file_info = node->get_file_info();
file_info->setOutputInCodeGeneration();
}
cd_copy->set_firstNondefiningDeclaration(cdn_copy);
SgClassType* cls_type = SgClassType::createType(cdn_copy);
cls_type->set_declaration(cdn_copy);
ROSE_ASSERT(cls_type != NULL);
ROSE_ASSERT (cls_type->get_declaration() == cdn_copy);
cdn_copy->set_type(cls_type);
cdn_copy->set_definingDeclaration(cd_copy);
cd_copy->set_type(cdn_copy->get_type());
if (RTEDDEBUG) {
cerr << "@@@@@@@@@@@@@@ Original Class classDecl : " << classDecl << " :: " << cd_copy << endl;
cerr << "@@@@@@@@@@@@@@ Original Class nondefining : " << classDecl->get_firstNondefiningDeclaration()<< " :: " << cdn_copy << endl;
cerr << "@@@@@@@@@@@@@@@@@@ TYPE OF cd_copy->get_type() : " << cd_copy->get_type() << endl;
cerr << "@@@@@@@@@@@@@@@@@@ TYPE OF cdn_copy->get_type() : " << cdn_copy->get_type() << endl;
cerr << "@@@@@@@@@@@@@@@@@@ TYPE OF cd_copy->get_type()->declaration : " <<cd_copy->get_type()->get_declaration() << endl;
cerr << "@@@@@@@@@@@@@@@@@@ TYPE OF cd_copy->definingDeclaration : " << cd_copy->get_definingDeclaration() << endl;
cerr << "@@@@@@@@@@@@@@@@@@ TYPE OF cd_copy->set_firstNondefiningDeclaration : " << cd_copy->get_firstNondefiningDeclaration() << endl;
}
// **********************
// add to top of each source file
// insert at top of all source files in reverse order
// only if the class has private members and if it is declared in a header file
std::vector<SgSourceFile*>::const_iterator aa = srcfiles.begin();
std::vector<SgSourceFile*>::const_iterator zz = srcfiles.end();
for (; aa != zz; ++aa)
{
SgSourceFile* sf = *aa;
assert( isInInstrumentedFile(sf) );
if (RTEDDEBUG) cerr << "Looking through sourcefile: " << sf -> get_file_info() -> get_filename() << endl;
// once we have the new class_decl inserted, we remove all functions and the constructor and destructor
const SgNodePtrList& remNodes = NodeQuery::querySubTree(cd_copy, V_SgFunctionDeclaration);
SgNodePtrList::const_iterator remNodesIt = remNodes.begin();
for (; remNodesIt != remNodes.end(); ++remNodesIt) {
SgFunctionDeclaration* node = isSgFunctionDeclaration(*remNodesIt);
ROSE_ASSERT(node);
SageInterface::removeStatement(node);
}
if (RTEDDEBUG) cerr << " changing privates to public" << endl;
// change each private: to public:
SgClassDefinition* cd_def = cd_copy->get_definition();
ROSE_ASSERT(cd_def);
SgDeclarationStatementPtrList decls = cd_def->get_members();
SgDeclarationStatementPtrList::const_iterator itDecls = decls.begin();
for (;itDecls!=decls.end();++itDecls) {
SgVariableDeclaration* node = isSgVariableDeclaration(*itDecls);
if (node) {
SgDeclarationModifier& mod = node->get_declarationModifier();
SgAccessModifier& am = mod.get_accessModifier();
if (am.isPrivate() || am.isProtected())
am.setPublic();
}
}
// get the namespace RTED to put new class into
if (RTEDDEBUG) cerr << "Finding Namespace RTED " << endl;
SourceFileRoseNMType::const_iterator pit = sourceFileRoseNamespaceMap.find(sf);
ROSE_ASSERT(pit!=sourceFileRoseNamespaceMap.end());
SgNamespaceDeclarationStatement* firstNamespace = pit->second;
// insert at top of file - after includes
//.........这里部分代码省略.........
示例12: isSgDeclarationStatement
void
AstPDFGeneration_private::edit_page(size_t pageNumber, SgNode* node, PDFInheritedAttribute inheritedValue)
{
// JW (added by DQ 7/23/2004): Adds address of each IR node to the top of the page
HPDF_Page_SetRGBFill(currentPage, 1, 0, 0);
// DQ (1/20/2006): Modified for 64 bit machines
// ostringstream _ss; _ss << "0x" << std::hex << (int)node;
ostringstream _ss;
_ss << "pointer:" << std::hex << node;
HPDF_Page_ShowTextNextLine(currentPage, _ss.str().c_str());
// Liao, 2/11/2009, move some essential information from bookmark into the page also
// since some deep levels of bookmarks cannot display long lines properly by acrobat reader
HPDF_Page_ShowTextNextLine(currentPage, node->sage_class_name());
SgLocatedNode* sgLocNode = dynamic_cast<SgLocatedNode*> (node);
if(sgLocNode)
{
Sg_File_Info* fi = sgLocNode->get_file_info();
ostringstream temp;
temp<<fi->get_filename()<<" "<<fi->get_line()<<":"<<fi->get_col();
if(fi)
HPDF_Page_ShowTextNextLine(currentPage,temp.str().c_str());
if (fi->isTransformation())
HPDF_Page_ShowTextNextLine(currentPage,"IsTransformation:1");
else
HPDF_Page_ShowTextNextLine(currentPage,"IsTransformation:0");
if (fi->isOutputInCodeGeneration())
HPDF_Page_ShowTextNextLine(currentPage,"IsOutputInCodeGeneration:1");
else
HPDF_Page_ShowTextNextLine(currentPage,"IsOutputInCodeGeneration:0");
}
if (isSgDeclarationStatement(node))
{
HPDF_Page_ShowTextNextLine(currentPage, ("Declaration mangled name: " + isSgDeclarationStatement(node)->get_mangled_name().getString()).c_str());
#if 0 // not necessary, p_name field gives the similar information
if (isSgDeclarationStatement(node)->hasAssociatedSymbol())
{
SgSymbol *symbol = isSgDeclarationStatement(node)->get_symbol_from_symbol_table ();
if (symbol)
HPDF_Page_ShowTextNextLine(currentPage, ("Symbol name: " + symbol->get_name().getString()).c_str());
}
#endif
}
// JW hack to show expression types
if (isSgExpression(node))
HPDF_Page_ShowTextNextLine(currentPage, ("Expression type: " + isSgExpression(node)->get_type()->unparseToString()).c_str());
HPDF_Page_SetRGBFill(currentPage, 0, 1, 0);
if (inheritedValue.parentPage==NULL)
{
HPDF_Page_ShowTextNextLine(currentPage, "");
HPDF_Page_ShowTextNextLine(currentPage, " root node");
}
else
{
HPDF_Page_ShowTextNextLine(currentPage, "");
HPDF_Page_ShowTextNextLine(currentPage, " ");
create_textlink("Click here to go to the parent node", inheritedValue.parentPage, 9);
}
HPDF_Page_ShowTextNextLine(currentPage, "");
HPDF_Page_ShowTextNextLine(currentPage, "");
// generate RTI information for SgNode
{
RTIReturnType rti=node->roseRTI();
for(RTIReturnType::iterator i=rti.begin(); i<rti.end(); i++)
{
if (strlen(i->type) >= 7 &&
strncmp(i->type, "static ", 7) == 0) {
continue; // Skip static members
}
HPDF_Page_SetRGBFill(currentPage, 0.5, 0, 0.1);
HPDF_Page_ShowTextNextLine(currentPage, i->type);
HPDF_Page_ShowText(currentPage, " ");
HPDF_Page_SetRGBFill(currentPage, 0.0, 0.5, 0.5);
HPDF_Page_ShowText(currentPage, i->name);
HPDF_Page_ShowText(currentPage, " : ");
HPDF_Page_SetRGBFill(currentPage, 0.0, 0.0, 0.0);
string value=i->value;
if (value.size() >= 80) { // HPDF doesn't like strings > 64k, and we probably shouldn't be trying to print them anyway; this trims things to a reasonable length
value = "<too long>: " + value.substr(0, 80);
}
if (value.size() >= 80) {
value = "<too long>: " + value.substr(0, 80);
}
AstNodeVisitMapping::MappingType::iterator mapit;
// ensure that mapping value exists (otherwise it would be added to the map)
// and decide whether to create a link to a page (representing a node) or not
mapit=addrPageMapping.find(value);
if (mapit!=addrPageMapping.end())
{
size_t destPageNum = mapit->second;
ROSE_ASSERT (destPageNum < pageDests.size());
//.........这里部分代码省略.........
示例13: printf
void
TransformationSupport::getTransformationOptions ( SgNode* astNode, list<OptionDeclaration> & generatedList, string identifingTypeName )
{
// This function searches for variables of type ScopeBasedTransformationOptimization. Variables
// of type ScopeBasedTransformationOptimization are used to communicate optimizations from the
// application to the preprocessor. If called from a project or file object it traverses down to
// the global scope of the file and searches only the global scope, if called from and other
// location within the AST it searches the current scope and then traverses the parent nodes to
// find all enclosing scopes until in reaches the global scope. At each scope it searches for
// variables of type ScopeBasedTransformationOptimization.
// printf ("######################### START OF TRANSFORMATION OPTION QUERY ######################## \n");
ROSE_ASSERT (astNode != NULL);
ROSE_ASSERT (identifingTypeName.c_str() != NULL);
#if 0
printf ("In getTransformationOptions(): astNode->sage_class_name() = %s generatedList.size() = %d \n",
astNode->sage_class_name(),generatedList.size());
SgLocatedNode* locatedNode = isSgLocatedNode(astNode);
if (locatedNode != NULL)
{
printf (" locatedNode->get_file_info()->get_filename() = %s \n",locatedNode->get_file_info()->get_filename());
printf (" locatedNode->get_file_info()->get_line() = %d \n",locatedNode->get_file_info()->get_line());
}
#endif
switch (astNode->variant())
{
case ProjectTag:
{
SgProject* project = isSgProject(astNode);
ROSE_ASSERT (project != NULL);
//! Loop through all the files in the project and call the mainTransform function for each file
int i = 0;
for (i=0; i < project->numberOfFiles(); i++)
{
SgFile* file = &(project->get_file(i));
// printf ("Calling Query::traverse(SgFile,QueryFunctionType,QueryAssemblyFunctionType) \n");
getTransformationOptions ( file, generatedList, identifingTypeName );
}
break;
}
case SourceFileTag:
{
SgSourceFile* file = isSgSourceFile(astNode);
ROSE_ASSERT (file != NULL);
SgGlobal* globalScope = file->get_globalScope();
ROSE_ASSERT (globalScope != NULL);
ROSE_ASSERT (isSgGlobal(globalScope) != NULL);
getTransformationOptions ( globalScope, generatedList, identifingTypeName );
break;
}
// Global Scope
case GLOBAL_STMT:
{
SgGlobal* globalScope = isSgGlobal(astNode);
ROSE_ASSERT (globalScope != NULL);
SgSymbolTable* symbolTable = globalScope->get_symbol_table();
ROSE_ASSERT (symbolTable != NULL);
getTransformationOptions ( symbolTable, generatedList, identifingTypeName );
// printf ("Processed global scope, exiting .. \n");
// ROSE_ABORT();
break;
}
case SymbolTableTag:
{
// List the variable in each scope
// printf ("List all the variables in this symbol table! \n");
SgSymbolTable* symbolTable = isSgSymbolTable(astNode);
ROSE_ASSERT (symbolTable != NULL);
bool foundTransformationOptimizationSpecifier = false;
// printf ("Now print out the information in the symbol table for this scope: \n");
// symbolTable->print();
#if 0
// I don't know when a SymbolTable is given a name!
printf ("SymbolTable has a name = %s \n",
(symbolTable->get_no_name()) ? "NO: it has no name" : "YES: it does have a name");
if (!symbolTable->get_no_name())
printf ("SymbolTable name = %s \n",symbolTable->get_name().str());
else
ROSE_ASSERT (symbolTable->get_name().str() == NULL);
#endif
if (symbolTable->get_table() != NULL)
{
SgSymbolTable::hash_iterator i = symbolTable->get_table()->begin();
int counter = 0;
while (i != symbolTable->get_table()->end())
{
//.........这里部分代码省略.........
示例14: isSgLocatedNode
static std::string
sourcePositionInformation (SgNode* node)
{
// DQ (8/31/2013): Adding source position information for DOT output.
string ss;
SgLocatedNode* locatedNode = isSgLocatedNode(node);
if (locatedNode != NULL)
{
Sg_File_Info* fileInfo = locatedNode->get_file_info();
if (fileInfo != NULL)
{
bool hasSpecialMode = false;
if (fileInfo->isCompilerGenerated() == true)
{
ss += "compiler generated\\n";
hasSpecialMode = true;
}
else
{
if (fileInfo->isFrontendSpecific() == true)
{
ss += "front-end specific\\n";
hasSpecialMode = true;
}
else
{
if (fileInfo->isTransformation() == true)
{
ss += "is part of transformation\\n";
hasSpecialMode = true;
}
else
{
// ss += "???\\n";
}
}
}
if (hasSpecialMode == true)
{
if (fileInfo->isOutputInCodeGeneration() == true)
{
ss += "IS output in generated code\\n";
}
else
{
ss += "is NOT output in generated code\\n";
}
}
else
{
// DQ (9/1/2013): Name a few cases were we want to output the end of the IR node construct's source position range.
// bool outputEndOfConstruct = (isSgAggregateInitializer(node) != NULL || isSgScopeStatement(node) != NULL);
bool outputEndOfConstruct = true; // (isSgAggregateInitializer(node) != NULL || isSgStatement(node) != NULL);
if (outputEndOfConstruct == true)
{
// Output the end of the range represented by the IR node's source position.
ss += generateFileLineColumnString(locatedNode->get_startOfConstruct());
ss += generateFileLineColumnString(locatedNode->get_endOfConstruct());
}
else
{
// For an SgStatement this is the startOfConstruct, but for an SgExpression this is the operator position (or sometimes equal to the startOfConstruct).
ss += generateFileLineColumnString(fileInfo);
}
}
}
else
{
ss += "no source position available\\n";
}
}
else
{
// DQ (9/1/2013): We could handle the source position of some other IR nodes (e.g. output name of the file for SgFile).
SgFile* file = isSgFile(node);
if (file != NULL)
{
ROSE_ASSERT(file->get_file_info() != NULL);
ss += generateFileLineColumnString(file->get_file_info());
}
}
return ss;
}
示例15: assert
AttachPreprocessingInfoTreeTraversalInheritedAttrribute
AttachAllPreprocessingInfoTreeTrav::evaluateInheritedAttribute ( SgNode *n, AttachPreprocessingInfoTreeTraversalInheritedAttrribute inh)
{
wrap_data_used_by_AttachPreprocessingInfoTreeTrav_t save_data;
SgFile *currentFilePtr = dynamic_cast<SgFile*>(n);
SgLocatedNode *currentLocNodePtr = dynamic_cast<SgLocatedNode*>(n);
int file_name_id = -1;
Sg_File_Info * file_info_ptr = NULL;
bool isCompilerGenerated = false;
bool isTransformation = false;
if ( ( currentFilePtr == NULL ) && ( currentLocNodePtr == NULL ) )
return inh;
// get a valid file name, and check if it is a new file; if yes, get
// all the comments and store the list into map. Then set save_data
// to prepare for the parent function.
// DQ (12/1/2008): I think this code can be simplified now, but I am not clear how it should be done!
// 1. find the file name for the current node:
if ( currentFilePtr!=NULL )
{
file_name_id = currentFilePtr->get_file_info()->get_file_id();
}
else
{
if ( currentLocNodePtr!=NULL )
{
file_info_ptr = currentLocNodePtr->get_file_info();
assert ( file_info_ptr!=NULL );
// Pi: compiler generated nodes have no real file names with them,
// so use the currentFileName as their names:
isCompilerGenerated = file_info_ptr->isCompilerGenerated();
// isCompilerGenerated = file_info_ptr->isCompilerGeneratedNodeToBeUnparsed();
isTransformation = file_info_ptr->isTransformation();
if ( isCompilerGenerated == true || isTransformation == true )
{
file_name_id = currentFileNameId;
}
else
{
file_name_id = file_info_ptr->get_file_id();
}
}
}
// 2. check whether the file name is new:
// AS(09/21/07) Reset start_index since we are dealing with a new file
start_index = 0;
map<int, wrap_data_used_by_AttachPreprocessingInfoTreeTrav_t>::iterator attr_list_itr = map_of_all_attributes.find(file_name_id);
// If the name is not in the map then ... it is a new file and we have to process it
if ( attr_list_itr == map_of_all_attributes.end() )
{
#ifdef outputallfilenamefound
cerr << "-->>> NEW file : " << file_name_str << endl;
#endif
save_data.previousLocNodePtr = previousLocNodePtr;
// AS(092907) Only collect the filenames we are interested in
// AS(093007) Logic to include or exclude finding comments in paths
bool includePath = true;
std::string file_name_str = Sg_File_Info::getFilenameFromID(file_name_id);
// If the command line directive to look for include paths has been
// specified. See if the current filename is in the list of
// included paths.
if( lookForIncludePaths == true )
{
includePath = false;
for (std::vector<std::string>::iterator iItr = pathsToInclude.begin(); iItr != pathsToInclude.end(); ++iItr)
{
if ( file_name_str.find(*iItr) != string::npos )
{
includePath = true;
break;
}
}
}
bool excludePath = false;
// If the command line directive to look for exclude paths has been
// specified. See if the current filename is in the list of
// excluded paths.
if ( lookForExcludePaths == true )
{
for (std::vector<std::string>::iterator iItr = pathsToExclude.begin(); iItr != pathsToExclude.end(); ++iItr)
{
if ( file_name_str.find(*iItr) != string::npos )
{
excludePath = true;
break;
}
}
//.........这里部分代码省略.........