sleep.bridges
Class BasicNumbers

java.lang.Object
  extended bysleep.bridges.BasicNumbers
All Implemented Interfaces:
Loadable, Operator, Predicate

public class BasicNumbers
extends Object
implements Predicate, Operator, Loadable

provides some of the basic number crunching functionality


Field Summary
static Class TYPE_DOUBLE
           
static Class TYPE_INT
           
static Class TYPE_LONG
           
 
Constructor Summary
BasicNumbers()
           
 
Method Summary
 boolean decide(String n, ScriptInstance i, Stack l)
          decides the truthfulness of the proposition predicateName applied to the passedInTerms.
 Scalar operate(String o, ScriptInstance i, Stack locals)
          apply operator operatorName on the values in the stack.
 boolean scriptLoaded(ScriptInstance aScript)
          called when a script is loaded
 boolean scriptUnloaded(ScriptInstance aScript)
          called when a script is unloaded
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TYPE_LONG

public static Class TYPE_LONG

TYPE_INT

public static Class TYPE_INT

TYPE_DOUBLE

public static Class TYPE_DOUBLE
Constructor Detail

BasicNumbers

public BasicNumbers()
Method Detail

scriptUnloaded

public boolean scriptUnloaded(ScriptInstance aScript)
Description copied from interface: Loadable
called when a script is unloaded

Specified by:
scriptUnloaded in interface Loadable

scriptLoaded

public boolean scriptLoaded(ScriptInstance aScript)
Description copied from interface: Loadable
called when a script is loaded

Specified by:
scriptLoaded in interface Loadable

decide

public boolean decide(String n,
                      ScriptInstance i,
                      Stack l)
Description copied from interface: Predicate
decides the truthfulness of the proposition predicateName applied to the passedInTerms.

Specified by:
decide in interface Predicate
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(String o,
                      ScriptInstance i,
                      Stack locals)
Description copied from interface: Operator
apply operator operatorName on the values in the stack.

Specified by:
operate in interface Operator
Parameters:
o - the name of the operator, for example the String "+"
i - instance of the script calling this operator
locals - 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.