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


C++ AstAttributeMechanism类代码示例

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


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

示例1:

// DQ (11/1/2003) added mechanism to add additional options (to add color, etc.)
string
AstDOTGeneration::additionalEdgeInfo(SgNode* from, SgNode* to, string label)
   {
  // return an empty string for default implementation
#if 0
     ostringstream ss;

  // DQ (7/4/2008): Added support for output of information about attributes
     AstAttributeMechanism* astAttributeContainer = node->get_attributeMechanism();
     if (astAttributeContainer != NULL)
        {
          for (AstAttributeMechanism::iterator i = astAttributeContainer->begin(); i != astAttributeContainer->end(); i++)
             {
            // std::string name = i->first;
               AstAttribute* attribute = i->second;
               ROSE_ASSERT(attribute != NULL);

               ss << attribute->additionalEdgeInfo();
             }
        }

     return ss.str();
#endif
     return "";
   }
开发者ID:LindaLovelace,项目名称:rose,代码行数:26,代码来源:AstDOTGeneration.C

示例2: printf

// DQ (11/1/2003) added mechanism to add additional options (to add color, etc.)
string
AstDOTGeneration::additionalNodeOptions(SgNode* node)
   {
  // return an empty string for default implementation
     ostringstream ss;

  // DQ (7/4/2008): Added support for output of information about attributes
     AstAttributeMechanism* astAttributeContainer = node->get_attributeMechanism();
     if (astAttributeContainer != NULL)
        {
#if 0
          printf ("In AstDOTGeneration::additionalNodeOptions(): astAttributeContainer = %p for node = %p = %s \n",astAttributeContainer,node,node->class_name().c_str());
#endif
          for (AstAttributeMechanism::iterator i = astAttributeContainer->begin(); i != astAttributeContainer->end(); i++)
             {
            // std::string name = i->first;
               AstAttribute* attribute = i->second;
               ROSE_ASSERT(attribute != NULL);

               ss << attribute->additionalNodeOptions();
             }
        }
       else
        {
#if 0
          printf ("In AstDOTGeneration::additionalNodeOptions(): astAttributeContainer == NULL for node = %p = %s \n",node,node->class_name().c_str());
#endif
        }

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

示例3: addAdditionalNodesAndEdges

void AstDOTGeneration::addAdditionalNodesAndEdges(SgNode* node)
{
  //*****
  // Nodes and edges can be annotated with additional information. This information is in
  // the form of additional nodes and edges. These is added to the output on a per-node basis.

  // DQ (7/4/2008): Support for edges specified in AST attributes
  AstAttributeMechanism* astAttributeContainer = node->get_attributeMechanism();
  if (astAttributeContainer != NULL)
  {
    // Loop over all the attributes at this IR node
    for (AstAttributeMechanism::iterator i = astAttributeContainer->begin(); i != astAttributeContainer->end(); i++)
    {
      // std::string name = i->first;
      AstAttribute* attribute = i->second;
      ROSE_ASSERT(attribute != NULL);

      // This can return a non-empty list in user-defined attributes (derived from AstAttribute).
      // printf ("Calling attribute->additionalNodeInfo() \n");
      std::vector<AstAttribute::AttributeNodeInfo> nodeList = attribute->additionalNodeInfo();
      // printf ("nodeList.size() = %lu \n",nodeList.size());

      for (std::vector<AstAttribute::AttributeNodeInfo>::iterator i_node = nodeList.begin(); i_node != nodeList.end(); i_node++)
      {
        SgNode* nodePtr   = i_node->nodePtr;
        string nodelabel  = i_node->label;
        string nodeoption = i_node->options;
        // printf ("In AstDOTGeneration::evaluateSynthesizedAttribute(): Adding a node nodelabel = %s nodeoption = %s \n",nodelabel.c_str(),nodeoption.c_str());
        // dotrep.addNode(NULL,dotrep.traceFormat(ia.tdTracePos)+nodelabel,nodeoption);
//        dotrep.addNode( nodePtr, dotrep.traceFormat(ia.tdTracePos) + nodelabel, nodeoption );
        dotrep.addNode( nodePtr, nodelabel, nodeoption );

      }

      // printf ("Calling attribute->additionalEdgeInfo() \n");
      std::vector<AstAttribute::AttributeEdgeInfo> edgeList = attribute->additionalEdgeInfo();
      // printf ("edgeList.size() = %lu \n",edgeList.size());
      for (std::vector<AstAttribute::AttributeEdgeInfo>::iterator i_edge = edgeList.begin(); i_edge != edgeList.end(); i_edge++)
      {
        string edgelabel  = i_edge->label;
        string edgeoption = i_edge->options;
        // printf ("In AstDOTGeneration::evaluateSynthesizedAttribute(): Adding an edge from i_edge->fromNode = %p to i_edge->toNode = %p edgelabel = %s edgeoption = %s \n",i_edge->fromNode,i_edge->toNode,edgelabel.c_str(),edgeoption.c_str());
        dotrep.addEdge(i_edge->fromNode,edgelabel,i_edge->toNode,edgeoption + "dir=forward");
      }
    }
  }
}
开发者ID:LindaLovelace,项目名称:rose,代码行数:47,代码来源:AstDOTGeneration.C

示例4: sourcePositionInformation

// To improve the default output add additional information here
// Note you need to add "\\n" for newline
string
AstDOTGeneration::additionalNodeInfo(SgNode* node)
   {
     ostringstream ss;
     ss << "\\n";

  // print number of max successors (= container size)
     AstSuccessorsSelectors::SuccessorsContainer c;
     AstSuccessorsSelectors::selectDefaultSuccessors(node,c);
     ss << c.size() << "\\n";

  // add memory location of node to dot output
     ss << node << "\\n";

  // DQ (8/31/2013): Added more information about the IR node to the dot graph.
     ss << sourcePositionInformation(node);

  // DQ (9/19/2013): Added more information about the IR node to the dot graph (comments and C preprocessor directive information).
     ss << commentAndCppInformation(node);

  // DQ (7/4/2008): Added support for output of information about attributes
     AstAttributeMechanism* astAttributeContainer = node->get_attributeMechanism();
     if (astAttributeContainer != NULL)
        {
          ss << "Attribute list (size=" << astAttributeContainer->size() << "):" << "\\n";
          for (AstAttributeMechanism::iterator i = astAttributeContainer->begin(); i != astAttributeContainer->end(); i++)
             {
            // pair<std::string,AstAttribute*>
               AstAttribute* attribute = i->second;
               ROSE_ASSERT(attribute != NULL);

            // Note cast to void*
               std::string name = i->first;
               std::string label = name + " : " + attribute->toString();
               ss << label << "\\n";
             }
          ss << "\\n";
          ss << "\\n";
        }

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

示例5:

AstAttributeMechanism::AstAttributeMechanism ( const AstAttributeMechanism & X )
   {
  // This is the copy constructor to support deep copies of AST attribute containers.
  // this is important for the support of the AST Copy mechanism (used all over the place,
  // but being tested in new ways within the bug seeding project).

  // Note that AstAttributeMechanism is derived from: AttributeMechanism<std::string,AstAttribute*>
  // Which is defined as: template<class Key,class Value> class AttributeMechanism : protected std::map<Key,Value>
#if 1
  // Iterate over all the elements of the map in X and copy them to the current map (this)
     for (const_iterator iter = X.begin(); iter != X.end(); iter++)
        {
       // Call the copy mechanism on the AstAttribute (virtual copy constructor)
          this->insert(std::make_pair( iter->first , _clone_attribute(iter->second) ));
        }
#else
  // ((const AttributeMechanism<std::string,AstAttribute*>*) this) = X;
     *this = X;
#endif
   }
开发者ID:peihunglin,项目名称:CFD-ROSE,代码行数:20,代码来源:AstAttributeMechanism.C

示例6: ROSE_ASSERT


//.........这里部分代码省略.........
             }
            else
             {
            // DQ (3/5/2007) added mechanism to add additional options (to add color, etc.)
               string edgeoption = additionalEdgeOptions(node,iter->node,edgelabel);

               switch(traversal)
                  {
                    case TOPDOWNBOTTOMUP:
                         dotrep.addEdge(node,edgelabel,(*iter).node,edgeoption + "dir=both");
                         break;
                    case PREORDER:
                    case TOPDOWN:
                         dotrep.addEdge(node,edgelabel,(*iter).node,edgeoption + "dir=forward");
                         break;
                    case POSTORDER:
                    case BOTTOMUP:
                         dotrep.addEdge(node,edgelabel,(*iter).node,edgeoption + "dir=back");
                         break;
                    default:
                         assert(false);
                  }
             }

          testnum++;
        }

