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


C++ SgLocatedNode类代码示例

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


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

示例1: 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 ("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: 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

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

示例4: isSgLocatedNode

void
WalrusGraph::OutputEdges::visit ( SgNode* astNode )
   {
  // printf ("astNode = %p = %s \n",astNode,astNode->class_name().c_str());

     int numberOfNodes = node_to_index_map.size()+1;
     static int num = 0;

     SgLocatedNode* locatedNode = isSgLocatedNode(astNode);
     if ((isBinary == true) || (locatedNode != NULL && locatedNode->get_file_info()->isFrontendSpecific() == false))
        {
          if (isSgGlobal(astNode) == NULL)
             {
               printf ("            { @source=%d; @destination=%d; }",node_to_index_map[astNode->get_parent()],node_to_index_map[astNode]);
               *outputFilePtr << "            { @source=" << node_to_index_map[astNode->get_parent()] << "; @destination=" << node_to_index_map[astNode] << "; }";

               if (num < numberOfNodes-2)
                  {
                    printf (",");
                    *outputFilePtr << ",";
                  }
               printf ("\n");
               *outputFilePtr << endl;
             }
          
          num++;
        }
   }
开发者ID:Federico2014,项目名称:edg4x-rose,代码行数:28,代码来源:walrus.C

示例5: isSgLocatedNode

void findPreprocInfo::visit(SgNode* n)
{

  // Add in the information from the current node
  SgLocatedNode* locatedNode = isSgLocatedNode(n);
  if (locatedNode != NULL)
  {
    AttachedPreprocessingInfoType* commentsAndDirectives = locatedNode->getAttachedPreprocessingInfo();

    if (commentsAndDirectives != NULL)
    {
      // printf ("Found attached comments (to IR node at %p of type: %s): \n",locatedNode,locatedNode->class_name().c_str());
      // int counter = 0;

      // Use a reverse iterator so that we preserve the order when using push_front to add each directive to the accumulatedList
      AttachedPreprocessingInfoType::reverse_iterator i;
      for (i = commentsAndDirectives->rbegin(); i != commentsAndDirectives->rend(); i++)
      {
        // The different classifications of comments and directives are in ROSE/src/frontend/SageIII/rose_attributes_list.h
        if ((*i)->getTypeOfDirective() == PreprocessingInfo::CMacroCall)
        {
          wherePreprocIsAttached.push_back(std::pair<SgNode*,PreprocessingInfo*>(n,*i) );
        }
      }
    }
  }


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

示例6: ROSE_ASSERT

// This function is not requied since the base class function is available and is preferred (for conformity).
std::string
CompassAnalyses::FunctionDefinitionPrototype::CheckerOutput::getString() const
{
     ROSE_ASSERT(getNodeArray().size() <= 1);

  // Default implementation for getString
     SgLocatedNode* locatedNode = isSgLocatedNode(getNode());
     std::string sourceCodeLocation;
     if (locatedNode != NULL)
        {
          Sg_File_Info* start = locatedNode->get_startOfConstruct();
          Sg_File_Info* end   = locatedNode->get_endOfConstruct();
          sourceCodeLocation = (end ? Compass::formatStandardSourcePosition(start, end) 
                                    : Compass::formatStandardSourcePosition(start));
       }
      else
       {
      // Else this could be a SgInitializedName or SgTemplateArgument (not yet moved to be a SgLocatedNode)
         Sg_File_Info* start = getNode()->get_file_info();
         ROSE_ASSERT(start != NULL);
         sourceCodeLocation = Compass::formatStandardSourcePosition(start);
       }

     std::string nodeName = getNode()->class_name();

  // The short description used here needs to be put into a separate function (can this be part of what is filled in by the script?)
  // return loc + ": " + nodeName + ": variable requiring static constructor initialization";

     return m_checkerName + ": " + sourceCodeLocation + ": " + nodeName + ": " + m_shortDescription + ".\n\"" + what + "\" does not have a prototype";
} //CompassAnalyses::FunctionDefinitionPrototype::CheckerOutput::getString()
开发者ID:8l,项目名称:rose,代码行数:31,代码来源:functionDefinitionPrototype.C

示例7: isSgLocatedNode

AST_Graph::nodePartOfGraph::result_type
AST_Graph::nodePartOfGraph::operator()(pair<SgNode*,std::string>& x)
   {
     result_type functionalReturn;
     functionalReturn.addToGraph = true;
     functionalReturn.DOTOptions = "";
     functionalReturn.DOTLabel      = "";
     
     SgLocatedNode* locatedNode = isSgLocatedNode(x.first);
     if(locatedNode!=NULL)
        {
          Sg_File_Info* fileInfo = locatedNode->get_file_info();
          std::string filename(Rose::utility_stripPathFromFileName(fileInfo->get_filename()));

          if (filename.find("rose_edg_required_macros_and_functions.h") != std::string::npos)
             {
               functionalReturn.addToGraph = false;
             }

          if (fileInfo->isCompilerGenerated()==true)
             {
            // std::cout << "Is compiler generated\n";
               functionalReturn.addToGraph = false;
             }
        }
           
     return functionalReturn;
   }
开发者ID:matzke1,项目名称:rose-develop,代码行数:28,代码来源:astGraph.C

示例8: visit

 void visit(SgNode *node) {
     SgLocatedNode *located = isSgLocatedNode(node);
     if (located) {
         fix(located, located->get_file_info());
         fix(located, located->generateMatchingFileInfo());
         fix(located, located->get_startOfConstruct());
         fix(located, located->get_endOfConstruct());
     }
 }
开发者ID:peihunglin,项目名称:CFD-ROSE,代码行数:9,代码来源:checkIsCompilerGeneratedFlag.C

示例9: visit

               void visit ( SgNode* astNode )
                  {
                    SgLocatedNode* locatedNode = isSgLocatedNode(astNode);
                    if (locatedNode != NULL)
                       {
                         locatedNode->get_file_info()->setTransformation();
                         locatedNode->get_file_info()->setOutputInCodeGeneration();

                      // Uncomment to see the source position information for each SgLocatedNode IR node.
                      // locatedNode->get_file_info()->display("markAsTransformation(): debug");
                       }
                  }
开发者ID:Federico2014,项目名称:edg4x-rose,代码行数:12,代码来源:testTranslator2012_01.C

示例10: isSgLocatedNode

SynthesizedAttribute
visitorTraversal::evaluateSynthesizedAttribute ( SgNode* n, SynthesizedAttributesList childAttributes )
   {
     SynthesizedAttribute localResult;

  // printf ("In evaluateSynthesizedAttribute(n = %p = %s) \n",n,n->class_name().c_str());

  // Build the list from children (in reverse order to preserve the final ordering)
     for (SynthesizedAttributesList::reverse_iterator child = childAttributes.rbegin(); child != childAttributes.rend(); child++)
        {
          localResult.accumulatedList.splice(localResult.accumulatedList.begin(),child->accumulatedList);
        }

  // Add in the information from the current node
     SgLocatedNode* locatedNode = isSgLocatedNode(n);
     if (locatedNode != NULL)
        {
          AttachedPreprocessingInfoType* commentsAndDirectives = locatedNode->getAttachedPreprocessingInfo();

          if (commentsAndDirectives != NULL)
             {
            // printf ("Found attached comments (to IR node at %p of type: %s): \n",locatedNode,locatedNode->class_name().c_str());
            // int counter = 0;

            // Use a reverse iterator so that we preserve the order when using push_front to add each directive to the accumulatedList
               AttachedPreprocessingInfoType::reverse_iterator i;
               for (i = commentsAndDirectives->rbegin(); i != commentsAndDirectives->rend(); i++)
                  {
                 // The different classifications of comments and directives are in ROSE/src/frontend/SageIII/rose_attributes_list.h
                    if ((*i)->getTypeOfDirective() == PreprocessingInfo::CpreprocessorDefineDeclaration)
                       {
#if 0
                         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());
#endif
                      // use push_front() to end up with source ordering of final list of directives
                         localResult.accumulatedList.push_front(*i);
                       }
                  }
             }
        }

  // printf ("localResult after adding current node info \n");
  // localResult.display();

     return localResult;
   }
开发者ID:billhoffman,项目名称:rose-develop,代码行数:50,代码来源:collectDefineDirectives.C

示例11: commentAndCppInformation

static std::string
commentAndCppInformation (SgNode* node)
   {
  // DQ (8/31/2013): Adding source position information for DOT output.
     string ss;

     SgLocatedNode* locatedNode = isSgLocatedNode(node);
     if (locatedNode != NULL)
        {
          AttachedPreprocessingInfoType* commentsAndCppDirectives = locatedNode->getAttachedPreprocessingInfo();
          size_t numberofCommentsAndCppDirectives = 0;
          if (commentsAndCppDirectives != NULL)
             {
               numberofCommentsAndCppDirectives = commentsAndCppDirectives->size();
               if (numberofCommentsAndCppDirectives >= 0)
                  {
                 // ss = string("comments = ") + StringUtility::numberToString(numberofCommentsAndCppDirectives) + "\\n";
                    ss += string("comments/directives (before) = ") + StringUtility::numberToString(numberByRelativePosition(commentsAndCppDirectives,PreprocessingInfo::before)) + "\\n";
                    ss += string("comments/directives (inside) = ") + StringUtility::numberToString(numberByRelativePosition(commentsAndCppDirectives,PreprocessingInfo::inside)) + "\\n";
                    ss += string("comments/directives (after)  = ") + StringUtility::numberToString(numberByRelativePosition(commentsAndCppDirectives,PreprocessingInfo::after)) + "\\n";
                  }
             }
        }

#if 0
       else
        {
       // DQ (9/1/2013): We could handle the source position of some other IR nodes (e.g. output name of the file for SgFile).
          SgFile* file = isSgFile(node);
          if (file != NULL)
             {
            // ROSE_ASSERT(file->get_file_info() != NULL);
            // ss += generateFileLineColumnString(file->get_file_info());
               AttachedPreprocessingInfoType* commentsAndCppDirectives = file->getAttachedPreprocessingInfo();
               size_t numberofCommentsAndCppDirectives = 0;
               if (commentsAndCppDirectives != NULL)
                  {
                    numberofCommentsAndCppDirectives = commentsAndCppDirectives->size();
                    if (numberofCommentsAndCppDirectives > 0)
                       {
                         ss = string("comments = ") + StringUtility::numberToString(numberofCommentsAndCppDirectives) + "\\n";
                       }
                  }
             }
        }
#endif

     return ss;
   }
开发者ID:lvpw,项目名称:edg4x-rose,代码行数:49,代码来源:AstDOTGeneration.C

示例12: ROSE_ASSERT

 source_position roseNode::getEndPos() const
 {
   source_position pos; 
   ROSE_ASSERT(mNode!=NULL);
   SgLocatedNode* lnode = isSgLocatedNode(mNode);
   if (lnode != NULL)
   {  
     pos.line = lnode->get_endOfConstruct()->get_line();
     pos.column= lnode->get_endOfConstruct()->get_col(); 
   }else
   {
     pos.line=0;
     pos.column=0;
   }
   return pos;
 }
开发者ID:Federico2014,项目名称:edg4x-rose,代码行数:16,代码来源:roseAdapter.cpp

示例13: isSgLocatedNode

//The argument to the function is 
filterOnNodes::result_type
filterOnNodes::operator()(filterOnNodes::argument_type x) const
   {
     AST_Graph::FunctionalReturnType returnValue;
     //Determine if the node is to be added to the graph. true=yes
     returnValue.addToGraph = true;
     //set colors etc. for the graph Node
     returnValue.DOTOptions = "shape=polygon,regular=0,URL=\"\\N\",tooltip=\"more info at\\N\",sides=4,peripheries=1,color=\"Blue\",fillcolor=green,fontname=\"7x13bold\",fontcolor=black,style=filled";

     if( isSgProject(x.first) != NULL )
        returnValue.DOTOptions = "shape=ellipse,regular=0,URL=\"\\N\",tooltip=\"more info at\\N\",sides=4,peripheries=1,color=\"Blue\",fillcolor=yellow,fontname=\"7x13bold\",fontcolor=black,style=filled";



     //Filter out SgSymbols from the graph
     if ( isSgSymbol(x.first) != NULL )
          returnValue.addToGraph = false;

     if ( isSgType(x.first) != NULL )
          returnValue.addToGraph = false;

     //Filter out compiler generated nodes
     SgLocatedNode* locatedNode = isSgLocatedNode(x.first);
     if ( locatedNode != NULL )
        {
          Sg_File_Info* fileInfo = locatedNode->get_file_info();
          std::string filename(Rose::utility_stripPathFromFileName(fileInfo->get_filename()));



          if (filename.find("rose_edg_macros_and_functions_required_for_gnu.h") != std::string::npos)
             {
               returnValue.addToGraph = false;
             }

          if (fileInfo->isCompilerGenerated()==true)
             {
            // std::cout << "Is compiler generated\n";
               returnValue.addToGraph = false;
             }
        }

     return returnValue;
   }
开发者ID:matzke1,项目名称:rose-develop,代码行数:45,代码来源:wholeGraphAST.C

示例14:

string
AstPDFGeneration_private::get_bookmark_name(SgNode* node)
   {
     string nodefilename="--not initialized--";
     string bookmarktext;
        {
          ostringstream ss;
          ss << node->sage_class_name() << " ";
          SgLocatedNode* sgLocNode = dynamic_cast<SgLocatedNode*> (node);
          if(sgLocNode)
             {
               Sg_File_Info* fi = sgLocNode->get_file_info();
               if(fi)
                  {
                 // ss << "(" << fi->get_line() << "," << fi->get_col() << ") in \"" << fi->get_filename() << "\"";
                 // nodefilename=string(fi->get_filename());
#if 1      
                //  if (fi->isCompilerGenerated())
                //    ss << " compilerGenerated "; 
                  if (fi->isTransformation())
                      ss << " transformation " ;
                  if (fi->isOutputInCodeGeneration())   
                       ss<< " unparsable ";
                    ss << "(" << fi->get_line() << "," << fi->get_col() << ") in \"" << fi->get_filename() << "\"";
#endif                       
                    nodefilename=string(fi->get_filename());
                  }
                 else
                  {
                    ss << "(BUG)";
                  }
             }
            else
             {
               ss << ""; // provide no explicit info about the lack of file_info
             }
          bookmarktext=ss.str();
        }

      return bookmarktext;
   }
开发者ID:InstRO,项目名称:InstRO-ROSE,代码行数:41,代码来源:AstPDFGeneration.C

示例15: ROSE_ASSERT

std::string
Compass::OutputViolationBase::getString() const
{
  ROSE_ASSERT(getNodeArray().size() <= 1);

  // Default implementation for getString
  SgLocatedNode* locatedNode = isSgLocatedNode(getNode());
  std::string sourceCodeLocation;
  if (locatedNode != NULL)
    {
      Sg_File_Info* start = locatedNode->get_startOfConstruct();
      Sg_File_Info* end   = locatedNode->get_endOfConstruct();
      sourceCodeLocation = (end ? Compass::formatStandardSourcePosition(start, end) 
			    : Compass::formatStandardSourcePosition(start));
    }
  else
    {
      // Else this could be a SgInitializedName or SgTemplateArgument (not yet moved to be a SgLocatedNode)
      if (getNode()) {
  //      std::cerr << "Node : " << getNode()->class_name() << std::endl;
        Sg_File_Info* start = getNode()->get_file_info();
      // tps : 22Jan 2009 - commented the following out because it does not work with binaries
      //ROSE_ASSERT(start != NULL);
        if (start)
	  sourceCodeLocation = Compass::formatStandardSourcePosition(start);
      }
    }

  // tps Jan 23 2009: getNode() can be NULL because it could be a binary node
  // added a test for this
  std::string nodeName = "unknown";
	if (getNode())
            getNode()->class_name();

  // The short description used here needs to be put into a separate function (can this be part of what is filled in by the script?)
  // return loc + ": " + nodeName + ": variable requiring static constructor initialization";

  // return m_checkerName + ": " + sourceCodeLocation + ": " + nodeName + ": " + m_shortDescription;
  return m_checkerName + ": " + sourceCodeLocation + ": " + m_shortDescription;
}
开发者ID:OpenFortranProject,项目名称:ftt-research,代码行数:40,代码来源:compass.C


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