sleep.engine.atoms

Class Check

public class Check extends Object implements Serializable

A check object is the internal atomic step representing a predicate condition. This API is exposed to allow developers implementing a PredicateEnvironment bridge to take advantage of this API.

Everything required to setup the predicate check, evaluate all the ands/ors, and return true or false is handled by this atomic step.

To better illustrate what a Check is:

 if ($x == 3)
 { 
    println("\$x is 3");
 }

The above sleep code would be compiled into a sequence that looks like:

[Goto]:  (loop: false)
  [Condition]:
      [Predicate]: name->==  negated->false
         [Setup]:
            [Create Frame]
            [Scalar]: $x
            [Push]
            [Scalar]: 3
            [Push]
  [If true]:
      [Create Frame]
      [Parsed Literal]  null
         [Element]: $x is 3
      [Push]
      [Function Call]: &println
  [If False]:

The parts that are bolded are representative of the word done by the Check object.

See Also: PredicateEnvironment

Field Summary
Stringname
Constructor Summary
Check(String n, Block s)
Constructs a check object, call by the sleep engine.
Method Summary
booleancheck(ScriptEnvironment env)
Performs this "check".
voidsetChoices(Check t, Check f)
Sets up the true and false choices, again this is handled by the sleep engine
voidsetInfo(int _hint)
Sets the line number in code where this check object occurs, again called by the sleep engine
StringtoString(String prefix)
Converts this object to a string, used by the sleep engine for constructing an AST like thing
StringtoString()
Returns a string representation of this object

Field Detail

name

public String name

Constructor Detail

Check

public Check(String n, Block s)
Constructs a check object, call by the sleep engine.

Method Detail

check

public boolean check(ScriptEnvironment env)
Performs this "check". Returns the value of the condition that is checked.

setChoices

public void setChoices(Check t, Check f)
Sets up the true and false choices, again this is handled by the sleep engine

setInfo

public void setInfo(int _hint)
Sets the line number in code where this check object occurs, again called by the sleep engine

toString

public String toString(String prefix)
Converts this object to a string, used by the sleep engine for constructing an AST like thing

toString

public String toString()
Returns a string representation of this object