Class ControlFlowNode

java.lang.Object
net.covers1624.coffeegrinder.bytecode.flow.ControlFlowNode

public class ControlFlowNode extends Object
Represents a block in the control flow graph.

Created by covers1624 on 28/2/21.

  • Field Details

    • cfgIndex

      public int cfgIndex
      The index in this nodes control flow graph.
    • block

      @Nullable public @Nullable Block block
      The block this control flow node is for.
    • visited

      public boolean visited
      Visited flag, used in various algorithms.
    • postOrderNumber

      public int postOrderNumber
      The index of the node in a post-order traversal of the control flow graph, starting at the end point. This field gets computed by dominance analysis.
  • Constructor Details

    • ControlFlowNode

      public ControlFlowNode()
    • ControlFlowNode

      public ControlFlowNode(int cfgIndex)
    • ControlFlowNode

      public ControlFlowNode(ControlFlowNode other)
    • ControlFlowNode

      public ControlFlowNode(int cfgIndex, Block block)
  • Method Details

    • addEdgeTo

      public void addEdgeTo(ControlFlowNode target)
    • traversePreOrder

      public void traversePreOrder(Function<ControlFlowNode,List<ControlFlowNode>> children, Consumer<ControlFlowNode> visitor)
    • traversePostOrder

      public void traversePostOrder(Function<ControlFlowNode,List<ControlFlowNode>> children, Consumer<ControlFlowNode> visitor)
    • dominates

      public boolean dominates(ControlFlowNode node)
      Gets whether this node dominates the provided node.
      Parameters:
      node - The node to check against.
      Returns:
      If this node dominates the provided node.
    • streamPreOrder

      public net.covers1624.quack.collection.FastStream<ControlFlowNode> streamPreOrder(Function<ControlFlowNode,net.covers1624.quack.collection.FastStream<ControlFlowNode>> children)
    • streamPostOrder

      public net.covers1624.quack.collection.FastStream<ControlFlowNode> streamPostOrder(Function<ControlFlowNode,net.covers1624.quack.collection.FastStream<ControlFlowNode>> children)
    • getBlock

      public Block getBlock()
      Gets the block, requiring it to be non-null. (mostly for nullability convenience.)
      Returns:
      The block.
    • getPredecessors

      public List<ControlFlowNode> getPredecessors()
      Returns:
      List of incoming control flow edges.
    • getSuccessors

      public List<ControlFlowNode> getSuccessors()
      Returns:
      List of outgoing control flow edges.
    • getImmediateDominator

      public ControlFlowNode getImmediateDominator()
      Gets the immediate dominator (the parent in the dominator tree). null if the dominance has not been calculated; or the node is unreachable.

      This is an overload for getImmediateDominatorOrNull()

      Returns:
      The immediate parent, or null.
    • getImmediateDominatorOrNull

      @Nullable public @Nullable ControlFlowNode getImmediateDominatorOrNull()
      Gets the immediate dominator (the parent in the dominator tree). null if the dominance has not been calculated; or the node is unreachable.
      Returns:
      The immediate parent, or null.
    • getDominatorTreeChildren

      public List<ControlFlowNode> getDominatorTreeChildren()
      List of children in the dominator tree.
      Returns:
      The children.
    • isReachable

      public boolean isReachable()
      Gets whether this node is reachable. Requires that dominance is computed!
      Returns:
      If the node is reachable.
    • toString

      public String toString()
      Overrides:
      toString in class Object