4 #ifndef ASTPROCESSING_H
5 #define ASTPROCESSING_H
12 #ifndef ROSE_USE_INTERNAL_FRONTEND_DEVELOPMENT
89 template <
class InheritedAttributeType,
class SynthesizedAttributeType>
96 template <
class InheritedAttributeType,
class SynthesizedAttributeType>
103 InheritedAttributeType inheritedValue,
107 InheritedAttributeType inheritedValue,
111 InheritedAttributeType inheritedValue,
129 InheritedAttributeType inheritedValue) = 0;
133 InheritedAttributeType
in,
164 InheritedAttributeType inheritedValue,
180 template <
class InheritedAttributeType,
class SynthesizedAttributeType>
183 template <
class InheritedAttributeType,
class SynthesizedAttributeType>
185 :
public SgTreeTraversal<InheritedAttributeType, SynthesizedAttributeType>
195 SynthesizedAttributeType
traverse(
SgNode* node, InheritedAttributeType inheritedValue);
211 InheritedAttributeType inheritedValue) = 0;
218 InheritedAttributeType,
230 template <
class InheritedAttributeType>
233 template <
class InheritedAttributeType>
236 template <
class InheritedAttributeType>
245 void traverse(
SgNode* node, InheritedAttributeType inheritedValue);
258 InheritedAttributeType inheritedValue) = 0;
275 InheritedAttributeType inheritedValue,
282 template <
class SynthesizedAttributeType>
285 template <
class InheritedAttributeType>
288 template <
class SynthesizedAttributeType>
357 template <
class InheritedAttributeType,
class SynthesizedAttributeType>
361 template <
class InheritedAttributeType>
365 template <
class SynthesizedAttributeType>
375 template<
class InheritedAttributeType,
class SynthesizedAttributeType>
387 template<
class InheritedAttributeType,
class SynthesizedAttributeType>
390 : useDefaultIndexBasedTraversal(true),
391 traversalConstraint(false),
399 template<
class InheritedAttributeType,
class SynthesizedAttributeType>
403 ROSE_ASSERT(synthesizedAttributes != NULL);
404 delete synthesizedAttributes;
405 synthesizedAttributes = NULL;
411 template<
class InheritedAttributeType,
class SynthesizedAttributeType>
414 : useDefaultIndexBasedTraversal(other.useDefaultIndexBasedTraversal),
415 traversalConstraint(other.traversalConstraint),
416 fileToVisit(other.fileToVisit),
417 synthesizedAttributes(other.synthesizedAttributes->
deepCopy())
421 template<
class InheritedAttributeType,
class SynthesizedAttributeType>
430 ROSE_ASSERT(synthesizedAttributes != NULL);
431 delete synthesizedAttributes;
437 template<
class InheritedAttributeType,
class SynthesizedAttributeType>
442 useDefaultIndexBasedTraversal = val;
447 template<
class InheritedAttributeType,
class SynthesizedAttributeType>
451 InheritedAttributeType inheritedValue,
461 printf (
"Warning: The traverseInputFiles() iteration over the file list prevents the evaluation of inherited and synthesized attributes on the SgProject IR node! \n");
463 for (SgFilePtrList::const_iterator fl_iter = fList.begin(); fl_iter != fList.end(); fl_iter++)
465 ROSE_ASSERT(*fl_iter != NULL);
466 traverseWithinFile((*fl_iter), inheritedValue, travOrder);
480 template <
class InheritedAttributeType,
class SynthesizedAttributeType>
481 SynthesizedAttributeType
492 template <
class InheritedAttributeType,
class SynthesizedAttributeType>
493 SynthesizedAttributeType
506 template <
class InheritedAttributeType>
510 InheritedAttributeType inheritedValue,
514 destroyInheritedValue(astNode, inheritedValue);
522 template <
class InheritedAttributeType>
533 template <
class InheritedAttributeType>
546 template <
class InheritedAttributeType>
562 template <
class SynthesizedAttributeType>
576 template <
class SynthesizedAttributeType>
583 SynthesizedAttributeType s = SynthesizedAttributeType();
588 template <
class SynthesizedAttributeType>
592 return defaultSynthesizedAttribute();
596 template <
class SynthesizedAttributeType>
602 return evaluateSynthesizedAttribute(astNode, l);
610 template <
class SynthesizedAttributeType>
622 template <
class SynthesizedAttributeType>
633 template <
class SynthesizedAttributeType>
646 #include "../astQuery/booleanQuery.h"
647 #include "../astQuery/booleanQueryInheritedAttribute.h"
650 template <
class InheritedAttributeType,
class SynthesizedAttributeType>
655 SynthesizedAttributeType s = SynthesizedAttributeType();
660 template <
class InheritedAttributeType,
class SynthesizedAttributeType>
661 SynthesizedAttributeType
664 InheritedAttributeType inheritedValue,
668 ROSE_ASSERT(
this != NULL);
669 traversalConstraint =
true;
672 if (filenode == NULL)
676 printf (
"Error: traverseWithinFile(): (node should be non-null) node = %p \n",node);
681 printf (
"Error: traverseWithinFile(): (node should be type SgFile) node = %p = %s \n",node,node->
class_name().c_str());
684 ROSE_ASSERT(filenode != NULL);
688 fileToVisit = filenode;
692 SynthesizedAttributeType synth = traverse(node, inheritedValue, treeTraversalOrder);
693 traversalConstraint =
false;
717 template <
class InheritedAttributeType,
class SynthesizedAttributeType>
723 synthesizedAttributes->resetStack();
724 ROSE_ASSERT(synthesizedAttributes->debugSize() == 0);
730 performTraversal(node, inheritedValue, treeTraversalOrder);
736 return traversalResult();
741 template<
class InheritedAttributeType,
class SynthesizedAttributeType>
745 InheritedAttributeType inheritedValue,
762 inheritedValue = evaluateInheritedAttribute(node, inheritedValue);
768 size_t numberOfSuccessors;
769 if (!useDefaultIndexBasedTraversal)
771 setNodeSuccessors(node, succContainer);
772 numberOfSuccessors = succContainer.size();
779 for (
size_t idx = 0; idx < numberOfSuccessors; idx++)
783 if (useDefaultIndexBasedTraversal)
789 ROSE_ASSERT(child == NULL || child != NULL);
794 child = succContainer[idx];
797 ROSE_ASSERT(child == NULL || child != NULL);
805 performTraversal(child, inheritedValue, treeTraversalOrder);
815 synthesizedAttributes->push(defaultSynthesizedAttribute(inheritedValue));
826 if (treeTraversalOrder & postorder)
834 synthesizedAttributes->setFrameSize(numberOfSuccessors);
835 ROSE_ASSERT(synthesizedAttributes->size() == numberOfSuccessors);
836 synthesizedAttributes->push(evaluateSynthesizedAttribute(node, inheritedValue, *synthesizedAttributes));
841 if (treeTraversalOrder & postorder)
842 synthesizedAttributes->push(defaultSynthesizedAttribute(inheritedValue));
848 template <
class InheritedAttributeType,
class SynthesizedAttributeType>
858 if (synthesizedAttributes->debugSize() == 1)
860 return synthesizedAttributes->pop();
864 static SynthesizedAttributeType sa;
871 template <
class InheritedAttributeType,
class SynthesizedAttributeType>
878 template <
class InheritedAttributeType,
class SynthesizedAttributeType>
901 template <
class InheritedAttributeType,
class SynthesizedAttributeType>
908 template <
class InheritedAttributeType,
class SynthesizedAttributeType>
915 template <
class InheritedAttributeType>
922 template <
class InheritedAttributeType>
929 template <
class InheritedAttributeType>
936 template <
class SynthesizedAttributeType>
943 template <
class SynthesizedAttributeType>