Class SSACFG.BasicBlock
java.lang.Object
com.ibm.wala.ssa.SSACFG.BasicBlock
- All Implemented Interfaces:
IBasicBlock<SSAInstruction>
,ISSABasicBlock
,INodeWithNumber
,Iterable<SSAInstruction>
- Direct Known Subclasses:
SSACFG.ExceptionHandlerBasicBlock
- Enclosing class:
SSACFG
A Basic Block in an SSA IR
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addPhiForLocal
(int n, SSAPhiInstruction phi) void
addPhiForStackSlot
(int slot, SSAPhiInstruction phi) void
addPiForRefAndPath
(int n, Object path, SSAPiInstruction pi) boolean
TODO: make this more efficient if neededTheSSACFG.ExceptionHandlerBasicBlock
subclass will override this.int
Method getFirstInstructionIndex.int
A non-negative integer which serves as an identifier for this node in it's "dominant" graph.int
Get the index of the last instruction in the basic block.int
Each basic block should have a unique number in its cfggetPhiForLocal
(int n) This method is used during SSA construction.getPhiForStackSlot
(int slot) This method is used during SSA construction.getPiForRefAndPath
(int n, Object path) int
hashCode()
boolean
hasPhi()
boolean
Is this block marked as a catch block?boolean
Does this block represent the unique entry to aControlFlowGraph
boolean
Does this block represent the unique exit from aControlFlowGraph
?iterator()
void
removePhis
(Set<SSAPhiInstruction> toRemove) Remove any phis in the set.void
setGraphNodeId
(int number) toString()
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
BasicBlock
public BasicBlock(int number)
-
-
Method Details
-
getNumber
public int getNumber()Description copied from interface:IBasicBlock
Each basic block should have a unique number in its cfg- Specified by:
getNumber
in interfaceIBasicBlock<SSAInstruction>
- Returns:
- the basic block's number
-
getFirstInstructionIndex
public int getFirstInstructionIndex()Method getFirstInstructionIndex.- Specified by:
getFirstInstructionIndex
in interfaceIBasicBlock<SSAInstruction>
- Returns:
- the instruction index for the first instruction in the basic block.
-
isCatchBlock
public boolean isCatchBlock()Is this block marked as a catch block?- Specified by:
isCatchBlock
in interfaceIBasicBlock<SSAInstruction>
- Specified by:
isCatchBlock
in interfaceISSABasicBlock
- Returns:
- true if the basic block represents a catch block.
-
getLastInstructionIndex
public int getLastInstructionIndex()Description copied from interface:IBasicBlock
Get the index of the last instruction in the basic block. The value is an index into the instruction array that contains all the instructions for the method.If the result is < 0, the block has no instructions
- Specified by:
getLastInstructionIndex
in interfaceIBasicBlock<SSAInstruction>
- Returns:
- the instruction index for the last instruction in the basic block
-
iteratePhis
- Specified by:
iteratePhis
in interfaceISSABasicBlock
- Returns:
- the phi instructions incoming to this block
-
getPhiForStackSlot
This method is used during SSA construction. -
getPhiForLocal
This method is used during SSA construction. -
addPhiForStackSlot
-
addPhiForLocal
-
removePhis
Remove any phis in the set. -
getPiForRefAndPath
-
addPiForRefAndPath
- Parameters:
n
- can be the val in the pi instructionpath
- can be the successor block in the pi instruction
-
iteratePis
- Specified by:
iteratePis
in interfaceISSABasicBlock
- Returns:
- the pi instructions incoming to this block
-
iterateNormalInstructions
-
getAllInstructions
TODO: make this more efficient if needed -
iterator
- Specified by:
iterator
in interfaceIterable<SSAInstruction>
-
hasPhi
public boolean hasPhi()- Returns:
- true iff this basic block has at least one phi
-
getGraphNodeId
public int getGraphNodeId()Description copied from interface:INodeWithNumber
A non-negative integer which serves as an identifier for this node in it's "dominant" graph. Initially this number is -1; a NumberedGraph will set it to a non-negative value when this node is inserted into the graph- Specified by:
getGraphNodeId
in interfaceINodeWithNumber
- Returns:
- the identifier
- See Also:
-
setGraphNodeId
public void setGraphNodeId(int number) - Specified by:
setGraphNodeId
in interfaceINodeWithNumber
- See Also:
-
toString
-
equals
-
getMethod
- Specified by:
getMethod
in interfaceIBasicBlock<SSAInstruction>
- Returns:
- governing method for this block
-
hashCode
-
isExitBlock
public boolean isExitBlock()Description copied from interface:ISSABasicBlock
Does this block represent the unique exit from aControlFlowGraph
?- Specified by:
isExitBlock
in interfaceIBasicBlock<SSAInstruction>
- Specified by:
isExitBlock
in interfaceISSABasicBlock
- Returns:
- true if the basic block represents the unique exit block.
- See Also:
-
isEntryBlock
public boolean isEntryBlock()Description copied from interface:ISSABasicBlock
Does this block represent the unique entry to aControlFlowGraph
- Specified by:
isEntryBlock
in interfaceIBasicBlock<SSAInstruction>
- Specified by:
isEntryBlock
in interfaceISSABasicBlock
- Returns:
- true if the basic block represents the unique entry block.
- See Also:
-
getLastInstruction
- Specified by:
getLastInstruction
in interfaceISSABasicBlock
- Returns:
- the last instruction in this block.
-
getCaughtExceptionTypes
TheSSACFG.ExceptionHandlerBasicBlock
subclass will override this.- Specified by:
getCaughtExceptionTypes
in interfaceISSABasicBlock
- Returns:
- the set of exception types this block may catch.
-