|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.scheinerman.phoenix.interpreter.Interpreter
net.scheinerman.phoenix.interpreter.LoopInterpreter
public abstract class LoopInterpreter
Extends the standard interpreter to provide abstract loop functionality to the standard interpretation
of a Phoenix program. This class is meant to be extended and not used. The current implementation
provides infinite looping capability. When extending this class, the loop end mechanism can be rewritten
by overriding the isDone()
method, which determines whether or not the loop has finished.
Interpreter}
Field Summary | |
---|---|
private boolean |
run
Indicates whether or not this loop has been executed, not allowing it to be run more than once. |
Fields inherited from class net.scheinerman.phoenix.interpreter.Interpreter |
---|
_break, _continue, _return, breakValue, code, fat, file, keywordList, line, line_diff, printValues, retType, retTypeSet, retValue, run_code, stop, vat |
Constructor Summary | |
---|---|
LoopInterpreter(java.lang.String file,
java.lang.String code,
int line,
java.util.LinkedList<java.util.HashMap<java.lang.String,Variable>> vat,
java.util.LinkedList<java.util.HashMap<java.lang.String,Function>> fat)
Creates a new basic loop interpreter. |
Method Summary | |
---|---|
protected void |
afterEnd()
|
protected void |
beforeStart()
|
protected void |
dealWithBreak(int value)
Deals with a break by reducing the value of the break by one, exiting the loop, and passing
the break up to the above interpreter if the break value is greater than zero. |
protected int |
dealWithContinue(int line)
Deals with a loop by moving to the end of loop and continuing if the ending condition has not been met. |
protected boolean |
isDone()
This method is called to indicate that the end of a loop cycle has occurred. |
void |
run()
This provides default implementation for a loop run structure. |
Methods inherited from class net.scheinerman.phoenix.interpreter.Interpreter |
---|
dealWithError, dealWithReturn, delete, doRun, getBlock, getFunction, getFunctionArguments, getFunctionFromDefinition, getReturnValue, getVariable, getWhitespace, initNewTables, isValidIdentifier, makeDefaultVariable, makeFunction, makeVariable, makeVariable, parsePhrase, putFunction, removeComments, removeWhitespace, retValueMatches |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private boolean run
Constructor Detail |
---|
public LoopInterpreter(java.lang.String file, java.lang.String code, int line, java.util.LinkedList<java.util.HashMap<java.lang.String,Variable>> vat, java.util.LinkedList<java.util.HashMap<java.lang.String,Function>> fat)
file
- - The currently read file.code
- - The lines of code that are to be executed.line
- - The starting line number.vat
- - The enclosing interpreter's VAT.fat
- - The enclosing interpreter's FAT.Method Detail |
---|
public final void run()
isDone()
returns true
or the protected variable indicating whether a
break
has been encountered becomes true. The loop simply calls an execution method
on the run_code
for this interpreter. When the loop exits, the local VAT and FAT are removed
from the lists and execution ends.
run
in class Interpreter
protected void dealWithBreak(int value)
break
by reducing the value of the break by one, exiting the loop, and passing
the break up to the above interpreter if the break value is greater than zero.
dealWithBreak
in class Interpreter
value
- - The number of breaks that should be executed.protected int dealWithContinue(int line)
dealWithContinue
in class Interpreter
line
- - The number of the line on which the continue is encountered.
protected boolean isDone()
false
indicates that the loop should continue, true
indicates that the loop should end. This
particular implementation always returns false
creating an infinite loop. If this class is
extended, this method should be overridden to provide appropriate functionality.
protected void beforeStart()
protected void afterEnd()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |