com.ibm.wala.ssa
Class SSACFG.BasicBlock

java.lang.Object
  extended by com.ibm.wala.ssa.SSACFG.BasicBlock
All Implemented Interfaces:
IBasicBlock, ISSABasicBlock, INodeWithNumber, java.lang.Iterable<IInstruction>
Direct Known Subclasses:
SSACFG.ExceptionHandlerBasicBlock
Enclosing class:
SSACFG

public class SSACFG.BasicBlock
extends java.lang.Object
implements ISSABasicBlock

A Basic Block in an SSA IR


Constructor Summary
SSACFG.BasicBlock(int number)
           
 
Method Summary
 void addPhiForLocal(int n, SSAPhiInstruction phi)
          Method addPhiForLocal.
 void addPhiForStackSlot(int slot, SSAPhiInstruction phi)
          Method addPhiForStackSlot.
 boolean equals(java.lang.Object arg0)
           
 java.util.List<SSAInstruction> getAllInstructions()
          TODO: make this more efficient if needed
 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()
          Method getLastInstructionIndex.
 IMethod getMethod()
           
 int getNumber()
          Each basic block should have a unique number in its cfg
 SSAPhiInstruction getPhiForLocal(int n)
          Method getPhiForLocal.
 SSAPhiInstruction getPhiForStackSlot(int slot)
          Method getPhiForStackSlot.
 int hashCode()
           
 boolean hasPhi()
           
 boolean isCatchBlock()
          Is this block marked as a catch block?
 boolean isEntryBlock()
          Return true if the basic block represents the unique entry block.
 boolean isExitBlock()
          Return true if the basic block represents the unique exit block.
 java.util.Iterator<? extends SSAInstruction> iteratePhis()
           
 java.util.Iterator<SSAPiInstruction> iteratePis()
           
 java.util.Iterator<IInstruction> iterator()
           
 void removePhis(java.util.Set<SSAPhiInstruction> toRemove)
          Remove any phis in the set.
 void setGraphNodeId(int number)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SSACFG.BasicBlock

public SSACFG.BasicBlock(int number)
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 interface IBasicBlock
Returns:
the basic block's number

getFirstInstructionIndex

public int getFirstInstructionIndex()
Method getFirstInstructionIndex.

Specified by:
getFirstInstructionIndex in interface IBasicBlock
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 interface IBasicBlock
Specified by:
isCatchBlock in interface ISSABasicBlock
Returns:
true if the basic block represents a catch block.

getLastInstructionIndex

public int getLastInstructionIndex()
Method getLastInstructionIndex.

Specified by:
getLastInstructionIndex in interface IBasicBlock
Returns:
int

iteratePhis

public java.util.Iterator<? extends SSAInstruction> iteratePhis()
Specified by:
iteratePhis in interface ISSABasicBlock

getPhiForStackSlot

public SSAPhiInstruction getPhiForStackSlot(int slot)
Method getPhiForStackSlot. This method is used during SSA construction.

Parameters:
slot -
Returns:
PhiInstruction

getPhiForLocal

public SSAPhiInstruction getPhiForLocal(int n)
Method getPhiForLocal. This method is used during SSA construction.

Parameters:
n -
Returns:
PhiInstruction

addPhiForStackSlot

public void addPhiForStackSlot(int slot,
                               SSAPhiInstruction phi)
Method addPhiForStackSlot.

Parameters:
slot -
phi -

addPhiForLocal

public void addPhiForLocal(int n,
                           SSAPhiInstruction phi)
Method addPhiForLocal.

Parameters:
n -
phi -

removePhis

public void removePhis(java.util.Set<SSAPhiInstruction> toRemove)
Remove any phis in the set.

Parameters:
toRemove -

iteratePis

public java.util.Iterator<SSAPiInstruction> iteratePis()
Specified by:
iteratePis in interface ISSABasicBlock

getAllInstructions

public java.util.List<SSAInstruction> getAllInstructions()
TODO: make this more efficient if needed


iterator

public java.util.Iterator<IInstruction> iterator()
Specified by:
iterator in interface java.lang.Iterable<IInstruction>

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 interface INodeWithNumber
Returns:
the identifier

setGraphNodeId

public void setGraphNodeId(int number)
Specified by:
setGraphNodeId in interface INodeWithNumber

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object
See Also:
Object.toString()

equals

public boolean equals(java.lang.Object arg0)
Overrides:
equals in class java.lang.Object

getMethod

public IMethod getMethod()
Specified by:
getMethod in interface IBasicBlock
Returns:
governing method for this block

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

isExitBlock

public boolean isExitBlock()
Description copied from interface: IBasicBlock
Return true if the basic block represents the unique exit block.

Specified by:
isExitBlock in interface IBasicBlock
Specified by:
isExitBlock in interface ISSABasicBlock
Returns:
true if the basic block represents the unique exit block.

isEntryBlock

public boolean isEntryBlock()
Description copied from interface: IBasicBlock
Return true if the basic block represents the unique entry block.

Specified by:
isEntryBlock in interface IBasicBlock
Specified by:
isEntryBlock in interface ISSABasicBlock
Returns:
true if the basic block represents the unique entry block.

getLastInstruction

public SSAInstruction getLastInstruction()
Specified by:
getLastInstruction in interface ISSABasicBlock