orc.runtime
Class Token

java.lang.Object
  extended by orc.runtime.Token
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable<Token>

public class Token
extends java.lang.Object
implements java.io.Serializable, java.lang.Comparable<Token>

Representation of an active thread of execution. Tokens move over the node graph as they are executed. They contain an environment, and may belong to a group. They also preserve the call chain and contain a value to be passed to the next token.

Author:
wcook
See Also:
Serialized Form

Field Summary
protected  OrcEngine engine
           
protected  Env<Future> env
           
protected  GroupCell group
           
protected  Node node
           
protected  Region region
           
 
Constructor Summary
Token(Node node, Env<Future> env, Execution exec)
           
Token(Node node, Env<Future> env, Token caller, GroupCell group, Region region, Value result, OrcEngine engine)
           
 
Method Summary
 void activate()
           
 void activate(Value v)
           
 Value arg(Arg a)
           
 Token bind(Future f)
          Push a new future onto the environment stack
 Callable call(Arg a)
           
 Token callcopy(Node node, Env<Future> env, Token returnToken)
          Create a copy of this token with the same dynamic characteristics, but executing at a new point in the graph with a different environment.
 int compareTo(Token t)
           
 Token copy()
          Create a copy of the token
 void debug(java.lang.String s)
           
 void die()
           
 void error(TokenException problem)
           
 void finalize()
           
 Token getCaller()
           
 OrcEngine getEngine()
           
 Env<Future> getEnvironment()
           
 GroupCell getGroup()
           
 Node getNode()
           
 Region getRegion()
           
 Value getResult()
           
 Future lookup(Arg a)
          Lookup a variable in the environment
 Token move(Node node)
          Move to a node node
 void process()
          If a token is alive, calls the node to perform the next action.
 void resume()
           
 void resume(Value v)
           
 Token setEnv(Env<Future> e)
           
 Token setGroup(GroupCell group)
           
 Token setRegion(Region region)
           
 Token setResult(Value result)
           
 Token unwind(int width)
          Pop values off of the environment stack.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

node

protected Node node

env

protected Env<Future> env

group

protected GroupCell group

region

protected Region region

engine

protected OrcEngine engine
Constructor Detail

Token

public Token(Node node,
             Env<Future> env,
             Token caller,
             GroupCell group,
             Region region,
             Value result,
             OrcEngine engine)

Token

public Token(Node node,
             Env<Future> env,
             Execution exec)
Method Detail

die

public void die()

finalize

public void finalize()
Overrides:
finalize in class java.lang.Object

process

public void process()
If a token is alive, calls the node to perform the next action.


getNode

public Node getNode()

getGroup

public GroupCell getGroup()

getEnvironment

public Env<Future> getEnvironment()

getResult

public Value getResult()

getCaller

public Token getCaller()

getEngine

public OrcEngine getEngine()

getRegion

public Region getRegion()

setResult

public Token setResult(Value result)

setGroup

public Token setGroup(GroupCell group)

setRegion

public Token setRegion(Region region)

setEnv

public Token setEnv(Env<Future> e)

move

public Token move(Node node)
Move to a node node

Parameters:
node - the node to move to
Returns:
returns self

callcopy

public Token callcopy(Node node,
                      Env<Future> env,
                      Token returnToken)
Create a copy of this token with the same dynamic characteristics, but executing at a new point in the graph with a different environment. Set the new caller's token to the token provided.


copy

public Token copy()
Create a copy of the token

Returns:
new token

bind

public Token bind(Future f)
Push a new future onto the environment stack

Parameters:
f - future to push
Returns:
self

unwind

public Token unwind(int width)
Pop values off of the environment stack. Used to leave binding scopes.

Returns:

lookup

public Future lookup(Arg a)
Lookup a variable in the environment

Parameters:
var - variable name
Returns:
value, or an error if the variable is undefined

call

public Callable call(Arg a)
              throws UncallableValueException
Throws:
UncallableValueException

arg

public Value arg(Arg a)

compareTo

public int compareTo(Token t)
Specified by:
compareTo in interface java.lang.Comparable<Token>

debug

public void debug(java.lang.String s)

activate

public void activate()

activate

public void activate(Value v)

resume

public void resume(Value v)

resume

public void resume()

error

public void error(TokenException problem)