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 voidaddPhiForLocal(int n, SSAPhiInstruction phi)voidaddPhiForStackSlot(int slot, SSAPhiInstruction phi)voidaddPiForRefAndPath(int n, Object path, SSAPiInstruction pi)booleanequals(Object arg0)List<SSAInstruction>getAllInstructions()TODO: make this more efficient if neededIterator<TypeReference>getCaughtExceptionTypes()TheSSACFG.ExceptionHandlerBasicBlocksubclass will override this.intgetFirstInstructionIndex()Method getFirstInstructionIndex.intgetGraphNodeId()A non-negative integer which serves as an identifier for this node in it's "dominant" graph.SSAInstructiongetLastInstruction()intgetLastInstructionIndex()Get the index of the last instruction in the basic block.IMethodgetMethod()intgetNumber()Each basic block should have a unique number in its cfgSSAPhiInstructiongetPhiForLocal(int n)This method is used during SSA construction.SSAPhiInstructiongetPhiForStackSlot(int slot)This method is used during SSA construction.SSAPiInstructiongetPiForRefAndPath(int n, Object path)inthashCode()booleanhasPhi()booleanisCatchBlock()Is this block marked as a catch block?booleanisEntryBlock()Does this block represent the unique entry to aControlFlowGraphbooleanisExitBlock()Does this block represent the unique exit from aControlFlowGraph?Iterator<SSAInstruction>iterateNormalInstructions()Iterator<SSAPhiInstruction>iteratePhis()Iterator<SSAPiInstruction>iteratePis()Iterator<SSAInstruction>iterator()voidremovePhis(Set<SSAPhiInstruction> toRemove)Remove any phis in the set.voidsetGraphNodeId(int number)StringtoString()-
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:IBasicBlockEach basic block should have a unique number in its cfg- Specified by:
getNumberin interfaceIBasicBlock<SSAInstruction>- Returns:
- the basic block's number
-
getFirstInstructionIndex
public int getFirstInstructionIndex()
Method getFirstInstructionIndex.- Specified by:
getFirstInstructionIndexin 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:
isCatchBlockin interfaceIBasicBlock<SSAInstruction>- Specified by:
isCatchBlockin interfaceISSABasicBlock- Returns:
- true if the basic block represents a catch block.
-
getLastInstructionIndex
public int getLastInstructionIndex()
Description copied from interface:IBasicBlockGet 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:
getLastInstructionIndexin interfaceIBasicBlock<SSAInstruction>- Returns:
- the instruction index for the last instruction in the basic block
-
iteratePhis
public Iterator<SSAPhiInstruction> iteratePhis()
- Specified by:
iteratePhisin 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:
iteratePisin 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:
iteratorin 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:INodeWithNumberA 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:
getGraphNodeIdin interfaceINodeWithNumber- Returns:
- the identifier
-
setGraphNodeId
public void setGraphNodeId(int number)
- Specified by:
setGraphNodeIdin interfaceINodeWithNumber
-
toString
public String toString()
- Overrides:
toStringin classObject- See Also:
Object.toString()
-
getMethod
public IMethod getMethod()
- Specified by:
getMethodin interfaceIBasicBlock<SSAInstruction>- Returns:
- governing method for this block
-
isExitBlock
public boolean isExitBlock()
Description copied from interface:ISSABasicBlockDoes this block represent the unique exit from aControlFlowGraph?- Specified by:
isExitBlockin interfaceIBasicBlock<SSAInstruction>- Specified by:
isExitBlockin interfaceISSABasicBlock- Returns:
- true if the basic block represents the unique exit block.
-
isEntryBlock
public boolean isEntryBlock()
Description copied from interface:ISSABasicBlockDoes this block represent the unique entry to aControlFlowGraph- Specified by:
isEntryBlockin interfaceIBasicBlock<SSAInstruction>- Specified by:
isEntryBlockin interfaceISSABasicBlock- Returns:
- true if the basic block represents the unique entry block.
-
getLastInstruction
public SSAInstruction getLastInstruction()
- Specified by:
getLastInstructionin interfaceISSABasicBlock- Returns:
- the last instruction in this block.
-
getCaughtExceptionTypes
public Iterator<TypeReference> getCaughtExceptionTypes()
TheSSACFG.ExceptionHandlerBasicBlocksubclass will override this.- Specified by:
getCaughtExceptionTypesin interfaceISSABasicBlock- Returns:
- the set of exception types this block may catch.
- See Also:
ISSABasicBlock.getCaughtExceptionTypes()
-
-