Program Listing for File transformationTracking.h#
↰ Return to documentation for file (src/midend/programTransformation/transformationTracking/transformationTracking.h)
#ifndef TRANSFORMATION_TRACKING_H
#define TRANSFORMATION_TRACKING_H
#include <map>
#include <utility>
class SgNode;
class Sg_File_Info;
typedef unsigned int AST_NODE_ID;
namespace TransformationTracking
{
//X. Support for unique integer IDs for AST nodes.
// My first idea was to add a new field into SgNode.
// Markus reminded me that this will increase the size of AST for any situation.
// He suggested a more flexible way is to use separated data structures (map, vector, etc.) to
// maintain the IDs for each SgNode.
//
// IDs start from 1, Default value of 0 means a node has not assigned an ID.
//------------------------------------
// Public interface functions
void registerAstSubtreeIds (SgNode* root);
#if 0 // cannot really reassign IDs for the same node in this version
void clearId(SgNode* node);
void clearAstSubtreeIds(SgNode* root);
// This happens automatically now when an ID is assigned to a node.
// Replaced by an internal function copyBeginAndEndFileInfo()
// Store the file info. for each AST node
// current transformation process may erase file_info., even for subtree coming from the original source code.
// we need to keep the information at least for the top level node
// store begin and end file info for a node
void storeFileInfo(AST_NODE_ID id, Sg_File_Info* start, Sg_File_Info* end);
#endif
AST_NODE_ID getId (SgNode* );
// check if a node has been assigned a unique ID
bool hasId (SgNode* n);
//Obtain the SgNode from an ID
SgNode* getNode (AST_NODE_ID id);
// retrieve stored file info: both begin and end info.
std::pair <Sg_File_Info*, Sg_File_Info*> getFileInfo (AST_NODE_ID id);
// To simplify the problem,
// we keep track of information at a single line statement level.
//
// For a transformed (statement) node, add an input (statement) node.
// Internally, the input node's ID will be saved.
//
// This should be called after the transformation is completed and all IDs are assigned.
void addInputNode(SgNode* affected_node, SgNode* inputnode);
// Obtain the transformation input nodes for n
// directly use the exposed map variable inputIDs
//std::set getInputNodes (SgNode* n);
extern std::map<AST_NODE_ID, std::set<AST_NODE_ID> > inputIDs;
//-------------------------------------------------
// Internal functions
void setId (SgNode*);
// return the next Id which will be used (assigned to an AST node)
// This is also the same as the total number of IDs + 1. It can be used to control loop iteration over all IDs
AST_NODE_ID getNextId ();
} // end namespace TransformationTracking
#endif //TRANSFORMATION_TRACKING_H