harpoon.IR.Properties
Class CFGrapher

java.lang.Object
  |
  +--harpoon.IR.Properties.CFGrapher

public abstract class CFGrapher
extends Object

CFGrapher provides a means to externally associate control-flow graph information with elements of an intermediate representation.

Version:
$Id: CFGrapher.java,v 1.2 2002/02/25 21:04:44 cananian Exp $
Author:
C. Scott Ananian <cananian@alumni.princeton.edu>
See Also:
CFGraphable

Field Summary
static CFGrapher DEFAULT
          Default CFGrapher for HCodeElements which implement CFGraphable.
 
Constructor Summary
CFGrapher()
           
 
Method Summary
 Collection edgeC(HCodeElement hc)
          Returns a Collection of all the edges to and from this HCodeElement.
 CFGrapher edgeReversed()
          Returns an edge-reversed grapher based on this one.
 HCodeEdge[] edges(HCodeElement hc)
          Returns an array of all the edges to and from the specified HCodeElement.
 Set getElements(HCode code)
           
abstract  HCodeElement getFirstElement(HCode hcode)
          Deprecated. Use getFirstElements() instead.
 HCodeElement[] getFirstElements(HCode hcode)
          Returns the first HCodeElements to be executed; that is, the roots of the control-flow graph.
abstract  HCodeElement[] getLastElements(HCode hcode)
          Returns the last HCodeElements to be executed; that is, the leaves of the control-flow graph.
 HCodeEdge[] pred(HCodeElement hc)
          Returns an array of all the edges entering the specified HCodeElement.
abstract  Collection predC(HCodeElement hc)
          Returns a Collection of all the edges to this HCodeElement.
 Collection predElemC(HCodeElement hc)
          Returns a Collection of all the HCodeElements preceeding hc.
 HCodeEdge[] succ(HCodeElement hc)
          Returns an array of all the edges leaving the specified HCodeElement.
abstract  Collection succC(HCodeElement hc)
          Returns a Collection of all the edges from this HCodeElement.
 Collection succElemC(HCodeElement hc)
          Returns a Collection of all the HCodeElement succeeding hc.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT

public static final CFGrapher DEFAULT
Default CFGrapher for HCodeElements which implement CFGraphable. Does nothing but cast the supplied HCodeElement to a CFGraphable and invoke the appropriate corresponding method in the CFGraphable interface. The root of the control flow graph is assumed to be whatever HCode.getRootElement returns.

See Also:
Comparator, Comparable, harpoon.Util.Default.comparator
Constructor Detail

CFGrapher

public CFGrapher()
Method Detail

getFirstElements

public HCodeElement[] getFirstElements(HCode hcode)
Returns the first HCodeElements to be executed; that is, the roots of the control-flow graph.


getLastElements

public abstract HCodeElement[] getLastElements(HCode hcode)
Returns the last HCodeElements to be executed; that is, the leaves of the control-flow graph.


getFirstElement

public abstract HCodeElement getFirstElement(HCode hcode)
Deprecated. Use getFirstElements() instead.

This method is present for compatibility only.


edges

public HCodeEdge[] edges(HCodeElement hc)
Returns an array of all the edges to and from the specified HCodeElement.


pred

public HCodeEdge[] pred(HCodeElement hc)
Returns an array of all the edges entering the specified HCodeElement.


succ

public HCodeEdge[] succ(HCodeElement hc)
Returns an array of all the edges leaving the specified HCodeElement.


edgeC

public Collection edgeC(HCodeElement hc)
Returns a Collection of all the edges to and from this HCodeElement.


predC

public abstract Collection predC(HCodeElement hc)
Returns a Collection of all the edges to this HCodeElement. Each HCodeEdge returned is guaranteed to return hc in response to a call to to(); the actual predecessor will be returned from from().


succC

public abstract Collection succC(HCodeElement hc)
Returns a Collection of all the edges from this HCodeElement. Each HCodeEdge returned is guaranteed to return hc in response to a call to from(); the actual successor to this will be returned from to().


predElemC

public Collection predElemC(HCodeElement hc)
Returns a Collection of all the HCodeElements preceeding hc.


succElemC

public Collection succElemC(HCodeElement hc)
Returns a Collection of all the HCodeElement succeeding hc.


getElements

public Set getElements(HCode code)

edgeReversed

public CFGrapher edgeReversed()
Returns an edge-reversed grapher based on this one. Certain algorithms operate more naturally on this representation --- for example, the difference between a dominator tree and a post-dominator tree is now simply whether you use the grapher or grapher.edgeReversed().