Class ControlFlowNode
java.lang.Object
net.covers1624.coffeegrinder.bytecode.flow.ControlFlowNode
Represents a block in the control flow graph.
Created by covers1624 on 28/2/21.
-
Field Summary
FieldsModifier and TypeFieldDescription@Nullable BlockThe block this control flow node is for.intThe index in this nodes control flow graph.intThe index of the node in a post-order traversal of the control flow graph, starting at the end point.booleanVisited flag, used in various algorithms. -
Constructor Summary
ConstructorsConstructorDescriptionControlFlowNode(int cfgIndex) ControlFlowNode(int cfgIndex, Block block) ControlFlowNode(ControlFlowNode other) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddEdgeTo(ControlFlowNode target) booleandominates(ControlFlowNode node) Gets whether this node dominates the provided node.getBlock()Gets theblock, requiring it to be non-null.List of children in the dominator tree.Gets the immediate dominator (the parent in the dominator tree).@Nullable ControlFlowNodeGets the immediate dominator (the parent in the dominator tree).booleanGets whether this node is reachable.net.covers1624.quack.collection.FastStream<ControlFlowNode> streamPostOrder(Function<ControlFlowNode, net.covers1624.quack.collection.FastStream<ControlFlowNode>> children) net.covers1624.quack.collection.FastStream<ControlFlowNode> streamPreOrder(Function<ControlFlowNode, net.covers1624.quack.collection.FastStream<ControlFlowNode>> children) toString()voidtraversePostOrder(Function<ControlFlowNode, List<ControlFlowNode>> children, Consumer<ControlFlowNode> visitor) voidtraversePreOrder(Function<ControlFlowNode, List<ControlFlowNode>> children, Consumer<ControlFlowNode> visitor)
-
Field Details
-
cfgIndex
public int cfgIndexThe index in this nodes control flow graph. -
block
The block this control flow node is for. -
visited
public boolean visitedVisited flag, used in various algorithms. -
postOrderNumber
public int postOrderNumberThe 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
-
ControlFlowNode
-
-
Method Details
-
addEdgeTo
-
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
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
Gets theblock, requiring it to be non-null. (mostly for nullability convenience.)- Returns:
- The block.
-
getPredecessors
- Returns:
- List of incoming control flow edges.
-
getSuccessors
- Returns:
- List of outgoing control flow edges.
-
getImmediateDominator
Gets the immediate dominator (the parent in the dominator tree).nullif the dominance has not been calculated; or the node is unreachable.This is an overload for
getImmediateDominatorOrNull()- Returns:
- The immediate parent, or null.
-
getImmediateDominatorOrNull
Gets the immediate dominator (the parent in the dominator tree).nullif the dominance has not been calculated; or the node is unreachable.- Returns:
- The immediate parent, or null.
-
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
-