ROSE 0.11.145.147
Public Types | Static Public Member Functions | List of all members
TransformationSupport Class Reference

Description

This class simplifies the development of queries on the AST resulting in a list of AST nodes.

This class holds functions that are generally useful for a broad cross-section of transformations. Functionality specific to any specific transformation should be represented in a similar transformation support class that is a part of the preprocessor source code representing that specific transformation.

Definition at line 24 of file transformationSupport.h.

#include <roseSupport/transformationSupport.h>

Public Types

enum  operatorCodeType {
  FUNCTION_CALL_OPERATOR_CODE = 0 ,
  ADD_OPERATOR_CODE = 1 ,
  SUBT_OPERATOR_CODE = 2 ,
  MULT_OPERATOR_CODE = 3 ,
  DIV_OPERATOR_CODE = 4 ,
  INTEGER_DIV_OPERATOR_CODE = 5 ,
  MOD_OPERATOR_CODE = 6 ,
  AND_OPERATOR_CODE = 7 ,
  OR_OPERATOR_CODE = 8 ,
  BITXOR_OPERATOR_CODE = 9 ,
  BITAND_OPERATOR_CODE = 10 ,
  BITOR_OPERATOR_CODE = 11 ,
  EQ_OPERATOR_CODE = 12 ,
  LT_OPERATOR_CODE = 13 ,
  GT_OPERATOR_CODE = 14 ,
  NE_OPERATOR_CODE = 15 ,
  LE_OPERATOR_CODE = 16 ,
  GE_OPERATOR_CODE = 17 ,
  ASSIGN_OPERATOR_CODE = 18 ,
  PLUS_ASSIGN_OPERATOR_CODE = 19 ,
  MINUS_ASSIGN_OPERATOR_CODE = 20 ,
  AND_ASSIGN_OPERATOR_CODE = 21 ,
  IOR_ASSIGN_OPERATOR_CODE = 22 ,
  MULT_ASSIGN_OPERATOR_CODE = 23 ,
  DIV_ASSIGN_OPERATOR_CODE = 24 ,
  MOD_ASSIGN_OPERATOR_CODE = 25 ,
  XOR_ASSIGN_OPERATOR_CODE = 26 ,
  PARENTHESIS_OPERATOR_CODE = 27 ,
  BRACKET_OPERATOR_CODE = 28 ,
  NOT_OPERATOR_CODE = 29 ,
  DEREFERENCE_OPERATOR_CODE = 30 ,
  ADDRESS_OPERATOR_CODE = 31 ,
  LSHIFT_OPERATOR_CODE = 32 ,
  RSHIFT_OPERATOR_CODE = 33 ,
  LSHIFT_ASSIGN_OPERATOR_CODE = 34 ,
  RSHIFT_ASSIGN_OPERATOR_CODE = 35 ,
  PREFIX_PLUSPLUS_OPERATOR_CODE = 36 ,
  POSTFIX_PLUSPLUS_OPERATOR_CODE = 37 ,
  PREFIX_MINUSMINUS_OPERATOR_CODE = 38 ,
  POSTFIX_MINUSMINUS_OPERATOR_CODE = 39 ,
  OPERATOR_CODE_LAST_TAG = 99
}
 

Static Public Member Functions

static std::string stringifyOperator (std::string name)
 generates a source code string from operator name.
 
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 buildOperatorString (SgNode *astNode)
 Return string representing operator node in AST.
 
static std::string getFunctionName (SgFunctionCallExp *functionCallExp)
 Get the string representing the function name (should be added to Sage III interface).
 
static std::string getTypeName (SgType *type)
 Get the string representing the type name (should be added to Sage III interface).
 
static std::string getFunctionTypeName (SgFunctionCallExp *functionCallExpression)
 Similar to getFunctionName(SgNode* astNode) above, but for member functions.
 
static std::string buildMacro (std::string s)
 wrap any string representing a macro into something that the unparser will unparse as a macro definition
 
static std::string internalSupportingGlobalDeclarations (SgNode *astNode, std::string prefixString)
 Builds variable declarations for all variable and types defined in subtree at astNode.
 
static SgProjectgetProject (const SgNode *astNode)
 
static SgDirectorygetDirectory (const SgNode *astNode)
 
static SgFilegetFile (const SgNode *astNode)
 
static SgSourceFilegetSourceFile (const SgNode *astNode)
 
static SgGlobalgetGlobalScope (const SgNode *astNode)
 
static SgStatementgetStatement (const SgNode *astNode)
 
static SgFunctionDeclarationgetFunctionDeclaration (const SgNode *astNode)
 
static SgFunctionDefinitiongetFunctionDefinition (const SgNode *astNode)
 
static SgClassDefinitiongetClassDefinition (const SgNode *astNode)
 
static SgModuleStatementgetModuleStatement (const SgNode *astNode)
 
