ROSE  0.9.6a
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
sourceLocationInheritedAttribute.h
Go to the documentation of this file.
1 #ifndef SOURCE_LOCATION_INHERITED_ATTRIBUTE_H
2 #define SOURCE_LOCATION_INHERITED_ATTRIBUTE_H
3 
4 // class InheritedAttributeBaseClassType
6  {
7  // We want to suggest that users use the inherited attributes to represent all source code
8  // specific context. This is impossible to inforce (I think) but likely the representation of all
9  // context can be represented in the inherited attribute and the code to support this can be
10  // automatically generated. The following data is required to represent context (there might be a
11  // better way of doing this):
12 
13  public:
18 
19  // Different sorts of scopes (could be any scope not just a SgBasicBlock)
20 
21  // This is some what redundent since the the funtion body is available from the
22  // currentFunctionDefinition.
24 
25  // These are useful when we want to introduce transformations of loops but force hoisting of
26  // loop invariant code (which may not appear to be loop invariant to the compiler!).
29 
30  // Local scope can be either a SgBasicBlock, SgCatchOptionStmt, SgClassDefinition,
31  // SgDoWhileStmt, SgForStatement, SgFunctionDefinition, SgGlobal, SgIfStmt,
32  // SgSwitchStatement, and SgWhileStmt.
34 
35  // Record the current statement so that we can easily retrive it in a consistant fashion as
36  // the other scope info.
38 
39  // Allow for later representation of expressions (though AST rewrite on expression level is
40  // not implemented yet).
42 
43  // Save the current AST node
45 
46  // Use a vector instead of a stack so that we can iterate over the vector (since we don't do
47  // any random insertion we don't need a list).
48  std::vector<SgScopeStatement*> scopeList;
49 
50  // list of statements (can be more useful than just the list of scopes)
51  std::vector<SgStatement*> statementList;
52 
53  private:
54  // Define the default constructor as private so that it can't be used in any derived class
55  // SourceLocationInheritedAttribute ();
56 
57  public:
58  // Destructor
60 
61  // Constructors (the standard stuff)
65 
67 
68  // If we have to build one use this method instead of a default constructor
69  // static SourceLocationInheritedAttribute initialInstance();
70 
71  // Set all pointers to NULL (initialization)
72  void initialize();
73 
74  // Main function to define values for all class member data
75  void refineClassification ( SgNode* astNode );
76 
77  // Debugging info
78  void display( const std::string s ) const;
79 
80  // Access functions
81  SgNode* getGlobalScope() const;
83  SgNode* getLocalScope() const;
86  SgNode* getParentScope() const;
88 
90  SgNode* getCurrentStatement() const;
92  SgNode* getCurrentNode() const;
93 
94  SgNode* getCurrentStatementInScope( SgScopeStatement* targetScope ) const;
95 
96  // error checking (not sure this makes sense)
97  // void assertValidPointers();
98  };
99 
100 // endif for SOURCE_LOCATION_INHERITED_ATTRIBUTE_H
101 #endif