本文整理汇总了C++中SgLocatedNode::unparseToString方法的典型用法代码示例。如果您正苦于以下问题:C++ SgLocatedNode::unparseToString方法的具体用法?C++ SgLocatedNode::unparseToString怎么用?C++ SgLocatedNode::unparseToString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SgLocatedNode
的用法示例。
在下文中一共展示了SgLocatedNode::unparseToString方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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));
}
};
}
};