Search in sources :

Example 11 with Branch

use of com.google.javascript.jscomp.ControlFlowGraph.Branch in project closure-compiler by google.

the class ControlFlowAnalysisTest method getAllDownEdges.

/**
 * Gets all the control flow edges of the given type from some node with
 * the first token to some node with the second token.
 * This edge must flow from a parent to one of its descendants.
 */
private static List<DiGraphEdge<Node, Branch>> getAllDownEdges(ControlFlowGraph<Node> cfg, Token startToken, Token endToken, Branch type) {
    List<DiGraphEdge<Node, Branch>> edges = getAllEdges(cfg, startToken, endToken, type);
    Iterator<DiGraphEdge<Node, Branch>> it = edges.iterator();
    while (it.hasNext()) {
        DiGraphEdge<Node, Branch> edge = it.next();
        Node source = edge.getSource().getValue();
        Node dest = edge.getDestination().getValue();
        if (!isAncestor(source, dest)) {
            it.remove();
        }
    }
    return edges;
}
Also used : DiGraphEdge(com.google.javascript.jscomp.graph.DiGraph.DiGraphEdge) Branch(com.google.javascript.jscomp.ControlFlowGraph.Branch) DiGraphNode(com.google.javascript.jscomp.graph.DiGraph.DiGraphNode) Node(com.google.javascript.rhino.Node)

Aggregations

Branch (com.google.javascript.jscomp.ControlFlowGraph.Branch)11 Node (com.google.javascript.rhino.Node)11 DiGraphNode (com.google.javascript.jscomp.graph.DiGraph.DiGraphNode)9 DiGraphEdge (com.google.javascript.jscomp.graph.DiGraph.DiGraphEdge)5 LiveVariableLattice (com.google.javascript.jscomp.LiveVariablesAnalysis.LiveVariableLattice)2 BitSet (java.util.BitSet)2 GraphNode (com.google.javascript.jscomp.graph.GraphNode)1 GraphvizNode (com.google.javascript.jscomp.graph.GraphvizGraph.GraphvizNode)1 FlowScope (com.google.javascript.jscomp.type.FlowScope)1 JSType (com.google.javascript.rhino.jstype.JSType)1 ObjectType (com.google.javascript.rhino.jstype.ObjectType)1 ArrayList (java.util.ArrayList)1