polyglot.visit
Class FlowGraph

java.lang.Object
  extended by polyglot.visit.FlowGraph

public class FlowGraph
extends java.lang.Object


Nested Class Summary
static class FlowGraph.Edge
          This class represents an edge in the flow graph.
static class FlowGraph.EdgeKey
          This class provides an identifying label for edges in the flow graph.
static class FlowGraph.ExceptionEdgeKey
          This class extends EdgeKey and is the key for edges that are taken when an exception of type t is thrown.
protected static class FlowGraph.ListKey
          Class to be used for inserting Lists in hashtables using collection equality (as defined in CollectionUtil).
static class FlowGraph.Peer
          A Peer is an occurance of an AST node in a flow graph.
 
Field Summary
static FlowGraph.EdgeKey EDGE_KEY_FALSE
          This EdgeKey is the EdgeKey for edges where the expression evaluates to false.
static FlowGraph.EdgeKey EDGE_KEY_OTHER
          This EdgeKey is the EdgeKey for edges where the flow is not suitable for EDGE_KEY_TRUE, EDGE_KEY_FALSE or an ExceptionEdgeKey, such as the edges from a switch statement to its cases and the flow from a sink node in the control flow graph.
static FlowGraph.EdgeKey EDGE_KEY_TRUE
          This EdgeKey is the EdgeKey for edges where the expression evaluates to true.
protected  boolean forward
          Is the flow in this flow graph forward or backward?
protected  java.util.Map peerMap
          Maps from AST nodes to path maps and hence to Peers that represent occurrences of the AST node in the flow graph.
protected  Term root
          The root of the AST that this is a flow graph for.
 
Method Summary
 Term entryNode()
           
 Term exitNode()
           
 Term finishNode()
           
 boolean forward()
           
 java.util.Map pathMap(Node n)
           
 java.util.Collection pathMaps()
           
 FlowGraph.Peer peer(Term n, DataFlow df)
          Retrieve the Peer for the Term n, where n does not appear in a finally block.
 FlowGraph.Peer peer(Term n, java.util.List path_to_finally, DataFlow df)
          Retrieve the Peer for the Term n that is associated with the given path to the finally block.
 java.util.Collection peers()
          Return a collection of all Peers in this flow graph.
 java.util.Collection peers(Term n)
          Return a collection of all of the Peers for the given Term n.
 Term root()
           
 Term startNode()
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

peerMap

protected java.util.Map peerMap
Maps from AST nodes to path maps and hence to Peers that represent occurrences of the AST node in the flow graph. In particular, peerMap maps IdentityKey(Node)s to path maps. A path map is a map from paths (ListKey(List of Terms)) to Peers. In particular, if n is an AST node in a finally block, then there will be a Peer of n for each possible path to the finally block, and the path map records which Peer corresponds to which path. If n does not occur in a finally block, then the path map should have only a single entry, from an empty list to the unique Peer for n.

WARNING: the AST must be a tree, not a DAG. Otherwise the same peer may be used for a node that appears at multiple points in the AST. These points may have different data flows.


root

protected Term root
The root of the AST that this is a flow graph for.


forward

protected boolean forward
Is the flow in this flow graph forward or backward?


EDGE_KEY_TRUE

public static final FlowGraph.EdgeKey EDGE_KEY_TRUE
This EdgeKey is the EdgeKey for edges where the expression evaluates to true.


EDGE_KEY_FALSE

public static final FlowGraph.EdgeKey EDGE_KEY_FALSE
This EdgeKey is the EdgeKey for edges where the expression evaluates to false.


EDGE_KEY_OTHER

public static final FlowGraph.EdgeKey EDGE_KEY_OTHER
This EdgeKey is the EdgeKey for edges where the flow is not suitable for EDGE_KEY_TRUE, EDGE_KEY_FALSE or an ExceptionEdgeKey, such as the edges from a switch statement to its cases and the flow from a sink node in the control flow graph.

Method Detail

startNode

public Term startNode()

finishNode

public Term finishNode()

entryNode

public Term entryNode()

exitNode

public Term exitNode()

root

public Term root()

forward

public boolean forward()

pathMaps

public java.util.Collection pathMaps()

pathMap

public java.util.Map pathMap(Node n)

peers

public java.util.Collection peers()
Return a collection of all Peers in this flow graph.


peer

public FlowGraph.Peer peer(Term n,
                           DataFlow df)
Retrieve the Peer for the Term n, where n does not appear in a finally block. If no such Peer exists, then one will be created.

Parameters:
df - unused; for legacy purposes only?

peers

public java.util.Collection peers(Term n)
Return a collection of all of the Peers for the given Term n.


peer

public FlowGraph.Peer peer(Term n,
                           java.util.List path_to_finally,
                           DataFlow df)
Retrieve the Peer for the Term n that is associated with the given path to the finally block. (A term that occurs in a finally block has one Peer for each possible path to that finally block.) If no such Peer exists, then one will be created.

Parameters:
df - unused; for legacy purposes only?

toString

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