soot.toolkits.graph
Class Block

java.lang.Object
  |
  +--soot.toolkits.graph.Block

public class Block
extends java.lang.Object
implements Directed

Represents BasicBlocks that partition a method body. It is implemented as view on an underlying Body instance; as a consequence, changes made on a Block will be automatically reflected in its enclosing method body. Blocks also exist in the context of a BlockGraph, a CFG for a method where Block instances are the nodes of the graph. Hence, a Block can be queried for its successors and predecessors Blocks, as found in this graph.


Constructor Summary
Block(Unit aHead, Unit aTail, Body aBody, int aIndexInMethod, int aBlockLength, BlockGraph aBlockGraph)
          Constructs a Block in the context of a BlockGraph, and enclosing Body instances.
 
Method Summary
 Body getBody()
          Returns the Block's enclosing Body instance.
 Unit getHead()
          Returns the first unit in this block.
 int getIndexInMethod()
          Returns the index of this Block in the list of Blocks that partition it's enclosing Body instance.
 Unit getPredOf(Unit aItem)
          Returns the Unit occuring immediatly before some other Unit in the block.
 java.util.List getPreds()
          Returns the List of Block that are predecessors to this block,
 Unit getSuccOf(Unit aItem)
          Returns the Unit occuring immediatly after some other Unit in the block.
 java.util.List getSuccs()
          Returns the List of Blocks that are successors to this block,
 Unit getTail()
          Returns the last unit in this block.
 void insertAfter(Unit toInsert, Unit point)
          Inserts a Unit after some other Unit in the Block.
 void insertBefore(Unit toInsert, Unit point)
          Inserts a Unit before some other Unit in this block.
 java.util.Iterator iterator()
          Returns an iterator for the linear chain of Units that make up the block.
 boolean remove(Unit item)
          Removes a Unit occuring before some other Unit in the Block.
 java.lang.String toBriefString()
          Returns a brief description of this object.
 java.lang.String toBriefString(java.util.Map stmtToName)
          Returns a brief description of this object using the given Map.
 java.lang.String toBriefString(java.util.Map stmtToName, java.lang.String indentation)
          Returns a brief description of this object, using the given Map and indentation..
 java.lang.String toBriefString(java.lang.String indentation)
          Returns a brief description of this object, using the given indentation.
 java.lang.String toShortString()
           
 java.lang.String toString()
           
protected  java.lang.String toString(boolean isBrief, java.util.Map stmtToName, java.lang.String indentation)
           
 java.lang.String toString(java.util.Map stmtToName)
           
 java.lang.String toString(java.util.Map stmtToName, java.lang.String indentation)
           
 java.lang.String toString(java.lang.String indentation)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Block

public Block(Unit aHead,
             Unit aTail,
             Body aBody,
             int aIndexInMethod,
             int aBlockLength,
             BlockGraph aBlockGraph)
Constructs a Block in the context of a BlockGraph, and enclosing Body instances.
Parameters:
aHead - The first unit ir this Block.
aTail - The last unit in this Block.
aBody - The Block's enclosing Body instance.
aIndexInMethod - The index of this Block in the list of Blocks that partition it's enclosing Body instance.
aBlockLength - The number of units that makeup this block.
aBlockGraph - The Graph of Blocks in which this block lives.
See Also:
Body, Chain, BlockGraph, Unit, SootMethod
Method Detail

getBody

public Body getBody()
Returns the Block's enclosing Body instance.
Returns:
The block's chain of instructions.
See Also:
JimpleBody, BafBody, Body

iterator

public java.util.Iterator iterator()
Returns an iterator for the linear chain of Units that make up the block.
Returns:
An iterator that iterates over the block's units.
See Also:
Chain, Unit

insertBefore

public void insertBefore(Unit toInsert,
                         Unit point)
Inserts a Unit before some other Unit in this block.
Parameters:
toInsert - A Unit to be inserted.
point - A Unit in the Block's body before which we wish to insert the Unit.
See Also:
Unit, Chain

insertAfter

public void insertAfter(Unit toInsert,
                        Unit point)
Inserts a Unit after some other Unit in the Block.
Parameters:
toInsert - A Unit to be inserted.
point - A Unit in the Block after which we wish to insert the Unit.
See Also:
Unit

remove

public boolean remove(Unit item)
Removes a Unit occuring before some other Unit in the Block.
Parameters:
item - A Unit to be remove from the Block's Unit Chain.
Returns:
True if the item could be found and removed.

getSuccOf

public Unit getSuccOf(Unit aItem)
Returns the Unit occuring immediatly after some other Unit in the block.
Parameters:
aItem - The Unit from which we wish to get it's successor.
Returns:
The successor or null if aItem is the tail for this Block.

getPredOf

public Unit getPredOf(Unit aItem)
Returns the Unit occuring immediatly before some other Unit in the block.
Parameters:
aItem - The Unit from which we wish to get it's predecessor.
Returns:
The predecessor or null if aItem is the head for this Block.

getIndexInMethod

public int getIndexInMethod()
Returns the index of this Block in the list of Blocks that partition it's enclosing Body instance.
Returns:
The index of the block in it's enclosing Body instance.

getHead

public Unit getHead()
Returns the first unit in this block.
Returns:
The first unit in this block.

getTail

public Unit getTail()
Returns the last unit in this block.
Returns:
The last unit in this block.

getPreds

public java.util.List getPreds()
Returns the List of Block that are predecessors to this block,
Returns:
A list of predecessor blocks.
See Also:
BlockGraph

getSuccs

public java.util.List getSuccs()
Returns the List of Blocks that are successors to this block,
Returns:
A list of successorblocks.
See Also:
BlockGraph

toShortString

public java.lang.String toShortString()

toBriefString

public java.lang.String toBriefString()
Returns a brief description of this object.

toBriefString

public java.lang.String toBriefString(java.util.Map stmtToName)
Returns a brief description of this object using the given Map.

toBriefString

public java.lang.String toBriefString(java.lang.String indentation)
Returns a brief description of this object, using the given indentation.

toBriefString

public java.lang.String toBriefString(java.util.Map stmtToName,
                                      java.lang.String indentation)
Returns a brief description of this object, using the given Map and indentation..

toString

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

toString

public java.lang.String toString(java.util.Map stmtToName)

toString

public java.lang.String toString(java.lang.String indentation)

toString

public java.lang.String toString(java.util.Map stmtToName,
                                 java.lang.String indentation)

toString

protected java.lang.String toString(boolean isBrief,
                                    java.util.Map stmtToName,
                                    java.lang.String indentation)