coins.alias
Class TagTreeBuilder

java.lang.Object
  extended bycoins.ir.hir.HirVisitorModel2
      extended bycoins.alias.TagTreeBuilder
All Implemented Interfaces:
HirVisitor

class TagTreeBuilder
extends HirVisitorModel2

Builds tag tree and assigns tags to HIR nodes.


Field Summary
(package private)  java.util.Map fHIRTomallocTag
          Map from malloc invocation HIR nodes to corresponding Tags.
(package private)  java.util.List fParentlessTags
          Tags corresponding to each named variable and allocated area and unknown external area.
(package private)  int fTagBitCount
          Total number of Tags that have a bit position assigned in the TagVector.
 
Fields inherited from class coins.ir.hir.HirVisitorModel2
fDbgLevel, hirRoot, ioRoot, symRoot
 
Constructor Summary
(package private) TagTreeBuilder(SubpDefinition pSubpDef, MyExpId[] pMyExpIds, boolean pIsOptimistic, HirRoot pHirRoot)
          Creates a new instance of TagTreeBuilder
 
Method Summary
 void atExp(Exp pExp)
          Visits the children of the specified argument, creates a Tag for the MyExpId attached to the specified argument if it is lvalue and not yet done, and registers the node-Tag correspondence into a global map.
 void atFunctionExp(FunctionExp pExp)
          Visits the children of the specified argument, and, if the specified argument is the C malloc library function call node, creates a Tag for the area allocated by the call and registers the node-Tag correspondence into a global map.
 void atPointedExp(PointedExp pExp)
          Visits the children of the specified argument, creates a Tag for the MyExpId attached to the specified argument if it is not yet done, and registers the node-Tag correspondence into a global map.
 void atQualifiedExp(QualifiedExp pExp)
          Visits the children of the specified argument, and if the specified argument is lvalue, creates a Tag for the MyExpId attached to the specified argument if it is not yet done, and registers the node-Tag correspondence into a global map.
 void atSubscriptedExp(SubscriptedExp pExp)
          Visits the children of the specified argument, and if the specified argument is not lvalue, creates a Tag for the MyExpId attached to the specified argument if it is not yet done, and registers the node-Tag correspondence into a global map.
 void atVarNode(VarNode pVarNode)
          Creates a Tag for the Var attached to the specified argument if it is not yet done, and registers the node-Tag correspondence into a global map.
(package private)  java.util.Map process()
          Builds the Tag tree.
 
Methods inherited from class coins.ir.hir.HirVisitorModel2
atAsmStmt, atAssignStmt, atBlockStmt, atConstNode, atElemNode, atExpStmt, atForStmt, atHirList, atHirSeq, atIfStmt, atIndexedLoopStmt, atInfNode, atInfStmt, atIrList, atJumpStmt, atLabelDef, atLabeledStmt, atLabelNode, atLoopStmt, atNullNode, atPhiExp, atProgram, atRepeatStmt, atReturnStmt, atSubpDefinition, atSubpNode, atSwitchStmt, atSymNode, atTypeNode, atUntilStmt, atWhileStmt, visit, visitChildren
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

fTagBitCount

int fTagBitCount
Total number of Tags that have a bit position assigned in the TagVector.


fHIRTomallocTag

java.util.Map fHIRTomallocTag
Map from malloc invocation HIR nodes to corresponding Tags.


fParentlessTags

java.util.List fParentlessTags
Tags corresponding to each named variable and allocated area and unknown external area. The whole area in memory that can be referred to by the subprogram under consideraion is covered by the tags that are in this List.

Constructor Detail

TagTreeBuilder

TagTreeBuilder(SubpDefinition pSubpDef,
               MyExpId[] pMyExpIds,
               boolean pIsOptimistic,
               HirRoot pHirRoot)
Creates a new instance of TagTreeBuilder

Parameters:
pSubpDef - the SubpDefinition object this module is responsible for.
pMyExpIds - the array of MyExpId objects, with HIR node's index as its index. This serves as the map from HIR nodes to MyExpId objects.
pHirRoot - the HirRoot object shared by every module in the program.
Method Detail

process

java.util.Map process()
Builds the Tag tree. It creates a Tag for each MyExpId that is lvalue, builds tree relation between those Tags, and makes a Map from HIR nodes to such Tags.

Returns:
the Map from HIR nodes to Tags.

atVarNode

public void atVarNode(VarNode pVarNode)
Creates a Tag for the Var attached to the specified argument if it is not yet done, and registers the node-Tag correspondence into a global map.

Specified by:
atVarNode in interface HirVisitor
Overrides:
atVarNode in class HirVisitorModel2
Parameters:
pVarNode - the VarNode the Var attached to which is going to be assigned a Tag.

atSubscriptedExp

public void atSubscriptedExp(SubscriptedExp pExp)
Visits the children of the specified argument, and if the specified argument is not lvalue, creates a Tag for the MyExpId attached to the specified argument if it is not yet done, and registers the node-Tag correspondence into a global map.

Specified by:
atSubscriptedExp in interface HirVisitor
Overrides:
atSubscriptedExp in class HirVisitorModel2
Parameters:
pExp - the SubscriptedExp the MyExpId attached to which is going to be assigned a Tag.

atQualifiedExp

public void atQualifiedExp(QualifiedExp pExp)
Visits the children of the specified argument, and if the specified argument is lvalue, creates a Tag for the MyExpId attached to the specified argument if it is not yet done, and registers the node-Tag correspondence into a global map.

Specified by:
atQualifiedExp in interface HirVisitor
Overrides:
atQualifiedExp in class HirVisitorModel2
Parameters:
pExp - the QualifiedExp the MyExpId attached to which is going to be assigned a Tag.

atPointedExp

public void atPointedExp(PointedExp pExp)
Visits the children of the specified argument, creates a Tag for the MyExpId attached to the specified argument if it is not yet done, and registers the node-Tag correspondence into a global map.

Specified by:
atPointedExp in interface HirVisitor
Overrides:
atPointedExp in class HirVisitorModel2
Parameters:
pExp - the PointedExp the MyExpId attached to which is going to be assigned a Tag.

atExp

public void atExp(Exp pExp)
Visits the children of the specified argument, creates a Tag for the MyExpId attached to the specified argument if it is lvalue and not yet done, and registers the node-Tag correspondence into a global map.

Specified by:
atExp in interface HirVisitor
Overrides:
atExp in class HirVisitorModel2
Parameters:
pExp - the Exp the MyExpId attached to which is going to be assigned a Tag.

atFunctionExp

public void atFunctionExp(FunctionExp pExp)
Visits the children of the specified argument, and, if the specified argument is the C malloc library function call node, creates a Tag for the area allocated by the call and registers the node-Tag correspondence into a global map.

Specified by:
atFunctionExp in interface HirVisitor
Overrides:
atFunctionExp in class HirVisitorModel2
Parameters:
pExp - the FunctionExp the area allocated by which is going to be assigned a Tag.