public class FlowGraph<FlowItem extends DataFlow.Item>
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
FlowGraph.Edge<FlowItem extends DataFlow.Item>
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.
|
static class |
FlowGraph.Peer<FlowItem extends DataFlow.Item>
A
Peer is an occurrence of an AST node in a flow graph. |
static class |
FlowGraph.PeerKey
Class to be used for inserting Lists in hash tables using collection
equality (as defined in
CollectionUtil ). |
Modifier and Type | Field and Description |
---|---|
protected boolean |
alwaysHaveSuccEdgeKey
When a peer has no successor edge keys, should we add
an OTHER edge key?
|
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<IdentityKey,java.util.Map<FlowGraph.PeerKey,FlowGraph.Peer<FlowItem>>> |
peerMap
Maps from AST nodes to path maps and hence to
Peer s 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.
|
Constructor and Description |
---|
FlowGraph(Term root,
boolean forward) |
FlowGraph(Term root,
boolean forward,
boolean alwaysHaveSuccEdgeKey) |
Modifier and Type | Method and Description |
---|---|
java.util.Collection<FlowGraph.Peer<FlowItem>> |
entryPeers() |
java.util.Collection<FlowGraph.Peer<FlowItem>> |
exitPeers() |
java.util.Collection<FlowGraph.Peer<FlowItem>> |
finishPeers() |
boolean |
forward() |
java.util.Map<FlowGraph.PeerKey,FlowGraph.Peer<FlowItem>> |
pathMap(Node n) |
java.util.Collection<java.util.Map<FlowGraph.PeerKey,FlowGraph.Peer<FlowItem>>> |
pathMaps() |
FlowGraph.Peer<FlowItem> |
peer(Term n,
boolean isEntry) |
FlowGraph.Peer<FlowItem> |
peer(Term n,
FlowGraph.PeerKey peerKey)
Retrieve the
Peer for the Term n that is
associated with the given PeerKey. |
FlowGraph.Peer<FlowItem> |
peer(Term n,
int entry)
Retrieve the entry or exit
Peer for the
Term n , where n does not appear in a
finally block. |
FlowGraph.Peer<FlowItem> |
peer(Term n,
java.util.List<Term> path_to_finally,
int entry)
Retrieve the
Peer for the Term n that is
associated with the given path to the finally block. |
java.util.Collection<FlowGraph.Peer<FlowItem>> |
peers()
Return a collection of all
Peer s in this flow graph. |
java.util.Collection<FlowGraph.Peer<FlowItem>> |
peers(Term n,
int entry)
Return a collection of all of the entry or exit
Peer s for
the given Term n . |
Term |
root() |
java.util.Collection<FlowGraph.Peer<FlowItem>> |
startPeers() |
java.lang.String |
toString() |
protected java.util.Map<IdentityKey,java.util.Map<FlowGraph.PeerKey,FlowGraph.Peer<FlowItem extends DataFlow.Item>>> peerMap
Peer
s 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<Term>)
)
to Peer
s. 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.
protected Term root
protected boolean forward
protected final boolean alwaysHaveSuccEdgeKey
public static final FlowGraph.EdgeKey EDGE_KEY_TRUE
public static final FlowGraph.EdgeKey EDGE_KEY_FALSE
public static final FlowGraph.EdgeKey EDGE_KEY_OTHER
public FlowGraph(Term root, boolean forward)
public FlowGraph(Term root, boolean forward, boolean alwaysHaveSuccEdgeKey)
public Term root()
public boolean forward()
public java.util.Collection<FlowGraph.Peer<FlowItem>> entryPeers()
public java.util.Collection<FlowGraph.Peer<FlowItem>> exitPeers()
public java.util.Collection<FlowGraph.Peer<FlowItem>> startPeers()
public java.util.Collection<FlowGraph.Peer<FlowItem>> finishPeers()
public java.util.Collection<java.util.Map<FlowGraph.PeerKey,FlowGraph.Peer<FlowItem>>> pathMaps()
public java.util.Map<FlowGraph.PeerKey,FlowGraph.Peer<FlowItem>> pathMap(Node n)
public java.util.Collection<FlowGraph.Peer<FlowItem>> peers()
Peer
s in this flow graph.public FlowGraph.Peer<FlowItem> peer(Term n, int entry)
Peer
for the
Term n
, where n
does not appear in a
finally block. If no such Peer exists, then one will be created.
entry
can be Term.ENTRY or Term.EXIT.public FlowGraph.Peer<FlowItem> peer(Term n, boolean isEntry)
public java.util.Collection<FlowGraph.Peer<FlowItem>> peers(Term n, int entry)
Peer
s for
the given Term n
.
entry
can be Term.ENTRY or Term.EXIT.public FlowGraph.Peer<FlowItem> peer(Term n, java.util.List<Term> path_to_finally, int entry)
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.
entry
can be Term.ENTRY or Term.EXIT.public FlowGraph.Peer<FlowItem> peer(Term n, FlowGraph.PeerKey peerKey)
Peer
for the Term n
that is
associated with the given PeerKey.public java.lang.String toString()
toString
in class java.lang.Object