Package com.google.javascript.jscomp
Class ControlFlowGraph<N>
- java.lang.Object
-
- com.google.javascript.jscomp.graph.Graph<N,E>
-
- com.google.javascript.jscomp.graph.DiGraph<N,E>
-
- com.google.javascript.jscomp.graph.LinkedDirectedGraph<N,ControlFlowGraph.Branch>
-
- com.google.javascript.jscomp.ControlFlowGraph<N>
-
- Type Parameters:
N
- The instruction type of the control flow graph.
- All Implemented Interfaces:
AdjacencyGraph<N,ControlFlowGraph.Branch>
,GraphvizGraph
public class ControlFlowGraph<N> extends LinkedDirectedGraph<N,ControlFlowGraph.Branch>
Control flow graph.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ControlFlowGraph.AbstractCfgNodeTraversalCallback
Abstract callback to visit a control flow graph node without going into subtrees of the node that are also represented by other control flow graph nodes.static class
ControlFlowGraph.Branch
The edge object for the control flow graph.-
Nested classes/interfaces inherited from class com.google.javascript.jscomp.graph.LinkedDirectedGraph
LinkedDirectedGraph.LinkedDiGraphEdge<N,E>, LinkedDirectedGraph.LinkedDiGraphNode<N,E>
-
Nested classes/interfaces inherited from class com.google.javascript.jscomp.graph.DiGraph
DiGraph.DiGraphEdge<N,E>, DiGraph.DiGraphNode<N,E>
-
Nested classes/interfaces inherited from class com.google.javascript.jscomp.graph.Graph
Graph.GraphEdge<N,E>
-
Nested classes/interfaces inherited from interface com.google.javascript.jscomp.graph.GraphvizGraph
GraphvizGraph.GraphvizEdge, GraphvizGraph.GraphvizNode
-
-
Field Summary
-
Fields inherited from class com.google.javascript.jscomp.graph.LinkedDirectedGraph
nodes
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description DiGraph.DiGraphNode<N,ControlFlowGraph.Branch>
getEntry()
Gets the entry point of the control flow graph.DiGraph.DiGraphNode<N,ControlFlowGraph.Branch>
getImplicitReturn()
Gets the implicit return node.java.util.Comparator<DiGraph.DiGraphNode<N,ControlFlowGraph.Branch>>
getOptionalNodeComparator(boolean isForward)
Gets a comparator for the nodes.static boolean
isEnteringNewCfgNode(Node n)
boolean
isImplicitReturn(DiGraph.DiGraphNode<N,ControlFlowGraph.Branch> node)
Checks whether node is the implicit return.java.lang.String
toString()
-
Methods inherited from class com.google.javascript.jscomp.graph.LinkedDirectedGraph
connect, connect, connectIfNotConnectedInDirection, create, createNode, createWithoutAnnotations, disconnect, disconnectInDirection, getDirectedPredNodes, getDirectedPredNodes, getDirectedSuccNodes, getDirectedSuccNodes, getEdges, getEdges, getEdgesInDirection, getFirstEdge, getGraphvizEdges, getGraphvizNodes, getInEdges, getName, getNeighborNodes, getNode, getNodeCount, getNodeDegree, getNodes, getOutEdges, isConnectedInDirection, isConnectedInDirection, isConnectedInDirection, isDirected, newSubGraph
-
Methods inherited from class com.google.javascript.jscomp.graph.DiGraph
isConnected, isConnected
-
Methods inherited from class com.google.javascript.jscomp.graph.Graph
clearEdgeAnnotations, clearNodeAnnotations, connectIfNotFound, getWeight, hasNode, popEdgeAnnotations, popNodeAnnotations, pushEdgeAnnotations, pushNodeAnnotations
-
-
-
-
Method Detail
-
getImplicitReturn
public DiGraph.DiGraphNode<N,ControlFlowGraph.Branch> getImplicitReturn()
Gets the implicit return node.- Returns:
- Return node.
-
getEntry
public DiGraph.DiGraphNode<N,ControlFlowGraph.Branch> getEntry()
Gets the entry point of the control flow graph. In general, this should be the beginning of the global script or beginning of a function.- Returns:
- The entry point.
-
isImplicitReturn
public boolean isImplicitReturn(DiGraph.DiGraphNode<N,ControlFlowGraph.Branch> node)
Checks whether node is the implicit return.- Parameters:
node
- Node.- Returns:
- True if the node is the implicit return.
-
getOptionalNodeComparator
public java.util.Comparator<DiGraph.DiGraphNode<N,ControlFlowGraph.Branch>> getOptionalNodeComparator(boolean isForward)
Gets a comparator for the nodes. The default implementation returnsnull
. SeegetOptionalNodeComparator(boolean)
.- Parameters:
isForward
- Whether the comparator sorts the nodes in the direction of the flow.- Returns:
- a comparator or null (in particular, if not overridden)
-
isEnteringNewCfgNode
public static boolean isEnteringNewCfgNode(Node n)
- Returns:
- True if n should be represented by a new CFG node in the control flow graph.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-