|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.scheinerman.phoenix.interpreter.IfInterpreter
public class IfInterpreter
Provides interpretation of if / else / else if blocks in Phoenix by testing the conditions and
creating a subordinate Interpreter
to interpret the correct code. The
IfInterpreter
takes a list of conditions and interprets them in order. The code of the
first one that is true when evaluated is run, or if there is an else condition, and all of the
other conditions are false, the else condition is run. The IfInterpreter
acts similarly
to the Interpreter
class and makes use of it, but does not actually extend the
Intepreter
class.
Field Summary | |
---|---|
protected boolean |
_break
Indicates whether or not a break was encountered in this scope. |
protected boolean |
_continue
Indicates whether or not a continue was encountered in this scope. |
protected boolean |
_return
Indicates whether or not a return was encountered in this scope. |
protected int |
breakValue
Indicates the value after a break statement that was called within this scope. |
private java.util.ArrayList<Condition> |
conditions
The set of conditions making up this if / else / else if block. |
private java.util.LinkedList<java.util.HashMap<java.lang.String,Function>> |
fat
The Function Allocation Table (FAT) stores functions and their values for all scopes of the interpretation process. |
private java.lang.String |
file
The path of the file that is being interpreted. |
private Interpreter |
interpreter
The interpreter that might be used to run the first conditions that evaluates to true, or the else condition if all previous evaluate to false. |
protected Variable |
retValue
The value returned after a return statement. |
private java.util.LinkedList<java.util.HashMap<java.lang.String,Variable>> |
vat
The Variable Allocation Table (VAT) stores variables and their values for all scopes of the interpretation process. |
Constructor Summary | |
---|---|
IfInterpreter(java.lang.String file,
java.util.ArrayList<Condition> conditions,
Interpreter interpreter,
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 IfInterpreter with a given file, a set of conditions, an interpreter
to run the conditions, a VAT and a FAT. |
Method Summary | |
---|---|
protected void |
dealWithBreak(int value)
Deals with a break statement in the subordinate Interpreter by passing it up
to the above interpreter. |
protected void |
dealWithContinue()
Deals with a continue statement in the subordinate Interpreter by passing it
up to the above interpreter. |
protected void |
dealWithReturn(Variable passed)
Deals with a return statement in the subordinate Interpreter by passing it
up to the above interpreter. |
void |
run()
Runs this interpretation by checking through the conditions and running the appropriate one. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected int breakValue
break
statement that was called within this scope.
protected boolean _break
break
was encountered in this scope.
protected boolean _continue
continue
was encountered in this scope.
protected boolean _return
return
was encountered in this scope.
protected Variable retValue
private java.lang.String file
private Interpreter interpreter
private java.util.ArrayList<Condition> conditions
private java.util.LinkedList<java.util.HashMap<java.lang.String,Variable>> vat
Variable
class equivalent. The last element of the list
is the global scope, the second to the last is the top-level local scope. The front element of the
list is the the most local scope. This VAT is used to pass to the subordinate interpreter for
the conditons.
private java.util.LinkedList<java.util.HashMap<java.lang.String,Function>> fat
Function
class equivalent. The last element of the list
is the global scope, the second to the last is the top-level local scope. The front element of the
list is the the most local scope. This FAT is used to pass to the subordinate interpreter for
the conditons.
Constructor Detail |
---|
public IfInterpreter(java.lang.String file, java.util.ArrayList<Condition> conditions, Interpreter interpreter, java.util.LinkedList<java.util.HashMap<java.lang.String,Variable>> vat, java.util.LinkedList<java.util.HashMap<java.lang.String,Function>> fat)
IfInterpreter
with a given file, a set of conditions, an interpreter
to run the conditions, a VAT and a FAT.
file
- - The path of the file that is being interpreted.conditions
- - The if / else / else if conditons.interpreter
- - The interpreter to be used to run the code.vat
- - The Variable Allocation Table (VAT) for this instance.fat
- - The Function Allocation Table (FAT) for this instance.Method Detail |
---|
public void run()
protected void dealWithBreak(int value)
break
statement in the subordinate Interpreter
by passing it up
to the above interpreter.
value
- - The value passed by the break statement.protected void dealWithContinue()
continue
statement in the subordinate Interpreter
by passing it
up to the above interpreter.
protected void dealWithReturn(Variable passed)
return
statement in the subordinate Interpreter
by passing it
up to the above interpreter.
passed
- - The variable passed to the return statement.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |