harpoon.Analysis
Class BasicBlock.Factory

java.lang.Object
  |
  +--harpoon.Analysis.BasicBlock.Factory
All Implemented Interfaces:
BasicBlockFactoryInterf, Serializable
Enclosing class:
BasicBlock

public static class BasicBlock.Factory
extends Object
implements BasicBlockFactoryInterf, Serializable

Factory structure for generating BasicBlock views of an HCode.

See Also:
Serialized Form

Constructor Summary
BasicBlock.Factory(HCode code)
          Constructs a BasicBlock.Factory using the implicit control flow provided by code.
BasicBlock.Factory(HCode hcode, CFGrapher grapher)
          Constructs a BasicBlock.Factory and generates BasicBlocks for a given HCode.
 
Method Summary
 Set blockSet()
          Returns the BasicBlocks constructed by this.
 Iterator blocksIterator()
          Generates an Iterator that traverses over all of the blocks generated by this BasicBlock.Factory.
 void dumpCFG()
           
static void dumpCFG(BasicBlock start)
           
 BasicBlockInterf getBBInterf(HCodeElement hce)
          Does the same thing as getBlock.
 BasicBlock getBlock(HCodeElement hce)
          Returns the BasicBlock containing hce.
static String getCFG(BasicBlock start)
           
 HCode getHCode()
          Returns the HCode that this factory produces basic blocks of.
 Set getLeaves()
          Returns the leaf BasicBlocks.
 Set getLeavesBBInterf()
          Does the same thing as getLeaves.
 BasicBlock getRoot()
          Returns the root BasicBlock.
 BasicBlockInterf getRootBBInterf()
          Does the same thing as getRoot.
 Iterator postorderBlocksIter()
          Generates an Iterator that traverses over all of the blocks generated by this BasicBlock.Factory in Postorder (subtrees first, then root).
 Iterator preorderBlocksIter()
          Generates an Iterator that traverses over all of the blocks generated by this BasicBlock.Factory in Preorder (root first, then subtrees).
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BasicBlock.Factory

public BasicBlock.Factory(HCode code)
Constructs a BasicBlock.Factory using the implicit control flow provided by code.
requires: elements of code implement CFGraphable.
effects: constructs a BasicBlock.Factory using this(code, CFGrapher.DEFAULT);


BasicBlock.Factory

public BasicBlock.Factory(HCode hcode,
                          CFGrapher grapher)
Constructs a BasicBlock.Factory and generates BasicBlocks for a given HCode.
requires: grapher.getFirstElement(hcode) is an appropriate entry point for a basic block.
effects: Creates a set of BasicBlocks corresponding to the blocks implicitly contained in grapher.getFirstElement(hcode) and the HCodeElement objects that this points to, and returns the BasicBlock that grapher.getFirstElement(hcode) is an instruction in. The BasicBlock returned is considered to be the root (entry-point) of the set of BasicBlocks created.

Method Detail

getRoot

public BasicBlock getRoot()
Returns the root BasicBlock.
effects: returns the BasicBlock that is at the start of the set of HCodeElements being analyzed.


getRootBBInterf

public BasicBlockInterf getRootBBInterf()
Does the same thing as getRoot. Work around Java's weak typing system.

Specified by:
getRootBBInterf in interface BasicBlockFactoryInterf

getLeaves

public Set getLeaves()
Returns the leaf BasicBlocks.
effects: returns a Set of BasicBlocks that are at the ends of the HCodeElements being analyzed.


getLeavesBBInterf

public Set getLeavesBBInterf()
Does the same thing as getLeaves. Work around Java's weak typing system.

Specified by:
getLeavesBBInterf in interface BasicBlockFactoryInterf

getHCode

public HCode getHCode()
Returns the HCode that this factory produces basic blocks of.

Specified by:
getHCode in interface BasicBlockFactoryInterf

blockSet

public Set blockSet()
Returns the BasicBlocks constructed by this.

Specified by:
blockSet in interface BasicBlockFactoryInterf

blocksIterator

public Iterator blocksIterator()
Generates an Iterator that traverses over all of the blocks generated by this BasicBlock.Factory.


preorderBlocksIter

public Iterator preorderBlocksIter()
Generates an Iterator that traverses over all of the blocks generated by this BasicBlock.Factory in Preorder (root first, then subtrees).


postorderBlocksIter

public Iterator postorderBlocksIter()
Generates an Iterator that traverses over all of the blocks generated by this BasicBlock.Factory in Postorder (subtrees first, then root).


getBlock

public BasicBlock getBlock(HCodeElement hce)
Returns the BasicBlock containing hce.
requires: hce is present in the code for this.
effects: returns the BasicBlock that contains hce, or null if hce is unreachable.


getBBInterf

public BasicBlockInterf getBBInterf(HCodeElement hce)
Does the same thing as getBlock. Work around Java's weak typing system.

Specified by:
getBBInterf in interface BasicBlockFactoryInterf

dumpCFG

public void dumpCFG()

toString

public String toString()
Overrides:
toString in class Object

dumpCFG

public static void dumpCFG(BasicBlock start)

getCFG

public static String getCFG(BasicBlock start)