harpoon.Analysis
Class BasicBlock.Factory<HCE extends HCodeElement>

java.lang.Object
  extended by harpoon.Analysis.BasicBlock.Factory<HCE>
All Implemented Interfaces:
BasicBlockFactoryInterf<HCE,BasicBlock<HCE>>, Serializable
Enclosing class:
BasicBlock<HCE extends HCodeElement>

public static class BasicBlock.Factory<HCE extends HCodeElement>
extends Object
implements BasicBlockFactoryInterf<HCE,BasicBlock<HCE>>, Serializable

Factory structure for generating BasicBlock views of an HCode.

See Also:
Serialized Form

Constructor Summary
BasicBlock.Factory(HCode<HCE> code)
          Constructs a BasicBlock.Factory using the implicit control flow provided by code.
BasicBlock.Factory(HCode<HCE> hcode, CFGrapher<HCE> grapher)
          Constructs a BasicBlock.Factory and generates BasicBlocks for a given HCode.
 
Method Summary
 Set<BasicBlock<HCE>> blockSet()
          Returns the BasicBlocks constructed by this.
 Iterator<BasicBlock<HCE>> blocksIterator()
          Generates an Iterator that traverses over all of the blocks generated by this BasicBlock.Factory.
 void dumpCFG()
           
static void dumpCFG(BasicBlock start)
           
 BasicBlock<HCE> getBBInterf(HCE hce)
          Does the same thing as getBlock.
 BasicBlock<HCE> getBlock(HCE hce)
          Returns the BasicBlock containing hce.
static String getCFG(BasicBlock start)
           
 HCode<HCE> getHCode()
          Returns the HCode that this factory produces basic blocks of.
 Set<BasicBlock<HCE>> getLeaves()
          Returns the leaf BasicBlocks.
 Set<BasicBlock<HCE>> getLeavesBBInterf()
          Does the same thing as getLeaves.
 BasicBlock<HCE> getRoot()
          Returns the root BasicBlock.
 BasicBlock<HCE> getRootBBInterf()
          Does the same thing as getRoot.
 Iterator<BasicBlock<HCE>> postorderBlocksIter()
          Generates an Iterator that traverses over all of the blocks generated by this BasicBlock.Factory in Postorder (subtrees first, then root).
 Iterator<BasicBlock<HCE>> 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<HCE> 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<HCE> hcode,
                          CFGrapher<HCE> 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<HCE> getRoot()
Returns the root BasicBlock.
effects: returns the BasicBlock that is at the start of the set of HCodeElements being analyzed.


getRootBBInterf

public BasicBlock<HCE> getRootBBInterf()
Does the same thing as getRoot. Work around Java's weak typing system.

Specified by:
getRootBBInterf in interface BasicBlockFactoryInterf<HCE extends HCodeElement,BasicBlock<HCE extends HCodeElement>>

getLeaves

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


getLeavesBBInterf

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

Specified by:
getLeavesBBInterf in interface BasicBlockFactoryInterf<HCE extends HCodeElement,BasicBlock<HCE extends HCodeElement>>

getHCode

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

Specified by:
getHCode in interface BasicBlockFactoryInterf<HCE extends HCodeElement,BasicBlock<HCE extends HCodeElement>>

blockSet

public Set<BasicBlock<HCE>> blockSet()
Returns the BasicBlocks constructed by this.

Specified by:
blockSet in interface BasicBlockFactoryInterf<HCE extends HCodeElement,BasicBlock<HCE extends HCodeElement>>

blocksIterator

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


preorderBlocksIter

public Iterator<BasicBlock<HCE>> 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<BasicBlock<HCE>> 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<HCE> getBlock(HCE 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 BasicBlock<HCE> getBBInterf(HCE hce)
Does the same thing as getBlock. Work around Java's weak typing system.

Specified by:
getBBInterf in interface BasicBlockFactoryInterf<HCE extends HCodeElement,BasicBlock<HCE extends HCodeElement>>

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)