本文整理汇总了C++中SgLocatedNode::class_name方法的典型用法代码示例。如果您正苦于以下问题:C++ SgLocatedNode::class_name方法的具体用法?C++ SgLocatedNode::class_name怎么用?C++ SgLocatedNode::class_name使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SgLocatedNode
的用法示例。
在下文中一共展示了SgLocatedNode::class_name方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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));
}
};
}
};
示例2: 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");
}
}
}
}
示例3: visit
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 ("Found attached comments (to IR node at %p of type: %s): \n",locatedNode,locatedNode->class_name().c_str());
int counter = 0;
AttachedPreprocessingInfoType::iterator i;
for (i = comments->begin(); i != comments->end(); i++)
{
printf (" Attached Comment #%d in file %s (relativePosition=%s): classification %s :\n%s\n",
counter++,(*i)->get_file_info()->get_filenameString().c_str(),
((*i)->getRelativePosition() == PreprocessingInfo::before) ? "before" : "after",
PreprocessingInfo::directiveTypeName((*i)->getTypeOfDirective()).c_str(),
(*i)->getString().c_str());
}
}
else
{
printf ("No attached comments (at %p of type: %s): \n",locatedNode,locatedNode->sage_class_name());
}
}
}