Beispiel #1
0
// DQ (10/6/2007): Added fixup function to set scopes not set properly by the ROSETTA generated copy!
void
SgFunctionParameterList::fixupCopy_symbols(SgNode* copy, SgCopyHelp & help) const
   {
#if DEBUG_FIXUP_COPY
     printf ("Inside of SgFunctionParameterList::fixupCopy_symbols() for %p = %s copy = %p \n",this,this->class_name().c_str(),copy);
#endif

  // Also call the base class version of the fixupCopycopy() member function
     SgDeclarationStatement::fixupCopy_symbols(copy,help);

     SgFunctionParameterList* copyFunctionParameterList = isSgFunctionParameterList(copy);
     ROSE_ASSERT(copyFunctionParameterList != NULL);

     const SgInitializedNamePtrList & parameterList_original = this->get_args();
     SgInitializedNamePtrList & parameterList_copy           = copyFunctionParameterList->get_args();

     SgInitializedNamePtrList::const_iterator i_original = parameterList_original.begin();
     SgInitializedNamePtrList::iterator i_copy           = parameterList_copy.begin();

  // Iterate over both lists to match up the correct pairs of SgInitializedName objects
     while ( (i_original != parameterList_original.end()) && (i_copy != parameterList_copy.end()) )
        {
          (*i_original)->fixupCopy_symbols(*i_copy,help);

          i_original++;
          i_copy++;
        }
   }
Beispiel #2
0
// void RemoveConstantFoldedValue::visit ( SgNode* node )
RemoveConstantFoldedValueSynthesizedAttribute
RemoveConstantFoldedValue::evaluateSynthesizedAttribute ( SgNode* node, SubTreeSynthesizedAttributes synthesizedAttributeList )
   {
     ROSE_ASSERT(node != NULL);

  // DQ (3/11/2006): Set NULL pointers where we would like to have none.
#if 0
#if 0
  // Avoid excessive output.
     if (isSgFunctionDeclaration(node) == NULL && isSgInitializedName(node) == NULL && isSgFunctionParameterList(node) == NULL)
          printf ("In RemoveConstantFoldedValue::evaluateSynthesizedAttribute(): node = %p = %s synthesizedAttributeList.size() = %" PRIuPTR " \n",node,node->class_name().c_str(),synthesizedAttributeList.size());
#else
     printf ("In RemoveConstantFoldedValue::evaluateSynthesizedAttribute(): node = %p = %s synthesizedAttributeList.size() = %" PRIuPTR " \n",node,node->class_name().c_str(),synthesizedAttributeList.size());
#endif
#endif

  // Here we reset the pointer to the constant folded value to be the pointer to the original expression tree.
     SubTreeSynthesizedAttributes::iterator i = synthesizedAttributeList.begin();
     while (i != synthesizedAttributeList.end())
        {
#if 0
       // Avoid excessive output.
          if (isSgFunctionDeclaration(i->node) == NULL && isSgInitializedName(i->node) == NULL && isSgFunctionParameterList(i->node) == NULL && i->node != NULL)
               printf ("synthesizedAttribute = %p = %s \n",i->node,(i->node != NULL) ? i->node->class_name().c_str() : "NULL");
#endif

       // DQ (10/8/2011): Refectored this code so that we could better support chains of original expression trees (see test2011_146.C).
          handleTheSynthesizedAttribute(node,*i);

          i++;
        }

  // Here we force the nested traversal of the originalExpressionTree, since it is not traversed as part of the AST.
  // Note that these are not always leaf nodes that we want to interogate (see test2011_140.C).

  // DQ (9/24/2011): I think this is the wrong place to process this case (see test2011_140.C).
  // DQ (9/24/2011): We have fixed the AST traversal to no longer traverse originalExpressionTree subtree's (since 
  // it make analysis using the traversal redundant with the constant folded values).
  // If the current node is an expression and a leaf node of the AST, then check if it has an originalExpressionTree, 
  // since we no longer traverse the originalExpressionTree as part of the definition of the AST.
  // SgExpression* leafExpression = (synthesizedAttributeList.empty() == true) ? isSgExpression(node) : NULL;
     SgExpression* expression = isSgExpression(node);
     if (expression != NULL)
        {
#if 0
          printf ("In RemoveConstantFoldedValue::evaluateSynthesizedAttribute(): Found an expression \n");
#endif
          SgExpression* originalExpressionTree = expression->get_originalExpressionTree();
          if (originalExpressionTree != NULL)
             {
#if 0
               printf ("Found an expression with a valid originalExpressionTree\n");
#endif
            // Make sure that the traversal will see the nested subtrees of any originalExpressionTree (since they may have constant folded subexpresions).
               RemoveConstantFoldedValue nestedOriginalExpressionTreeTraversal;
               RemoveConstantFoldedValueSynthesizedAttribute nestedSynthesizedAttribute = nestedOriginalExpressionTreeTraversal.traverse(originalExpressionTree);
#if 0
            // DQ (10/8/2011): We should not handl this here, I think.
               handleTheSynthesizedAttribute(node,nestedSynthesizedAttribute);
#endif
#if 0
               printf ("DONE: Found an expression with a valid originalExpressionTree nestedSynthesizedAttribute \n");
#endif
             }
        }

     return RemoveConstantFoldedValueSynthesizedAttribute(node);
   }