ROSE 0.11.145.147
transformationSupport.h
1#ifndef ROSE_TRANSFORMATION_SUPPORT
2#define ROSE_TRANSFORMATION_SUPPORT
3
4// #include "transformationOptions.h"
5
6#include "optionDeclaration.h"
7
8// Access to Query Libraries
9#include "roseQueryLib.h"
10
11// include "nodeQuery.h"
12// include "nameQuery.h"
13// include "numberQuery.h"
14
24class ROSE_DLL_API TransformationSupport
25 {
26 public:
27
38 {
40 FUNCTION_CALL_OPERATOR_CODE = 0,
41
42 // binary operators
43 ADD_OPERATOR_CODE = 1,
44 SUBT_OPERATOR_CODE = 2,
45 MULT_OPERATOR_CODE = 3,
46 DIV_OPERATOR_CODE = 4,
47 INTEGER_DIV_OPERATOR_CODE = 5,
48 MOD_OPERATOR_CODE = 6,
49 AND_OPERATOR_CODE = 7,
50 OR_OPERATOR_CODE = 8,
51 BITXOR_OPERATOR_CODE = 9,
52 BITAND_OPERATOR_CODE = 10,
53 BITOR_OPERATOR_CODE = 11,
54 EQ_OPERATOR_CODE = 12,
55 LT_OPERATOR_CODE = 13,
56 GT_OPERATOR_CODE = 14,
57 NE_OPERATOR_CODE = 15,
58 LE_OPERATOR_CODE = 16,
59 GE_OPERATOR_CODE = 17,
60 ASSIGN_OPERATOR_CODE = 18,
61 PLUS_ASSIGN_OPERATOR_CODE = 19,
62 MINUS_ASSIGN_OPERATOR_CODE = 20,
63 AND_ASSIGN_OPERATOR_CODE = 21,
64 IOR_ASSIGN_OPERATOR_CODE = 22,
65 MULT_ASSIGN_OPERATOR_CODE = 23,
66 DIV_ASSIGN_OPERATOR_CODE = 24,
67 MOD_ASSIGN_OPERATOR_CODE = 25,
68 XOR_ASSIGN_OPERATOR_CODE = 26,
69
70 // operator() and operator[]
71 PARENTHESIS_OPERATOR_CODE = 27,
72 BRACKET_OPERATOR_CODE = 28,
73
74 // unary operators
75 NOT_OPERATOR_CODE = 29,
76 DEREFERENCE_OPERATOR_CODE = 30,
77 ADDRESS_OPERATOR_CODE = 31,
78 LSHIFT_OPERATOR_CODE = 32,
79 RSHIFT_OPERATOR_CODE = 33,
80 LSHIFT_ASSIGN_OPERATOR_CODE = 34,
81 RSHIFT_ASSIGN_OPERATOR_CODE = 35,
82 PREFIX_PLUSPLUS_OPERATOR_CODE = 36,
83 POSTFIX_PLUSPLUS_OPERATOR_CODE = 37,
84 PREFIX_MINUSMINUS_OPERATOR_CODE = 38,
85 POSTFIX_MINUSMINUS_OPERATOR_CODE = 39,
86
87 // End of list tag
88 OPERATOR_CODE_LAST_TAG = 99
89 };
90
97 static std::string stringifyOperator (std::string name);
98
109 std::string name,
110 int numberOfParameters = 0,
111 bool prefixOperator = false);
112
119 static std::string buildOperatorString ( SgNode* astNode );
120
122 static std::string getFunctionName ( SgFunctionCallExp* functionCallExp );
123
125 static std::string getTypeName ( SgType* type );
126
133 static std::string getFunctionTypeName ( SgFunctionCallExp* functionCallExpression );
134
141 static std::string buildMacro ( std::string s );
142
161 SgNode* astNode,
162 std::list<OptionDeclaration> & variableNameList,
163 std::string identifingTypeName );
164
173 SgNode* astNode,
174 std::list<int> & variableNameList,
175 std::string identifingTypeName );
176
182 SgVariableDeclaration* variableDeclaration,
183 std::list<int> & returnList );
184
190 SgVariableDeclaration* variableDeclaration,
191 std::list<OptionDeclaration> & returnList );
202 static std::string internalSupportingGlobalDeclarations( SgNode* astNode, std::string prefixString );
203
204 // DQ (9/26/03) Added here to eliminate ProjectQueryLibrary
205 // (which as mostly an experiment with the reverse traversal)
206 static SgProject* getProject( const SgNode* astNode);
207 static SgDirectory* getDirectory( const SgNode* astNode);
208 static SgFile* getFile( const SgNode* astNode);
209 static SgSourceFile* getSourceFile( const SgNode* astNode);
210#ifdef ROSE_ENABLE_BINARY_ANALYSIS
211 static SgBinaryComposite* getBinaryFile( const SgNode* astNode);
212#endif
213 static SgGlobal* getGlobalScope( const SgNode* astNode);
214 static SgStatement* getStatement(const SgNode* astNode);
215 static SgFunctionDeclaration* getFunctionDeclaration( const SgNode* astNode);
216 static SgFunctionDefinition* getFunctionDefinition( const SgNode* astNode);
217 static SgClassDefinition* getClassDefinition( const SgNode* astNode);
218 static SgModuleStatement* getModuleStatement( const SgNode* astNode);
219
220 // DQ (7/25/2012): Modified to reflect new template design using different types of template IR nodes.
221 // static SgTemplateDeclaration* getTemplateDeclaration( const SgNode* astNode);
222 static SgDeclarationStatement* getTemplateDeclaration( const SgNode* astNode);
223
224 // DQ (8/19/2014): Iterate back through the parents and scopes to find the SgType that the current node is embedded into.
229 static SgType* getAssociatedType( const SgNode* astNode );
230
231 // DQ (5/11/2011): This function was moved to SgTemplateArgument a long time ago and is not longer available.
232 // DQ (6/9/2007): This function traverses through the parents to the first scope (used for name qualification support of template arguments)
233 // static SgScopeStatement* getScope(const SgNode* astNode);
234
235 // static SgValueExp* getValueExpr(const SgNode* astNode);
236 };
237
238// endif for ROSE_TRANSFORMATION_SUPPORT
239#endif
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
This class represents the concept of a class definition in C++.
This class represents the concept of a declaration statement.
This class represents a directory within a projects file structure of files and directories.
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 C++ function call (which is an expression).
This class represents the concept of a function declaration statement.
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 notion of a statement.
This class represents the base class for all types.
This class represents the concept of a C or C++ variable declaration.
This class simplifies the development of queries on the AST resulting in a list of AST nodes.
static void getTransformationOptions(SgNode *astNode, std::list< int > &variableNameList, std::string identifingTypeName)
static void getTransformationOptionsFromVariableDeclarationConstructorArguments(SgVariableDeclaration *variableDeclaration, std::list< OptionDeclaration > &returnList)
static SgType * getAssociatedType(const SgNode *astNode)
Find the associated type that might be a parent (through a parent chain) of the input SgNode.
static operatorCodeType classifyOverloadedOperator(std::string name, int numberOfParameters=0, bool prefixOperator=false)
Classifies operator and returns an operatorCodeType value (useful for switch statements).
static std::string buildMacro(std::string s)
wrap any string representing a macro into something that the unparser will unparse as a macro definit...
static std::string buildOperatorString(SgNode *astNode)
Return string representing operator node in AST.
static std::string getTypeName(SgType *type)
Get the string representing the type name (should be added to Sage III interface).
static std::string internalSupportingGlobalDeclarations(SgNode *astNode, std::string prefixString)
Builds variable declarations for all variable and types defined in subtree at astNode.
static void getTransformationOptions(SgNode *astNode, std::list< OptionDeclaration > &variableNameList, std::string identifingTypeName)
This interface permits a more general specification of options using strings to identify the options ...
static std::string stringifyOperator(std::string name)
generates a source code string from operator name.
static std::string getFunctionTypeName(SgFunctionCallExp *functionCallExpression)
Similar to getFunctionName(SgNode* astNode) above, but for member functions.
static std::string getFunctionName(SgFunctionCallExp *functionCallExp)
Get the string representing the function name (should be added to Sage III interface).
static void getTransformationOptionsFromVariableDeclarationConstructorArguments(SgVariableDeclaration *variableDeclaration, std::list< int > &returnList)