00001 #pragma once
00002
00003 #include <rose.h>
00004
00005 struct FunctionCallInheritedAttribute
00006 {
00009 SgScopeStatement* currentLoop;
00010
00012 SgStatement* lastStatement;
00013
00015 enum
00016 {
00017 INSIDE_FOR_INIT, INSIDE_FOR_TEST, INSIDE_FOR_INCREMENT, INSIDE_WHILE_CONDITION,
00018 INSIDE_DO_WHILE_CONDITION, NOT_IN_LOOP
00019 }
00020 loopStatus;
00021
00023 FunctionCallInheritedAttribute() : currentLoop(NULL), lastStatement(NULL), loopStatus(NOT_IN_LOOP) { }
00024 };
00025
00027 struct FunctionCallInfo
00028 {
00030 SgFunctionCallExp* functionCall;
00031
00034 SgStatement* tempVarDeclarationLocation;
00035
00037 enum InsertionMode
00038 {
00040 INSERT_BEFORE,
00042 APPEND_SCOPE,
00043 INVALID
00044 };
00045
00047 InsertionMode tempVarDeclarationInsertionMode;
00048
00049 FunctionCallInfo(SgFunctionCallExp * function) :
00050 functionCall(function),
00051 tempVarDeclarationLocation(NULL),
00052 tempVarDeclarationInsertionMode(INVALID) { }
00053 };
00054
00055
00058
00059 class FunctionEvaluationOrderTraversal : public AstTopDownBottomUpProcessing<FunctionCallInheritedAttribute, bool>
00060 {
00061 public:
00064 static std::vector<FunctionCallInfo> GetFunctionCalls(SgNode* root);
00065
00067 FunctionCallInheritedAttribute evaluateInheritedAttribute(SgNode* astNode, FunctionCallInheritedAttribute parentAttribute);
00068
00070 bool evaluateSynthesizedAttribute(SgNode* astNode, FunctionCallInheritedAttribute parentAttribute, SynthesizedAttributesList);
00071
00072 private:
00073
00075
00076 FunctionEvaluationOrderTraversal() { }
00077
00079 std::vector<FunctionCallInfo> functionCalls;
00080 };