orc.ast.oil
Class Expr

java.lang.Object
  extended by orc.ast.oil.Expr
Direct Known Subclasses:
Arg, Bar, Call, Defs, Null, Pull, Push, Semi

public abstract class Expr
extends java.lang.Object

Base class for the portable (.oil, for Orc Intermediate Language) abstract syntax tree.

Author:
dkitchin

Constructor Summary
Expr()
           
 
Method Summary
abstract
<E> E
accept(Visitor<E> visitor)
           
 void addIndices(java.util.Set<java.lang.Integer> indices, int depth)
          If this expression has any indices which are >= depth, add (index - depth) to the index set accumulator.
 Node compile()
           
abstract  Node compile(Node output)
          Compiles an oil syntax tree into an execution graph.
 java.util.Set<Var> freeVars()
          Find the set of free variables in this expression.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Expr

public Expr()
Method Detail

compile

public abstract Node compile(Node output)
Compiles an oil syntax tree into an execution graph. Every node is compiled relative to an "output" node that represents the "rest of the program". Thus the tree of compiled nodes is created bottom up.

Parameters:
output - This is the node to which output (publications) will be directed.
Returns:
A new node.

compile

public Node compile()

freeVars

public java.util.Set<Var> freeVars()
Find the set of free variables in this expression.

Returns:
The set of free variables.

addIndices

public void addIndices(java.util.Set<java.lang.Integer> indices,
                       int depth)
If this expression has any indices which are >= depth, add (index - depth) to the index set accumulator. The depth increases each time this method recurses through a binder. The default implementation is to assume the expression has no free variables, and thus do nothing. Expressions which contain variables or subexpressions override this behavior.

Parameters:
indices - The index set accumulator.
depth - The minimum index for a free variable.

accept

public abstract <E> E accept(Visitor<E> visitor)