当前位置: 首页>>代码示例>>C++>>正文


C++ SgLocatedNode::variantT方法代码示例

本文整理汇总了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)
			{
//.........这里部分代码省略.........
开发者ID:8l,项目名称:rose,代码行数:101,代码来源:ControlStructure.C


注:本文中的SgLocatedNode::variantT方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。