orc.ast.oil
Class Expr

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

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)
           
abstract  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.
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.
 void typecheck(Type T, Env<Type> ctx)
           
abstract  Type typesynth(Env<Type> ctx)
           
 
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.

typesynth

public abstract Type typesynth(Env<Type> ctx)
                        throws TypeException
Throws:
TypeException

typecheck

public void typecheck(Type T,
                      Env<Type> ctx)
               throws TypeException
Throws:
TypeException

freeVars

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

Returns:
The set of free variables.

addIndices

public abstract 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)