00001 #ifndef SOURCE_LOCATION_INHERITED_ATTRIBUTE_H 00002 #define SOURCE_LOCATION_INHERITED_ATTRIBUTE_H 00003 00004 // class InheritedAttributeBaseClassType 00005 class SourceLocationInheritedAttribute 00006 { 00007 // We want to suggest that users use the inherited attributes to represent all source code 00008 // specific context. This is impossible to inforce (I think) but likely the representation of all 00009 // context can be represented in the inherited attribute and the code to support this can be 00010 // automatically generated. The following data is required to represent context (there might be a 00011 // better way of doing this): 00012 00013 public: 00014 SgProject* project; 00015 SgFile* file; 00016 SgGlobal* globalScope; 00017 SgFunctionDefinition* currentFunctionDefinitionScope; 00018 00019 // Different sorts of scopes (could be any scope not just a SgBasicBlock) 00020 00021 // This is some what redundent since the the funtion body is available from the 00022 // currentFunctionDefinition. 00023 SgBasicBlock* currentFunctionBasicBlockScope; 00024 00025 // These are useful when we want to introduce transformations of loops but force hoisting of 00026 // loop invariant code (which may not appear to be loop invariant to the compiler!). 00027 SgScopeStatement* loopNestParentScope; 00028 SgScopeStatement* conditionalParentScope; 00029 00030 // Local scope can be either a SgBasicBlock, SgCatchOptionStmt, SgClassDefinition, 00031 // SgDoWhileStmt, SgForStatement, SgFunctionDefinition, SgGlobal, SgIfStmt, 00032 // SgSwitchStatement, and SgWhileStmt. 00033 SgScopeStatement* localScope; 00034 00035 // Record the current statement so that we can easily retrive it in a consistant fashion as 00036 // the other scope info. 00037 SgStatement* currentStatement; 00038 00039 // Allow for later representation of expressions (though AST rewrite on expression level is 00040 // not implemented yet). 00041 SgExpression* currentExpression; 00042 00043 // Save the current AST node 00044 SgNode* currentNode; 00045 00046 // Use a vector instead of a stack so that we can iterate over the vector (since we don't do 00047 // any random insertion we don't need a list). 00048 std::vector<SgScopeStatement*> scopeList; 00049 00050 // list of statements (can be more useful than just the list of scopes) 00051 std::vector<SgStatement*> statementList; 00052 00053 private: 00054 // Define the default constructor as private so that it can't be used in any derived class 00055 // SourceLocationInheritedAttribute (); 00056 00057 public: 00058 // Destructor 00059 virtual ~SourceLocationInheritedAttribute (); 00060 00061 // Constructors (the standard stuff) 00062 SourceLocationInheritedAttribute ( SgNode* astNode ); 00063 SourceLocationInheritedAttribute ( const SourceLocationInheritedAttribute & X ); 00064 SourceLocationInheritedAttribute ( const SourceLocationInheritedAttribute & X, SgNode* astNode ); 00065 00066 SourceLocationInheritedAttribute & operator= ( const SourceLocationInheritedAttribute & X ); 00067 00068 // If we have to build one use this method instead of a default constructor 00069 // static SourceLocationInheritedAttribute initialInstance(); 00070 00071 // Set all pointers to NULL (initialization) 00072 void initialize(); 00073 00074 // Main function to define values for all class member data 00075 void refineClassification ( SgNode* astNode ); 00076 00077 // Debugging info 00078 void display( const std::string s ) const; 00079 00080 // Access functions 00081 SgNode* getGlobalScope() const; 00082 SgNode* getCurrentFunctionScope() const; 00083 SgNode* getLocalScope() const; 00084 SgNode* getLoopNestParentScope() const; 00085 SgNode* getConditionalParentScope() const; 00086 SgNode* getParentScope() const; 00087 SgNode* getCurrentFunctionBasicBlockScope() const; 00088 00089 SgNode* getCurrentDeclarationInGlobalScope() const; 00090 SgNode* getCurrentStatement() const; 00091 SgNode* getCurrentExpression() const; 00092 SgNode* getCurrentNode() const; 00093 00094 SgNode* getCurrentStatementInScope( SgScopeStatement* targetScope ) const; 00095 00096 // error checking (not sure this makes sense) 00097 // void assertValidPointers(); 00098 }; 00099 00100 // endif for SOURCE_LOCATION_INHERITED_ATTRIBUTE_H 00101 #endif
1.4.7