1 import com
.sun
.source
.tree
.Tree
;
5 * A single node in a control flow graph.
6 * @author <a href="mailto:koenig@cs.washington.edu">David Matthew Jerry Koenig</a>
8 public class ControlFlowNode
{
9 private ControlFlowNode elseSuccessor
;
10 private Map
<Throwable
, ControlFlowNode
> exceptionSuccessors
;
11 private List
<ControlFlowNode
> predecessors
;
12 private ControlFlowNode successor
;
16 * Sets up a control flow node with no predecessors or exception
19 public ControlFlowNode(Tree tree
) {
20 exceptionSuccessors
= new HashMap
<Throwable
, ControlFlowNode
>();
21 predecessors
= new ArrayList
<ControlFlowNode
>();
26 * If the current node is a condition in a loop, if statement, or the
27 * ternary operator, the path to take if the condition is false.
29 public ControlFlowNode
getElseSuccessor() {
34 * A map from Throwables that may be thrown in the evaluation of this
35 * node to the path that execution will take on the throwing of the
36 * corresponding throwable.
38 public Map
<Throwable
, ControlFlowNode
> getExceptionSuccessors() {
39 return exceptionSuccessors
;
43 * All incoming paths to this node.
45 public List
<ControlFlowNode
> getPredecessors() {
50 * The outgoing path of execution. If the current node is a condition in
51 * a loop, if statement, or the ternary operator, the path to take if the
54 public ControlFlowNode
getSuccessor() {
59 * Returns the node in the abstract syntax tree that corresponds to this
60 * node in the control flow graph.
62 public Tree
getTree() {
67 * Sets the following node for normal execution. If the current node is a
68 * condition in a loop, if statement, or the ternary operator, the path to
69 * take if the condition is true.
71 public void setSuccessor(ControlFlowNode successor
) {
72 this.successor
= successor
;
76 * Sets the path to take if the current node is a condition in a loop, if
77 * statement, or the ternary operator, and the condition is false.
79 public void setElseSuccessor(ControlFlowNode elseSuccessor
) {
80 this.elseSuccessor
= elseSuccessor
;
84 * Sets the node in the abstract syntax tree that corresponds to this node
85 * in the control flow graph.
87 public void setTree(Tree tree
) {