本文整理汇总了C++中SgLocatedNode::variantT方法的典型用法代码示例。如果您正苦于以下问题:C++ SgLocatedNode::variantT方法的具体用法?C++ SgLocatedNode::variantT怎么用?C++ SgLocatedNode::variantT使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SgLocatedNode
的用法示例。
在下文中一共展示了SgLocatedNode::variantT方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SgName
Rose_STL_Container<
ControlStructureContainer *
>queryFindCommentsInScope (const string stringPrefixToMatch,
const string stringToMatch,
SgScopeStatement * sageScopeStatement)
{
ROSE_ASSERT (stringPrefixToMatch.length () > 0);
ROSE_ASSERT (stringToMatch.length () > 0);
ROSE_ASSERT (sageScopeStatement != NULL);
Rose_STL_Container< ControlStructureContainer * >returnList;
//find all pragmas who match the stringToMatch
//cout << "Before pragma search" << endl;
/*list < SgNode * >pragmaStatements =
NodeQuery::querySubTree (sageScopeStatement,
new SgName (stringToMatch.c_str ()),
NodeQuery::PragmaDeclarationFromName);
*/
//list<SGNode*> pragmaStatements ;
//cout << "After pragma search" << endl;
/* cout << "BEFORE LIST" << endl;
list < SgNode * >pragmaStatements = queryNodePragmaStatementFromName2(sageScopeStatement,
new SgName(stringToMatch.c_str()));
cout << "AFTER LIST" << endl;*/
//return the pragmas in containers
/* for (list < SgNode * >::iterator i = pragmaStatements.begin ();
i != pragmaStatements.end (); ++i)
{
SgPragmaDeclaration *sagePragma = isSgPragmaDeclaration (*i);
ROSE_ASSERT (sagePragma);
ROSE_ASSERT (sagePragma->get_pragma () != NULL);
ROSE_ASSERT (sagePragma->get_pragma ()->get_pragma ());
ControlStructureContainer *container = new ControlStructureContainer ();
container->setPragmaString (sagePragma->get_pragma ()->get_pragma ());
container->setAssociatedStatement (sagePragma);
returnList.push_back (container);
}
*/
//find all statements in the current scope
if (sageScopeStatement->variantT () == V_SgClassDefinition)
{
SgDeclarationStatementPtrList statementsInScope =
sageScopeStatement->getDeclarationList ();
SgDeclarationStatementPtrList::iterator i;
for (i = statementsInScope.begin (); i != statementsInScope.end (); i++)
{
SgLocatedNode *locatedNode = isSgLocatedNode (*i);
ROSE_ASSERT (locatedNode != NULL);
//find all comments attached to current node.
AttachedPreprocessingInfoType *comments =
locatedNode->getAttachedPreprocessingInfo ();
if(locatedNode->variantT() == V_SgPragmaDeclaration){
SgPragmaDeclaration* sagePragmaDeclaration = isSgPragmaDeclaration(locatedNode);
ROSE_ASSERT( sagePragmaDeclaration );
ROSE_ASSERT( sagePragmaDeclaration->get_pragma() != NULL );
string pragmaDeclarationString = sagePragmaDeclaration->get_pragma()->get_pragma();
//extract the part before the leftmost = is pragmaDeclarationString
pragmaDeclarationString = pragmaDeclarationString.substr(0,pragmaDeclarationString.find("="));
//if the name-criteria is met accept node
if(pragmaDeclarationString.find( stringToMatch ) != string::npos ){
cout << pragmaDeclarationString << endl;
ControlStructureContainer *container = new ControlStructureContainer ();
container->setPragmaString (sagePragmaDeclaration->get_pragma ()->get_pragma ());
container->setAssociatedStatement (sagePragmaDeclaration);
returnList.push_back (container);
}
}
if (comments != NULL)
{
//We need to find comments which fits the criteria
printf ("Found attached comments (at %p of type: %s): \n",
locatedNode, locatedNode->sage_class_name ());
AttachedPreprocessingInfoType::iterator j;
for (j = comments->begin (); j != comments->end (); j++)
{
ROSE_ASSERT ((*j) != NULL);
string comment = (*j)->getString ();
//see if comment begins with stringPrefixToMatch
string tempString = comment.substr (0, comment.find (' '));
if (tempString == stringPrefixToMatch)
{ //+stringPrefixToMatch ){
//cout << "Found string" << endl;
comment =
StringUtility::copyEdit (comment, stringPrefixToMatch,
"");
//see if the comment has an element which matches the stringToMatch
if (comment.find (stringToMatch) != string::npos)
{
//.........这里部分代码省略.........