edu.uci.eecs.doc.cascade.controlflow
Class WhileLoop
java.lang.Object
edu.uci.eecs.doc.cascade.controlflow.Node
edu.uci.eecs.doc.cascade.controlflow.Loop
edu.uci.eecs.doc.cascade.controlflow.WhileLoop
- All Implemented Interfaces:
- Iterable<Node>
public class WhileLoop
- extends Loop
Represents while loops in control flow graphs and trees.
- Author:
- Trevor Harmon
Methods inherited from class edu.uci.eecs.doc.cascade.controlflow.Node |
getBlock, getEnclosingLoop, getFirstInstruction, getInstructions, getMethodInvocations, getNext, getOutermostLoop, getParent, getScope, getSourceCodeLineNumber, getStartAddress, getTree, iterator, lastNode, setNext |
gotoNode
protected Goto gotoNode
WhileLoop
public WhileLoop(Tree tree,
int scope,
Node parent,
LoopBlock loopBlock,
List<InstructionHandle> instructions)
- Creates a new WhileLoop object.
- Parameters:
tree
- the control flow tree to which this node belongsscope
- the lexical scope of the node (0 = top-level scope)parent
- the node's parent (null if the node has no parent)loopBlock
- a JODE object representing the while loopinstructions
- the list of instructions in the loop's method (the whole
method, not just the loop)
setBody
public void setBody(Node body)
- Sets the body of the loop. This may be necessary if, for example, the loop body
is determined to be empty and needs to be "fixed up" accordingly.
- Overrides:
setBody
in class Loop
- Parameters:
body
- a control flow node representing the loop's body
getGoto
public Goto getGoto()
- Returns a handle to the goto instruction that is executed at the end of the loop
body in order to return control to the top of the loop. Note that some while
loop constructs will not have a goto instruction as the last instruction in the
body, or they may have no goto instruction at all. In these cases, this method
returns null. For example, this while loop has no goto instruction whatsoever:
while (val > 3)
{
if (b) return;
}
- Returns:
- a handle to the goto instruction of the for loop, or null if the last
instruction in the loop body is not a goto instruction
getLastInstruction
protected InstructionHandle getLastInstruction()
- Overrides:
getLastInstruction
in class Node
toString
public String toString()
- Converts the while loop to a string.
- Overrides:
toString
in class Object
- Returns:
- a source-code-like string representing the while loop