static SgDeclarationStatementgetTemplateDeclaration (const SgNode *astNode)
 
static SgTypegetAssociatedType (const SgNode *astNode)
 Find the associated type that might be a parent (through a parent chain) of the input SgNode.
 
Applications Specific Transformation Option Mechanism

Supporting functions for reading transformation specifications (hints)

Preprocessors can optionally retrive hints embedded within the user's application. The mechanism is useful to provide additional information used to make more sophisticated optimizations than the knowledge of the semantics of abstractions might provide. It also is a way to pass on information as a substitution for program analysis.

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 and values to associate with the identified option.
 
static void getTransformationOptions (SgNode *astNode, std::list< int > &variableNameList, std::string identifingTypeName)
 
static void getTransformationOptionsFromVariableDeclarationConstructorArguments (SgVariableDeclaration *variableDeclaration, std::list< int > &returnList)
 
static void getTransformationOptionsFromVariableDeclarationConstructorArguments (SgVariableDeclaration *variableDeclaration, std::list< OptionDeclaration > &returnList)
 

Member Enumeration Documentation

◆ operatorCodeType

Enumerator
FUNCTION_CALL_OPERATOR_CODE 

normal function call (used as the default value)

Definition at line 37 of file transformationSupport.h.

Member Function Documentation

◆ stringifyOperator()

static std::string TransformationSupport::stringifyOperator ( std::string  name)
static

generates a source code string from operator name.

This function returns a string representing the elementwise operator (for primative types) that would be match that associated with the overloaded operator for a user-defined abstractions (e.g. identifyOperator("operator+()") returns "+").

◆ classifyOverloadedOperator()

static operatorCodeType TransformationSupport::classifyOverloadedOperator ( std::string  name,
int  numberOfParameters = 0,
bool  prefixOperator = false 
)
static

Classifies operator and returns an operatorCodeType value (useful for switch statements).

This function is useful in switch statements to further refine the type of function based on the function name, number of parameters, and if it is a prefix or postfix operator. These are the minimum requirements to classify all possible C++ overloaded functions (though usually the name is sufficient so the additional parameters are optional).

◆ buildOperatorString()

static std::string TransformationSupport::buildOperatorString ( SgNode astNode)
static

Return string representing operator node in AST.

This function returns a string representing the operator associated with the SgNode* (assuming it is an SgExpression*). It calls the identifyOperator() function to convert overloaded functions to strings.

◆ getFunctionTypeName()

static std::string TransformationSupport::getFunctionTypeName ( SgFunctionCallExp functionCallExpression)
static

Similar to getFunctionName(SgNode* astNode) above, but for member functions.

For member fuinctions this returns the class name of the class for which this functon is a member and for non-member functions this function returns the name of the class associated with the return type (this might be done better).

◆ buildMacro()

static std::string TransformationSupport::buildMacro ( std::string  s)
static

wrap any string representing a macro into something that the unparser will unparse as a macro definition

This mechanism is a hack for now since it embeds a substring into a comment which the unparser presently will recognize. This needs to be fixed to work more cleanly.

◆ getTransformationOptions() [1/2]

static void TransformationSupport::getTransformationOptions ( SgNode astNode,
std::list< OptionDeclaration > &  variableNameList,
std::string  identifingTypeName 
)
static

This interface permits a more general specification of options using strings to identify the options and values to associate with the identified option.

See also
OptionDeclaration

This function is the only interface to the general mechanism that permits passing data from the user's application to a preprocessor. If this mechanism is used, the user's application is optionally annotated with declarations (which have no side-effect to the execution of the user's application) but which can be read and interpreted by a preprocessor. This function makes ...

◆ getTransformationOptions() [2/2]

static void TransformationSupport::getTransformationOptions ( SgNode astNode,
std::list< int > &  variableNameList,
std::string  identifingTypeName 
)
static

◆ getTransformationOptionsFromVariableDeclarationConstructorArguments() [1/2]

static void TransformationSupport::getTransformationOptionsFromVariableDeclarationConstructorArguments ( SgVariableDeclaration variableDeclaration,
std::list< int > &  returnList 
)
static

◆ getTransformationOptionsFromVariableDeclarationConstructorArguments() [2/2]

static void TransformationSupport::getTransformationOptionsFromVariableDeclarationConstructorArguments ( SgVariableDeclaration variableDeclaration,
std::list< OptionDeclaration > &  returnList 
)
static

◆ internalSupportingGlobalDeclarations()

static std::string TransformationSupport::internalSupportingGlobalDeclarations ( SgNode astNode,
std::string  prefixString 
)
static

Builds variable declarations for all variable and types defined in subtree at astNode.

New variables and types introduced by way of a transformation need to be defined in the application before they are used. This sort of transofrmation can be generally automated.


The documentation for this class was generated from the following file: