orc.runtime.nodes
Class Defs

java.lang.Object
  extended by orc.runtime.nodes.Node
      extended by orc.runtime.nodes.Defs
All Implemented Interfaces:
java.io.Serializable

public class Defs
extends Node

See Also:
Serialized Form

Field Summary
 java.util.List<Def> defs
           
 java.util.Set<Var> free
          Variables defined outside this node which appear in the bodies of the defs.
 Node next
           
 
Constructor Summary
Defs(java.util.List<Def> defs, Node next, java.util.Set<Var> free)
           
 
Method Summary
 void process(Token t)
          Creates closures encapsulating the definitions and the defining environment.
 
Methods inherited from class orc.runtime.nodes.Node
isTerminal, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

defs

public java.util.List<Def> defs

next

public Node next

free

public java.util.Set<Var> free
Variables defined outside this node which appear in the bodies of the defs. If the defs are all mutually recursive, this is correct, otherwise this is overly pessimistic and may force some defs to wait on variables which they won't use.

Constructor Detail

Defs

public Defs(java.util.List<Def> defs,
            Node next,
            java.util.Set<Var> free)
Method Detail

process

public void process(Token t)
Creates closures encapsulating the definitions and the defining environment. The environment for the closure is the same as the input environment, but it is extended to include a binding for the definition name whose value is the closure. This means that the closure environment must refer to the closure, so there is a cycle in the object pointer graph. This cycle is constructed in two steps:
  • Create and bind the closure with a null environment
  • Update the closure to point to the new environment Then the next token is activated in this new environment. This is a standard technique for creating recursive closures.

    Closures created in this way are prevented them from being used in argument position until all unbound vars in the closure become bound. This is necessary to prevent unbound vars from escaping their binding context.

    Specified by:
    process in class Node
    Parameters:
    t - input token being processed