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


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

本文整理汇总了C++中SgLocatedNode::sage_class_name方法的典型用法代码示例。如果您正苦于以下问题:C++ SgLocatedNode::sage_class_name方法的具体用法?C++ SgLocatedNode::sage_class_name怎么用?C++ SgLocatedNode::sage_class_name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SgLocatedNode的用法示例。


在下文中一共展示了SgLocatedNode::sage_class_name方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: 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());
             }
        }
   }
开发者ID:billhoffman,项目名称:rose-develop,代码行数:28,代码来源:collectComments.C

示例2: 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

示例3: visit

               void visit ( SgNode* n )
                  {
                    SgLocatedNode* locatedNode = isSgLocatedNode(n); 
                    if (locatedNode != NULL)
                       {
                         AttachedPreprocessingInfoType* comments = locatedNode->getAttachedPreprocessingInfo();

                         if (comments != NULL)
                            {
                              printf ("Found attached comments (at %p of type: %s): \n",locatedNode,locatedNode->sage_class_name());
                              AttachedPreprocessingInfoType::iterator i;
                              for (i = comments->begin(); i != comments->end(); i++)
                                 {
                                   ROSE_ASSERT ( (*i) != NULL );
                                   printf ("          Attached Comment (relativePosition=%s): %s\n",
                                        ((*i)->getRelativePosition() == PreprocessingInfo::before) ? "before" : "after",
                                        (*i)->getString().c_str());
#if 1
                                // This does not appear to be a valid object when read in from an AST file.
                                   printf ("Comment/Directive getNumberOfLines = %d getColumnNumberOfEndOfString = %d \n",(*i)->getNumberOfLines(),(*i)->getColumnNumberOfEndOfString());
#endif
#if 1
                                // This does not appear to be a valid object when read in from an AST file.
                                   (*i)->get_file_info()->display("comment/directive location");
#endif
                                 }
                            }
                       }
                  }
开发者ID:Federico2014,项目名称:edg4x-rose,代码行数:29,代码来源:testAstFileRead.C


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