Package sleep.bridges
Class BasicUtilities
- java.lang.Object
-
- sleep.bridges.BasicUtilities
-
-
Constructor Summary
Constructors Constructor Description BasicUtilities()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleandecide(java.lang.String predName, ScriptInstance anInstance, java.util.Stack terms)decides the truthfulness of the proposition predicateName applied to the passedInTerms.Scalarevaluate(java.lang.String n, ScriptInstance i, java.util.Stack l)Evaluate a function and return the resulting scalar.voidscriptLoaded(ScriptInstance i)called when a script is loadedvoidscriptUnloaded(ScriptInstance i)called when a script is unloaded
-
-
-
Method Detail
-
scriptUnloaded
public void scriptUnloaded(ScriptInstance i)
Description copied from interface:Loadablecalled when a script is unloaded- Specified by:
scriptUnloadedin interfaceLoadable
-
scriptLoaded
public void scriptLoaded(ScriptInstance i)
Description copied from interface:Loadablecalled when a script is loaded- Specified by:
scriptLoadedin interfaceLoadable
-
decide
public boolean decide(java.lang.String predName, ScriptInstance anInstance, java.util.Stack terms)Description copied from interface:Predicatedecides the truthfulness of the proposition predicateName applied to the passedInTerms.- Specified by:
decidein interfacePredicate- Parameters:
predName- a predicate i.e. ==anInstance- an instance of the script asking about this predicate.terms- a stack of terms i.e. [3, 4]. These arguments are passed in REVERSE ORDER i.e. [right hand side, left hand side]- Returns:
- a boolean, in the case of a predicate == and the terms [3, 4] we know 3 == 4 is false so return false.
-
evaluate
public Scalar evaluate(java.lang.String n, ScriptInstance i, java.util.Stack l)
Description copied from interface:FunctionEvaluate a function and return the resulting scalar. Only the sleep interpreter should ever call this function. If you have a maddening desire to call this Function object yourself, then use the convienence method in SleepUtils.- Specified by:
evaluatein interfaceFunction- Parameters:
n- the function being called.i- an instance of the script calling this function.l- a stack containing the locals passed to this function. The locals are Scalar values passed in reverse order i.e. [arg n, arg n-1, ..., arg 1, arg 0]- Returns:
- an instance of Scalar containing the return value of this function.
- See Also:
SleepUtils.runCode(Function, String, ScriptInstance, Stack)
-
-