Class DominatorTree<N>

  • All Implemented Interfaces:
    Iterable<DominatorNode<N>>
    Direct Known Subclasses:
    MHGDominatorTree

    public class DominatorTree<N>
    extends Object
    implements Iterable<DominatorNode<N>>
    Constructs a dominator tree structure from the given DominatorsFinder. The nodes in DominatorTree are of type DominatorNode.

    Note: DominatorTree does not currently implement DirectedGraph since it provides 4 methods of navigating the nodes where the meaning of getPredsOf and getSuccsOf diverge from the usual meaning in a DirectedGraph implementation.

    If you need a DirectedGraph implementation, see DominatorTreeAdapter.

    Author:
    Navindra Umanee
    • Method Detail

      • getGraph

        public DirectedGraph<N> getGraph()
        Returns:
        the original graph to which the DominatorTree pertains
      • getHeads

        public List<DominatorNode<N>> getHeads()
        Returns:
        the root of the dominator tree.
      • getHead

        public DominatorNode<N> getHead()
        Gets the first head of the dominator tree. This function is implemented for single-headed trees and mainly for backwards compatibility.
        Returns:
        The first head of the dominator tree
      • getTails

        public List<DominatorNode<N>> getTails()
        Returns:
        list of the tails of the dominator tree.
      • getParentOf

        public DominatorNode<N> getParentOf​(DominatorNode<N> node)
        Returns:
        the parent of node in the tree, null if the node is at the root.
      • getPredsOf

        public List<DominatorNode<N>> getPredsOf​(DominatorNode<N> node)
        Returns:
        list of the DominatorNodes corresponding to the predecessors of node in the original DirectedGraph
      • getSuccsOf

        public List<DominatorNode<N>> getSuccsOf​(DominatorNode<N> node)
        Returns:
        list of the DominatorNodes corresponding to the successors of node in the original DirectedGraph
      • isImmediateDominatorOf

        public boolean isImmediateDominatorOf​(DominatorNode<N> idom,
                                              DominatorNode<N> node)
        Returns:
        true if idom immediately dominates node.
      • getDode

        public DominatorNode<N> getDode​(N gode)
        Returns:
        DominatorNode for a given node in the original DirectedGraph.
      • size

        public int size()
        Returns:
        the number of nodes in the tree
      • buildTree

        protected void buildTree()
        Add all the necessary links between nodes to form a meaningful tree structure.
      • fetchDode

        protected DominatorNode<N> fetchDode​(N gode)
        Convenience method, ensures we don't create more than one DominatorNode for a given block.