orc.ast.simple
Class WithLocation
java.lang.Object
orc.ast.simple.Expression
orc.ast.simple.WithLocation
- All Implemented Interfaces:
- Located
public class WithLocation
- extends Expression
- implements Located
Annotate an expression with a source location.
- Author:
- quark
Method Summary |
Expr |
convert(Env<Var> vars,
Env<java.lang.String> typevars)
Converts abstract syntax tree into a serializable form, used to generate
portable .oil (Orc Intermediate Language) files. |
SourceLocation |
getSourceLocation()
|
Expression |
subst(Argument a,
NamedVar x)
Performs the substitution [a/x], replacing occurrences of the free variable x
with the new argument a (which could be any argument, including another variable). |
java.util.Set<Var> |
vars()
Find the set of all unbound Vars (note: not FreeVars) in this expression. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
WithLocation
public WithLocation(Expression expr,
SourceLocation location)
convert
public Expr convert(Env<Var> vars,
Env<java.lang.String> typevars)
throws CompilationException
- Description copied from class:
Expression
- Converts abstract syntax tree into a serializable form, used to generate
portable .oil (Orc Intermediate Language) files.
Note that the typevars environment is a content-addressable environment
of strings. Type vars are represented as strings for simplicity, because
unlike regular vars, there are not yet any compiler steps which generate
temporary type variables.
- Specified by:
convert
in class Expression
- Parameters:
vars
- The vars environment, used in content addressable mode to
find the appropriate deBruijn index of a var.typevars
- The type vars environment, used in content addressable
mode to find the appropriate deBruijn index of a type var.
- Returns:
- A new node.
- Throws:
CompilationException
subst
public Expression subst(Argument a,
NamedVar x)
- Description copied from class:
Expression
- Performs the substitution [a/x], replacing occurrences of the free variable x
with the new argument a (which could be any argument, including another variable).
- Specified by:
subst
in class Expression
- Parameters:
a
- The replacing variable or valuex
- The free variable whose occurrences will be replaced
- Returns:
- A new copy of the expression with the substitution performed
vars
public java.util.Set<Var> vars()
- Description copied from class:
Expression
- Find the set of all unbound Vars (note: not FreeVars) in this expression.
- Specified by:
vars
in class Expression
getSourceLocation
public SourceLocation getSourceLocation()
- Specified by:
getSourceLocation
in interface Located