dk.brics.xact.analysis.xmlgraph
Class ForwardsXGAnalyzer<T>

java.lang.Object
  extended by dk.brics.xact.analysis.xmlgraph.ForwardsXGAnalyzer<T>
Type Parameters:
T - lattice type. Requires a working Object.equals(Object).
Direct Known Subclasses:
FirstRootAnalysis, RootAnalysis

public abstract class ForwardsXGAnalyzer<T>
extends Object

Base class for performing forwards dataflow analysis on XML graphs. Subclasses should call doAnalysis() when the analysis should be performed, which by convention should be at the end of its constructor.

Only reachable nodes are analyzed – requesting the lattice point for an unreachable node will always return null.


Constructor Summary
ForwardsXGAnalyzer(XMLGraph xg)
           
 
Method Summary
protected abstract  T bottom()
          Returns BOTTOM element.
protected  void doAnalysis()
           
 T get(int index)
          Returns the lattice data associated with the given node; or null if the node is unreachable.
 T get(Node node)
          Returns the lattice data associated with the given node; or null if the node is unreachable.
 XMLGraph getXmlGraph()
           
protected abstract  T initial(Node node)
          Returns initial value for the specified node.
protected abstract  Set<Integer> initialNodes()
          Returns the initial nodes.
protected  void put(int index, T newValue)
          Changes the lattice point for the specified node.
protected abstract  void transfer(T src, Node node)
          Transfer data from the specified node to its children.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ForwardsXGAnalyzer

public ForwardsXGAnalyzer(XMLGraph xg)
Method Detail

bottom

protected abstract T bottom()
Returns BOTTOM element.

Returns:
a lattice point

doAnalysis

protected void doAnalysis()

get

public T get(int index)
Returns the lattice data associated with the given node; or null if the node is unreachable.

Parameters:
index - index of a node
Returns:
a lattice point

get

public T get(Node node)
Returns the lattice data associated with the given node; or null if the node is unreachable.

Parameters:
node - a node
Returns:
a lattice point

getXmlGraph

public XMLGraph getXmlGraph()

initial

protected abstract T initial(Node node)
Returns initial value for the specified node.

Parameters:
node - one of the nodes whose index was returned by initialNodes()
Returns:
a lattice point

initialNodes

protected abstract Set<Integer> initialNodes()
Returns the initial nodes. This will typically be the root nodes in the XML graph. All initial nodes must be reachable from the graph's root nodes.

Returns:
read-only set

put

protected void put(int index,
                   T newValue)
Changes the lattice point for the specified node. The underlying worklist is updated if the new value is different from the old value.

Note that this method does not perform any least upper bound computation – you often want to merge with the existing value before calling put.

Parameters:
index -
newValue -

transfer

protected abstract void transfer(T src,
                                 Node node)
Transfer data from the specified node to its children. Update node data using put(int, Object).

Parameters:
src - lattice point for the specified node, provided for convenience
node - the node to transfer from


Copyright © 2005-2011 Aarhus University.