331 virtual void atTraversalEnd();
334 virtual DummyAttribute evaluateInheritedAttribute(
SgNode* astNode, DummyAttribute inheritedValue);
357template <
class InheritedAttributeType,
class SynthesizedAttributeType>
361template <
class InheritedAttributeType>
365template <
class SynthesizedAttributeType>
375template<
class InheritedAttributeType,
class SynthesizedAttributeType>
380 AstSuccessorsSelectors::selectDefaultSuccessors(node, succContainer);
387template<
class InheritedAttributeType,
class SynthesizedAttributeType>
390 : useDefaultIndexBasedTraversal(true),
391 traversalConstraint(false),
392 fileToVisit(nullptr),
393 synthesizedAttributes(new SynthesizedAttributesList())
399template<
class InheritedAttributeType,
class SynthesizedAttributeType>
403 ASSERT_not_null(synthesizedAttributes);
404 delete synthesizedAttributes;
405 synthesizedAttributes =
nullptr;
413template<
class InheritedAttributeType,
class SynthesizedAttributeType>
416 : useDefaultIndexBasedTraversal(other.useDefaultIndexBasedTraversal),
417 traversalConstraint(other.traversalConstraint),
418 fileToVisit(other.fileToVisit),
419 synthesizedAttributes(other.synthesizedAttributes->
deepCopy())
426template<
class InheritedAttributeType,
class SynthesizedAttributeType>
431 useDefaultIndexBasedTraversal = other.useDefaultIndexBasedTraversal;
432 traversalConstraint = other.traversalConstraint;
433 fileToVisit = other.fileToVisit;
435 ASSERT_not_null(synthesizedAttributes);
436 delete synthesizedAttributes;
437 synthesizedAttributes = other.synthesizedAttributes->deepCopy();
443template<
class InheritedAttributeType,
class SynthesizedAttributeType>
448 useDefaultIndexBasedTraversal = val;
453template<
class InheritedAttributeType,
class SynthesizedAttributeType>
457 InheritedAttributeType inheritedValue,
458 t_traverseOrder travOrder)
460 const SgFilePtrList& fList = projectNode->get_fileList();
467 printf (
"Warning: The traverseInputFiles() iteration over the file list prevents the evaluation of inherited and synthesized attributes on the SgProject IR node! \n");
469 for (SgFilePtrList::const_iterator fl_iter = fList.begin(); fl_iter != fList.end(); fl_iter++)
471 ASSERT_not_null(*fl_iter);
472 traverseWithinFile((*fl_iter), inheritedValue, travOrder);
484template <
class InheritedAttributeType,
class SynthesizedAttributeType>
485SynthesizedAttributeType
491 ::traverse(node, inheritedValue, preandpostorder);
496template <
class InheritedAttributeType,
class SynthesizedAttributeType>
497SynthesizedAttributeType
510template <
class InheritedAttributeType>
514 InheritedAttributeType inheritedValue,
515 typename AstTopDownProcessing<InheritedAttributeType>::SynthesizedAttributesList)
518 destroyInheritedValue(astNode, inheritedValue);
520 DummyAttribute a = defaultDummyAttribute;
526template <
class InheritedAttributeType>
532 DummyAttribute a = defaultDummyAttribute;
537template <
class InheritedAttributeType>
545 ::traverse(node, inheritedValue, preandpostorder);
550template <
class InheritedAttributeType>
567template <
class SynthesizedAttributeType>
573 DummyAttribute a = defaultDummyAttribute;
580template <
class SynthesizedAttributeType>
587 SynthesizedAttributeType s = SynthesizedAttributeType();
592template <
class SynthesizedAttributeType>
596 return defaultSynthesizedAttribute();
600template <
class SynthesizedAttributeType>
604 SynthesizedAttributesList l)
606 return evaluateSynthesizedAttribute(astNode, l);
614template <
class SynthesizedAttributeType>
619 static DummyAttribute da;
626template <
class SynthesizedAttributeType>
630 static DummyAttribute da;
637template <
class SynthesizedAttributeType>
641 static DummyAttribute da;
650#include "../astQuery/booleanQuery.h"
651#include "../astQuery/booleanQueryInheritedAttribute.h"
654template <
class InheritedAttributeType,
class SynthesizedAttributeType>
659 SynthesizedAttributeType s = SynthesizedAttributeType();
664template <
class InheritedAttributeType,
class SynthesizedAttributeType>
665SynthesizedAttributeType
668 InheritedAttributeType inheritedValue,
669 t_traverseOrder treeTraversalOrder)
672 traversalConstraint =
true;
674 SgFile* filenode = isSgFile(node);
675 if (filenode ==
nullptr)
679 printf (
"Error: traverseWithinFile(): (node should be non-null) node = %p \n",node);
684 printf (
"Error: traverseWithinFile(): (node should be type SgFile) node = %p = %s \n",node,node->
class_name().c_str());
687 ASSERT_not_null(filenode);
691 fileToVisit = filenode;
695 std::string filename = fileToVisit !=
nullptr ? fileToVisit->
getFileName() :
"";
696 printf (
"In SgTreeTraversal<>::traverseWithinFile(): fileToVisit = %p filename = %s \n",fileToVisit,filename.c_str());
699 ROSE_ASSERT(SgTreeTraversal_inFileToTraverse(node, traversalConstraint, fileToVisit) ==
true);
701 SynthesizedAttributeType synth = traverse(node, inheritedValue, treeTraversalOrder);
703 traversalConstraint =
false;
728template <
class InheritedAttributeType,
class SynthesizedAttributeType>
731 t_traverseOrder treeTraversalOrder)
734 synthesizedAttributes->resetStack();
735 ROSE_ASSERT(synthesizedAttributes->debugSize() == 0);
741 performTraversal(node, inheritedValue, treeTraversalOrder);
747 return traversalResult();
752template<
class InheritedAttributeType,
class SynthesizedAttributeType>
756 InheritedAttributeType inheritedValue,
757 t_traverseOrder treeTraversalOrder)
766 if (node && SgTreeTraversal_inFileToTraverse(node, traversalConstraint, fileToVisit))
772 if (treeTraversalOrder & preorder)
773 inheritedValue = evaluateInheritedAttribute(node, inheritedValue);
778 AstSuccessorsSelectors::SuccessorsContainer succContainer;
779 size_t numberOfSuccessors;
780 if (!useDefaultIndexBasedTraversal)
782 setNodeSuccessors(node, succContainer);
783 numberOfSuccessors = succContainer.size();
792 printf (
"In SgTreeTraversal<>::performTraversal(): node = %p = %s numberOfSuccessors = %zu \n",node,node->
class_name().c_str(),numberOfSuccessors);
795 for (
size_t idx = 0; idx < numberOfSuccessors; idx++)
799 if (useDefaultIndexBasedTraversal)
804 ASSERT_require(child ==
nullptr || child !=
nullptr);
808 child = succContainer[idx];
811 ASSERT_require(child ==
nullptr || child !=
nullptr);
816 printf (
"In SgTreeTraversal<>::performTraversal(): child = %p \n",child);
819 if (child !=
nullptr)
823 printf (
"In SgTreeTraversal<>::performTraversal(): child = %p = %s \n",child,child->
class_name().c_str());
825 performTraversal(child, inheritedValue, treeTraversalOrder);
832 if (treeTraversalOrder & postorder)
833 synthesizedAttributes->push(defaultSynthesizedAttribute(inheritedValue));
844 if (treeTraversalOrder & postorder)
852 synthesizedAttributes->setFrameSize(numberOfSuccessors);
853 ROSE_ASSERT(synthesizedAttributes->size() == numberOfSuccessors);
854 synthesizedAttributes->push(evaluateSynthesizedAttribute(node, inheritedValue, *synthesizedAttributes));
859 if (treeTraversalOrder & postorder)
860 synthesizedAttributes->push(defaultSynthesizedAttribute(inheritedValue));
866template <
class InheritedAttributeType,
class SynthesizedAttributeType>
876 if (synthesizedAttributes->debugSize() == 1)
878 return synthesizedAttributes->pop();
882 static SynthesizedAttributeType sa;
889template <
class InheritedAttributeType,
class SynthesizedAttributeType>
897template <
class InheritedAttributeType,
class SynthesizedAttributeType>
921template <
class InheritedAttributeType,
class SynthesizedAttributeType>
928template <
class InheritedAttributeType,
class SynthesizedAttributeType>
935template <
class InheritedAttributeType>
942template <
class InheritedAttributeType>
949template <
class InheritedAttributeType>
956template <
class SynthesizedAttributeType>