Package sleep.bridges
Class BasicNumbers
- java.lang.Object
-
- sleep.bridges.BasicNumbers
-
-
Constructor Summary
Constructors Constructor Description BasicNumbers()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
decide(java.lang.String n, ScriptInstance i, java.util.Stack l)
decides the truthfulness of the proposition predicateName applied to the passedInTerms.Scalar
evaluate(java.lang.String name, ScriptInstance si, java.util.Stack args)
Evaluate a function and return the resulting scalar.Scalar
operate(java.lang.String o, ScriptInstance i, java.util.Stack locals)
apply operator operatorName on the values in the stack.void
scriptLoaded(ScriptInstance aScript)
called when a script is loadedvoid
scriptUnloaded(ScriptInstance aScript)
called when a script is unloaded
-
-
-
Method Detail
-
scriptUnloaded
public void scriptUnloaded(ScriptInstance aScript)
Description copied from interface:Loadable
called when a script is unloaded- Specified by:
scriptUnloaded
in interfaceLoadable
-
scriptLoaded
public void scriptLoaded(ScriptInstance aScript)
Description copied from interface:Loadable
called when a script is loaded- Specified by:
scriptLoaded
in interfaceLoadable
-
evaluate
public Scalar evaluate(java.lang.String name, ScriptInstance si, java.util.Stack args)
Description copied from interface:Function
Evaluate 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:
evaluate
in interfaceFunction
- Parameters:
name
- the function being called.si
- an instance of the script calling this function.args
- 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)
-
decide
public boolean decide(java.lang.String n, ScriptInstance i, java.util.Stack l)
Description copied from interface:Predicate
decides the truthfulness of the proposition predicateName applied to the passedInTerms.- Specified by:
decide
in interfacePredicate
- Parameters:
n
- a predicate i.e. ==i
- an instance of the script asking about this predicate.l
- 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.
-
operate
public Scalar operate(java.lang.String o, ScriptInstance i, java.util.Stack locals)
Description copied from interface:Operator
apply operator operatorName on the values in the stack.- Specified by:
operate
in interfaceOperator
- Parameters:
o
- the name of the operator, for example the String "+"i
- instance of the script calling this operatorlocals
- a stack containing values the operator is to be applied to: [left hand side, right hand side]- Returns:
- a Scalar containing the result of the operatorName applied to the passedInLocals, in the case of "+" applied to [4, 3] we would get a Scalar containing the integer 7.
-
-