ROSE 0.11.145.147
sourceLocationInheritedAttribute.h
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:
14 SgProject* project;
15 SgFile* file;
16 SgGlobal* globalScope;
17 SgFunctionDefinition* currentFunctionDefinitionScope;
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.
23 SgBasicBlock* currentFunctionBasicBlockScope;
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!).
27 SgScopeStatement* loopNestParentScope;
28 SgScopeStatement* conditionalParentScope;
29
30 // Local scope can be either a SgBasicBlock, SgCatchOptionStmt, SgClassDefinition,
31 // SgDoWhileStmt, SgForStatement, SgFunctionDefinition, SgGlobal, SgIfStmt,
32 // SgSwitchStatement, and SgWhileStmt.
33 SgScopeStatement* localScope;
34
35 // Record the current statement so that we can easily retrive it in a consistant fashion as
36 // the other scope info.
37 SgStatement* currentStatement;
38
39 // Allow for later representation of expressions (though AST rewrite on expression level is
40 // not implemented yet).
41 SgExpression* currentExpression;
42
43 // Save the current AST node
44 SgNode* currentNode;
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;
82 SgNode* getCurrentFunctionScope() const;
83 SgNode* getLocalScope() const;
84 SgNode* getLoopNestParentScope() const;
85 SgNode* getConditionalParentScope() const;
86 SgNode* getParentScope() const;
87 SgNode* getCurrentFunctionBasicBlockScope() const;
88
89 SgNode* getCurrentDeclarationInGlobalScope() const;
90 SgNode* getCurrentStatement() const;
91 SgNode* getCurrentExpression() 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
This class represents the concept of a block (not a basic block from control flow analysis).
This class represents the notion of an expression. Expressions are derived from SgLocatedNodes,...
This class represents a source file for a project (which may contian many source files and or directo...
This class represents the concept of a scope in C++ (e.g. global scope, fuction scope,...
This class represents the concept of a namespace definition.
This class represents the base class for all IR nodes within Sage III.
This class represents a source project, with a list of SgFile objects and global information about th...
This class represents the concept of a scope in C++ (e.g. global scope, fuction scope,...
This class represents the notion of a statement.