orc.env
Class Env<T>
java.lang.Object
orc.env.Env<T>
- All Implemented Interfaces:
- java.io.Serializable
public class Env<T>
- extends java.lang.Object
- implements java.io.Serializable
Generic indexed environment, used primarily at runtime.
Env is also content addressable, so it can be used for the
deBruijn index conversion in the compiler.
- Author:
- dkitchin
- See Also:
- Serialized Form
Nested Class Summary |
protected class |
Env.ENode
Individual entries in the environment. |
Method Summary |
Env<T> |
add(T item)
|
Env<T> |
addAll(java.util.List<T> items)
|
T |
lookup(int index)
Lookup a variable in the environment
Currently uses a linear search. |
int |
search(T target)
Content addressable mode. |
Env<T> |
unwind(int width)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Env
protected Env(Env.ENode node)
Env
public Env()
add
public Env<T> add(T item)
addAll
public Env<T> addAll(java.util.List<T> items)
lookup
public T lookup(int index)
- Lookup a variable in the environment
Currently uses a linear search.
- Parameters:
index
- Stack depth (a deBruijn index)
- Returns:
- The bound item
search
public int search(T target)
- Content addressable mode. Used in compilation
to determine the deBruijn indices from an
environment populated by Var objects.
Assuming no error is raised, search and lookup are inverses:
search(lookup(i)) = i
lookup(search(o)) = o
- Parameters:
target
- The item
- Returns:
- The index of the target item
unwind
public Env<T> unwind(int width)