Package com.ibm.wala.ssa
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
public class SSACFG.BasicBlock extends Object implements ISSABasicBlock
A Basic Block in an SSA IR
-
-
Constructor Summary
Constructors Constructor Description BasicBlock(int number)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addPhiForLocal(int n, SSAPhiInstruction phi)
void
addPhiForStackSlot(int slot, SSAPhiInstruction phi)
void
addPiForRefAndPath(int n, Object path, SSAPiInstruction pi)
boolean
equals(Object arg0)
List<SSAInstruction>
getAllInstructions()
TODO: make this more efficient if neededIterator<TypeReference>
getCaughtExceptionTypes()
TheSSACFG.ExceptionHandlerBasicBlock
subclass will override this.int
getFirstInstructionIndex()
Method getFirstInstructionIndex.int
getGraphNodeId()
A non-negative integer which serves as an identifier for this node in it's "dominant" graph.SSAInstruction
getLastInstruction()
int
getLastInstructionIndex()
Get the index of the last instruction in the basic block.IMethod
getMethod()
int
getNumber()
Each basic block should have a unique number in its cfgSSAPhiInstruction
getPhiForLocal(int n)
This method is used during SSA construction.SSAPhiInstruction
getPhiForStackSlot(int slot)
This method is used during SSA construction.SSAPiInstruction
getPiForRefAndPath(int n, Object path)
int
hashCode()
boolean
hasPhi()
boolean
isCatchBlock()
Is this block marked as a catch block?boolean
isEntryBlock()
Does this block represent the unique entry to aControlFlowGraph
boolean
isExitBlock()
Does this block represent the unique exit from aControlFlowGraph
?Iterator<SSAInstruction>
iterateNormalInstructions()
Iterator<SSAPhiInstruction>
iteratePhis()
Iterator<SSAPiInstruction>
iteratePis()
Iterator<SSAInstruction>
iterator()
void
removePhis(Set<SSAPhiInstruction> toRemove)
Remove any phis in the set.void
setGraphNodeId(int number)
String
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
-
-
-
-
Method Detail
-
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
public Iterator<SSAPhiInstruction> iteratePhis()
- Specified by:
iteratePhis
in interfaceISSABasicBlock
- Returns:
- the phi instructions incoming to this block
-
getPhiForStackSlot
public SSAPhiInstruction getPhiForStackSlot(int slot)
This method is used during SSA construction.
-
getPhiForLocal
public SSAPhiInstruction getPhiForLocal(int n)
This method is used during SSA construction.
-
addPhiForStackSlot
public void addPhiForStackSlot(int slot, SSAPhiInstruction phi)
-
addPhiForLocal
public void addPhiForLocal(int n, SSAPhiInstruction phi)
-
removePhis
public void removePhis(Set<SSAPhiInstruction> toRemove)
Remove any phis in the set.
-
getPiForRefAndPath
public SSAPiInstruction getPiForRefAndPath(int n, Object path)
-
addPiForRefAndPath
public void addPiForRefAndPath(int n, Object path, SSAPiInstruction pi)
- Parameters:
n
- can be the val in the pi instructionpath
- can be the successor block in the pi instructionpi
-
-
iteratePis
public Iterator<SSAPiInstruction> iteratePis()
- Specified by:
iteratePis
in interfaceISSABasicBlock
- Returns:
- the pi instructions incoming to this block
-
iterateNormalInstructions
public Iterator<SSAInstruction> iterateNormalInstructions()
-
getAllInstructions
public List<SSAInstruction> getAllInstructions()
TODO: make this more efficient if needed
-
iterator
public Iterator<SSAInstruction> 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
-
setGraphNodeId
public void setGraphNodeId(int number)
- Specified by:
setGraphNodeId
in interfaceINodeWithNumber
-
toString
public String toString()
- Overrides:
toString
in classObject
- See Also:
Object.toString()
-
getMethod
public IMethod getMethod()
- Specified by:
getMethod
in interfaceIBasicBlock<SSAInstruction>
- Returns:
- governing method for this block
-
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.
-
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.
-
getLastInstruction
public SSAInstruction getLastInstruction()
- Specified by:
getLastInstruction
in interfaceISSABasicBlock
- Returns:
- the last instruction in this block.
-
getCaughtExceptionTypes
public Iterator<TypeReference> getCaughtExceptionTypes()
TheSSACFG.ExceptionHandlerBasicBlock
subclass will override this.- Specified by:
getCaughtExceptionTypes
in interfaceISSABasicBlock
- Returns:
- the set of exception types this block may catch.
- See Also:
ISSABasicBlock.getCaughtExceptionTypes()
-
-