ROSE  0.9.6a
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TransformationSupport Class Reference

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. More...

#include <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
}
 Enum values required to classify all possible overloaded C++ operators. More...
 

Static Public Member Functions

static std::string stringifyOperator (std::string name)
 generates a source code string from operator name. More...
 
static operatorCodeType classifyOverloadedOperator (std::string name, int numberOfParameters=0, bool prefixOperator=false)
 Classifies operator and returns an operatorCodeType value (useful for switch statements). More...
 
static std::string buildOperatorString (SgNode *astNode)
 Return string representing operator node in AST. More...
 
static std::string getFunctionName (SgFunctionCallExp *functionCallExp)
 Get the string representing the function name (should be added to Sage III interface). More...
 
static std::string getTypeName (SgType *type)
 Get the string representing the type name (should be added to Sage III interface). More...
 
static std::string getFunctionTypeName (SgFunctionCallExp *functionCallExpression)
 Similar to getFunctionName(SgNode* astNode) above, but for member functions. More...
 
static std::string buildMacro (std::string s)
 wrap any string representing a macro into something that the unparser will unparse as a macro definition More...
 
static std::string internalSupportingGlobalDeclarations (SgNode *astNode, std::string prefixString)
 Builds variable declarations for all variable and types defined in subtree at astNode. More...
 
static SgProjectgetProject (const SgNode *astNode)
 
static SgDirectorygetDirectory (const SgNode *astNode)
 
static SgFilegetFile (const SgNode *astNode)
 
static SgSourceFilegetSourceFile (const SgNode *astNode)
 
static SgBinaryCompositegetBinaryFile (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)
 
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. More...
 
static void getTransformationOptions (SgNode *astNode, std::list< int > &variableNameList, std::string identifingTypeName)
 Get the list<int> of options (if any are specified). More...
 
static void getTransformationOptionsFromVariableDeclarationConstructorArguments (SgVariableDeclaration *variableDeclaration, std::list< int > &returnList)
 Function used internally (for list<int> interface) More...
 
static void getTransformationOptionsFromVariableDeclarationConstructorArguments (SgVariableDeclaration *variableDeclaration, std::list< OptionDeclaration > &returnList)
 Function used internally (used with list<string> version of interface) More...
 

Detailed 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.

Member Enumeration Documentation

Enum values required to classify all possible overloaded C++ operators.

 Enum value supports the conversion of overloaded function names --> operator codes used to
 distiguish different sorts of transformations for each catagory of overloaded function.

We could not use the Cxx_GrammarVariants enum since it does not contain a classification for operator() and operator[].

Enumerator
FUNCTION_CALL_OPERATOR_CODE 

normal function call (used as the default value)

ADD_OPERATOR_CODE 
SUBT_OPERATOR_CODE 
MULT_OPERATOR_CODE 
DIV_OPERATOR_CODE 
INTEGER_DIV_OPERATOR_CODE 
MOD_OPERATOR_CODE 
AND_OPERATOR_CODE 
OR_OPERATOR_CODE 
BITXOR_OPERATOR_CODE 
BITAND_OPERATOR_CODE 
BITOR_OPERATOR_CODE 
EQ_OPERATOR_CODE 
LT_OPERATOR_CODE 
GT_OPERATOR_CODE 
NE_OPERATOR_CODE 
LE_OPERATOR_CODE 
GE_OPERATOR_CODE 
ASSIGN_OPERATOR_CODE 
PLUS_ASSIGN_OPERATOR_CODE 
MINUS_ASSIGN_OPERATOR_CODE 
AND_ASSIGN_OPERATOR_CODE 
IOR_ASSIGN_OPERATOR_CODE 
MULT_ASSIGN_OPERATOR_CODE 
DIV_ASSIGN_OPERATOR_CODE 
MOD_ASSIGN_OPERATOR_CODE 
XOR_ASSIGN_OPERATOR_CODE 
PARENTHESIS_OPERATOR_CODE 
BRACKET_OPERATOR_CODE 
NOT_OPERATOR_CODE 
DEREFERENCE_OPERATOR_CODE 
ADDRESS_OPERATOR_CODE 
LSHIFT_OPERATOR_CODE 
RSHIFT_OPERATOR_CODE 
LSHIFT_ASSIGN_OPERATOR_CODE 
RSHIFT_ASSIGN_OPERATOR_CODE 
PREFIX_PLUSPLUS_OPERATOR_CODE 
POSTFIX_PLUSPLUS_OPERATOR_CODE 
PREFIX_MINUSMINUS_OPERATOR_CODE 
POSTFIX_MINUSMINUS_OPERATOR_CODE 
OPERATOR_CODE_LAST_TAG 

Definition at line 37 of file transformationSupport.h.

Member Function Documentation

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 "+").

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).

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.

static std::string TransformationSupport::getFunctionName ( SgFunctionCallExp functionCallExp)
static

Get the string representing the function name (should be added to Sage III interface).

static std::string TransformationSupport::getTypeName ( SgType type)
static

Get the string representing the type name (should be added to Sage III interface).

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).

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.

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 ...

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

Get the list<int> of options (if any are specified).

Deprecated:
This function is superceeded by the more general form: getTransformationOptions (SgNode* astNode,list<OptionDeclaration>&variableNameList,string identifingTypeName )
static void TransformationSupport::getTransformationOptionsFromVariableDeclarationConstructorArguments ( SgVariableDeclaration variableDeclaration,
std::list< int > &  returnList 
)
static

Function used internally (for list<int> interface)

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

Function used internally (used with list<string> version of interface)

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.

There may be some cases where this mechanism can be outsmarted :-).

static SgProject* TransformationSupport::getProject ( const SgNode astNode)
static
static SgDirectory* TransformationSupport::getDirectory ( const SgNode astNode)
static
static SgFile* TransformationSupport::getFile ( const SgNode astNode)
static
static SgSourceFile* TransformationSupport::getSourceFile ( const SgNode astNode)
static
static SgBinaryComposite* TransformationSupport::getBinaryFile ( const SgNode astNode)
static
static SgGlobal* TransformationSupport::getGlobalScope ( const SgNode astNode)
static
static SgStatement* TransformationSupport::getStatement ( const SgNode astNode)
static
static SgFunctionDeclaration* TransformationSupport::getFunctionDeclaration ( const SgNode astNode)
static
static SgFunctionDefinition* TransformationSupport::getFunctionDefinition ( const SgNode astNode)
static
static SgClassDefinition* TransformationSupport::getClassDefinition ( const SgNode astNode)
static
static SgModuleStatement* TransformationSupport::getModuleStatement ( const SgNode astNode)
static
static SgDeclarationStatement* TransformationSupport::getTemplateDeclaration ( const SgNode astNode)
static

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