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> freeset
           
 Node next
           
 
Constructor Summary
Defs(java.util.List<Def> defs, Node next, java.util.Set<Var> freeset)
           
 
Method Summary
 void process(Token t)
          Creates closures encapsulating the definitions and the defining environment.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

defs

public java.util.List<Def> defs

next

public Node next

freeset

public java.util.Set<Var> freeset
Constructor Detail

Defs

public Defs(java.util.List<Def> defs,
            Node next,
            java.util.Set<Var> freeset)
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 three steps:
  • Create the closure with a null environment
  • Bind the name to the new closure
  • 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 protected by a PartialValue object, preventing them from being used in argument position until all unbound vars in all definition bodies become bound.

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