// **************************
        }



  // DQ (7/4/2008): Support for edges specified in AST attributes
     AstAttributeMechanism* astAttributeContainer = node->get_attributeMechanism();
     if (astAttributeContainer != NULL)
        {
       // Loop over all the attributes at this IR node
          for (AstAttributeMechanism::iterator i = astAttributeContainer->begin(); i != astAttributeContainer->end(); i++)
             {
            // std::string name = i->first;
               AstAttribute* attribute = i->second;
               ROSE_ASSERT(attribute != NULL);

            // This can return a non-empty list in user-defined attributes (derived from AstAttribute).
            // printf ("Calling attribute->additionalNodeInfo() \n");
               std::vector<AstAttribute::AttributeNodeInfo> nodeList = attribute->additionalNodeInfo();
            // printf ("nodeList.size() = %lu \n",nodeList.size());

               for (std::vector<AstAttribute::AttributeNodeInfo>::iterator i_node = nodeList.begin(); i_node != nodeList.end(); i_node++)
                  {
                    SgNode* nodePtr   = i_node->nodePtr;
                    string nodelabel  = i_node->label;
                    string nodeoption = i_node->options;
                 // printf ("In AstDOTGeneration::evaluateSynthesizedAttribute(): Adding a node nodelabel = %s nodeoption = %s \n",nodelabel.c_str(),nodeoption.c_str());
                 // dotrep.addNode(NULL,dotrep.traceFormat(ia.tdTracePos)+nodelabel,nodeoption);
                    dotrep.addNode( nodePtr, dotrep.traceFormat(ia.tdTracePos) + nodelabel, nodeoption );
                  }

            // printf ("Calling attribute->additionalEdgeInfo() \n");
               std::vector<AstAttribute::AttributeEdgeInfo> edgeList = attribute->additionalEdgeInfo();
            // printf ("edgeList.size() = %lu \n",edgeList.size());
               for (std::vector<AstAttribute::AttributeEdgeInfo>::iterator i_edge = edgeList.begin(); i_edge != edgeList.end(); i_edge++)
                  {
                    string edgelabel  = i_edge->label;
                    string edgeoption = i_edge->options;
                 // printf ("In AstDOTGeneration::evaluateSynthesizedAttribute(): Adding an edge from i_edge->fromNode = %p to i_edge->toNode = %p edgelabel = %s edgeoption = %s \n",i_edge->fromNode,i_edge->toNode,edgelabel.c_str(),edgeoption.c_str());
开发者ID:LindaLovelace,项目名称:rose,代码行数:67,代码来源:AstDOTGeneration.C

示例7: ROSE_ASSERT

Detection_SynthesizedAttribute
DetectionTraversal::evaluateSynthesizedAttribute (SgNode* astNode, Detection_InheritedAttribute inheritedAttribute, SubTreeSynthesizedAttributes synthesizedAttributeList )
   {
     ROSE_ASSERT(astNode != NULL);

     Detection_SynthesizedAttribute return_synthesizedAttribute(astNode);

#if 1
     printf ("In evaluateSynthesizedAttribute(): astNode = %p = %s synthesizedAttributeList.size() = %zu dslChildren.size() = %zu \n",
          astNode,astNode->class_name().c_str(),synthesizedAttributeList.size(),return_synthesizedAttribute.dslChildren.size());
#endif

  // At each IR node and across all children, accumulate the dslChildren (child nodes for each of the DSL AST nodes).
     for (SubTreeSynthesizedAttributes::iterator i = synthesizedAttributeList.begin(); i != synthesizedAttributeList.end(); i++)
        {
          SgNode* childNode = (*i).node;
       // ROSE_ASSERT(childNode != NULL);
          if (childNode != NULL)
             {
#if 0
               printf ("Identified child node in evaluateSynthesizedAttribute(): childNode = %p = %s \n",childNode,childNode->class_name().c_str());
#endif
            // Insert each list from the child into the accumulated list in the current Synthesized Attribute.
               return_synthesizedAttribute.dslChildren.insert(return_synthesizedAttribute.dslChildren.end(),i->dslChildren.begin(),i->dslChildren.end());
#if 0
               printf ("   --- copying i->dslChildren.size() = %zu into return_synthesizedAttribute.dslChildren.size() = %zu \n",i->dslChildren.size(),return_synthesizedAttribute.dslChildren.size());
#endif
               if (return_synthesizedAttribute.dslChildren.empty() == false)
                  {
#if 0
                    printf ("In evaluateSynthesizedAttribute(): dslChildren.size() = %zu \n",return_synthesizedAttribute.dslChildren.size());
#endif
                  }
             }
            else
             {
#if 1
               printf ("childNode == NULL \n");
#endif
             }
        }


  // Recognition of other control statements (e.g. for loops for the stencil evaluation) or expression/statement abstractions (e.g. function calls)
  // Note: DSL specific control abstractions might be recognised as loops containing DSL abstractions and having constant evaluatable base and bounds.


  // For any DSL specific AST nodes (C++ AST nodes containing a DSL_Attribute), initialize the pointers to children of the DSL IR node.
     AstAttributeMechanism* astAttributeContainer = astNode->get_attributeMechanism();
     if (astAttributeContainer != NULL)
        {
#if 1
          printf ("In evaluateSynthesizedAttribute(): found a attribute on astNode = %p = %s \n",astNode,astNode->class_name().c_str());
#endif
       // I think there should only be one DSL attribute, in the future we can support more on a single IR node.
          if (astAttributeContainer->size() != 1)
             {
               printf ("WARNING: astAttributeContainer->size() != 1: astAttributeContainer->size() = %zu \n",astAttributeContainer->size());
             }
#if 1
       // DQ: Allow this for the moment while testing.
          ROSE_ASSERT(astAttributeContainer->size() == 1);
#endif
       // Loop over all the attributes at this IR node
       // Pei-Hung (12/22/15): THe ASTAttributeMechanmsim is changed and has to use new API
       // for (AstAttributeMechanism::iterator i = astAttributeContainer->begin(); i != astAttributeContainer->end(); i++)
          BOOST_FOREACH (const std::string &attributeName, astAttributeContainer->getAttributeIdentifiers()) 
             {
               AstAttribute* attribute = astNode->getAttribute(attributeName);
               ROSE_ASSERT(attribute != NULL);
#if 1
            // DSL_Attribute* dslAstAttribute = dynamic_cast<DSL_Attribute*>(attribute);
               dsl_attribute* dslAstAttribute = dynamic_cast<dsl_attribute*>(attribute);
               ROSE_ASSERT(dslAstAttribute != NULL);
#if 1
               printf ("Identified dslAstAttribute in evaluateSynthesizedAttribute(): astNode = %p = %s \n",astNode,astNode->class_name().c_str());
               printf ("   --- return_synthesizedAttribute.dslChildren.size() = %zu \n",return_synthesizedAttribute.dslChildren.size());
#endif
            // Copy the dsl child data to the dsl attribute.
               dslAstAttribute->currentNode = astNode;
               dslAstAttribute->dslChildren = return_synthesizedAttribute.dslChildren;
#endif
             }

       // Clear the dsl attributes becasue we the only collect dsl child attributes at dsl attributed IR nodes and don't pass then further up the tree.          
          return_synthesizedAttribute.dslChildren.clear();

       // Add the current node since it has an attribute.
          return_synthesizedAttribute.dslChildren.push_back(astNode);

#if 0
          printf ("Exiting as a test! \n");
          ROSE_ASSERT(false);
#endif
        }
开发者ID:justintoo,项目名称:rose-develop,代码行数:95,代码来源:dsl_detection.C


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