edu.cmu.cs.crystal.flow.worklist
Class WorklistNodeOrderComparator

java.lang.Object
  extended by edu.cmu.cs.crystal.flow.worklist.WorklistNodeOrderComparator
All Implemented Interfaces:
Comparator<ICFGNode<?>>

public class WorklistNodeOrderComparator
extends Object
implements Comparator<ICFGNode<?>>

Comparator to be used in ordering nodes in a worklist. Best analysis performance is achieved using reverse post-order. createPostOrderAndPopulateNodeMap(IControlFlowGraph, Map, boolean) creates a comparator for post-order; reversal should happen by removing nodes from the back of the worklist.

Since:
3.3.0
Author:
Kevin Bierhoff

Method Summary
 int compare(ICFGNode<?> node1, ICFGNode<?> node2)
           
static
<N> WorklistNodeOrderComparator
createPostOrderAndPopulateNodeMap(IControlFlowGraph<N> cfg, Map<N,Set<ICFGNode<N>>> nodeMap, boolean isForward)
          Builds a post-order comparator for the nodes in the given CFG, in which a node is bigger than all of its successors (predecessors) if isForward is true (false), and populates a map from AST nodes to all their corresponding nodes in the given CFG.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.Comparator
equals
 

Method Detail

createPostOrderAndPopulateNodeMap

public static <N> WorklistNodeOrderComparator createPostOrderAndPopulateNodeMap(IControlFlowGraph<N> cfg,
                                                                                Map<N,Set<ICFGNode<N>>> nodeMap,
                                                                                boolean isForward)
Builds a post-order comparator for the nodes in the given CFG, in which a node is bigger than all of its successors (predecessors) if isForward is true (false), and populates a map from AST nodes to all their corresponding nodes in the given CFG.

Parameters:
cfg -
nodeMap - Node map to be populated (will not be cleared).
isForward - If true the CFG is traversed in the forward direction, meaning starting from the start node following outgoing edges; if false the traversal direction is reversed, meaning traversal starts from the end node and follows incoming edges.
Returns:
Post-order comparator for the nodes in the given CFG

compare

public int compare(ICFGNode<?> node1,
                   ICFGNode<?> node2)
Specified by:
compare in interface Comparator<ICFGNode<?>>