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


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

本文整理汇总了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));
        }

        
      };

       

    }
    
  };
开发者ID:InstRO,项目名称:InstRO-ROSE,代码行数:61,代码来源:unparseMacro.C

示例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");
      }
    }
  }
}
开发者ID:ian-bertolacci,项目名称:rose-develop,代码行数:38,代码来源:preprocessingInfoDumper.C

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


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