|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectsleep.runtime.ScriptEnvironment
This class contains methods for accessing the data stack, return value of a function, and the environment hashtable for a script. In sleep each ScriptInstance has a ScriptEnvironment object associated with it. Most of the functions in this class are used internally by sleep.
For the developers purposes, this class is your gateway into the runtime environment of a script.
If you use the evaluate methods to evaluate a snippet of code, they will be evaluated as if they were part of the script file that this ScriptEnvironment represents.
The Hashtable environment contains references for all of the loaded bridges this script has access to. Every function, predicate, and operator is specified in the environment hashtable. To force scripts to share this information use setEnvironment(Hashtable) and pass the same instance of Hashtable that other scripts are using.
This class is instantiated by sleep.runtime.ScriptInstance.
ScriptLoader
,
ScriptInstance
,
Serialized FormField Summary | |
protected Hashtable |
environment
the environment hashtable that contains all of the functions, predicates, operators, and "environment keywords" this script has access to. |
protected Stack |
environmentStack
the runtime data stack for this environment |
protected String |
errorMessage
stored error message... |
protected int |
findex
|
protected ArrayList |
frames
|
protected boolean |
isBreak
value that determines if we are breaking out of the current loop or not |
protected ScriptInstance |
self
the script instance that this is the environment for |
Constructor Summary | |
ScriptEnvironment()
Not recommended that you instantiate a script environment in this way |
|
ScriptEnvironment(Hashtable env,
ScriptInstance myscript)
Instantiate a new script environment with the specified environment (can be shared), and the specified ScriptInstance |
Method Summary | |
String |
checkError()
once an error is checked using this function, it is cleared, the orignal error message is returned as well |
void |
clearCache()
clears the cache of parsed and evaluated strings used by the "evaluate*" methods |
void |
clearReturn()
|
void |
CreateFrame()
|
Scalar |
evaluateExpression(String code)
evaluates an expression |
Scalar |
evaluateParsedLiteral(String code)
evaluates the passed in code as if it was a sleep parsed literal |
boolean |
evaluatePredicate(String code)
evaluates a predicate condition |
Scalar |
evaluateStatement(String code)
evaluate a full blown statement... |
void |
flagBreak(boolean flag)
determine wether or not we want to break out of the current loop |
void |
flagError(String message)
A utility for bridge writers to flag an error. |
void |
flagReturn(Scalar value)
|
Stack |
getCurrentFrame()
|
Hashtable |
getEnvironment()
Returns the environment for this script. |
Stack |
getEnvironmentStack()
returns the environment stack used for temporary calculations and such. |
FilterEnvironment |
getFilterEnvironment(String env)
|
Function |
getFunction(String func)
|
Environment |
getFunctionEnvironment(String env)
|
Operator |
getOperator(String oper)
|
Predicate |
getPredicate(String name)
|
PredicateEnvironment |
getPredicateEnvironment(String env)
|
Scalar |
getReturnValue()
|
Scalar |
getScalar(String key)
returns a scalar from this scripts environment |
ScriptInstance |
getScriptInstance()
returns a reference to the script associated with this environment |
ScriptVariables |
getScriptVariables()
returns the variable manager for this script |
boolean |
isBreak()
checks wether or not we want to break out of the current loop |
boolean |
isReturn()
|
void |
KillFrame()
|
void |
putScalar(String key,
Scalar value)
puts a scalar into this scripts environment |
void |
setEnvironment(Hashtable h)
Sets the environment Hashtable this script is to use. |
String |
toString()
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
protected ScriptInstance self
protected Stack environmentStack
protected Hashtable environment
protected String errorMessage
protected ArrayList frames
protected int findex
protected boolean isBreak
Constructor Detail |
public ScriptEnvironment()
public ScriptEnvironment(Hashtable env, ScriptInstance myscript)
Method Detail |
public ScriptInstance getScriptInstance()
public void flagError(String message)
public String checkError()
public ScriptVariables getScriptVariables()
public Scalar getScalar(String key)
public void putScalar(String key, Scalar value)
public Function getFunction(String func)
public Environment getFunctionEnvironment(String env)
public PredicateEnvironment getPredicateEnvironment(String env)
public FilterEnvironment getFilterEnvironment(String env)
public Predicate getPredicate(String name)
public Operator getOperator(String oper)
public Hashtable getEnvironment()
public void setEnvironment(Hashtable h)
public Stack getEnvironmentStack()
public String toString()
public Scalar getReturnValue()
public boolean isReturn()
public void flagReturn(Scalar value)
public void clearReturn()
public Stack getCurrentFrame()
public void KillFrame()
public void CreateFrame()
public void flagBreak(boolean flag)
public boolean isBreak()
public void clearCache()
public Scalar evaluateStatement(String code) throws YourCodeSucksException
YourCodeSucksException
public boolean evaluatePredicate(String code) throws YourCodeSucksException
YourCodeSucksException
public Scalar evaluateExpression(String code) throws YourCodeSucksException
YourCodeSucksException
public Scalar evaluateParsedLiteral(String code) throws YourCodeSucksException
YourCodeSucksException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |