|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object orc.env.Env<T>
public final class Env<T>
Generic indexed environment, used primarily at runtime. Env is also content addressable, so it can be used for deBruijn index conversions in the compiler. Env allows null values, a capability used in the typechecker to distinguish bound types from free ones.
Currently this is implemented as a simple linked-list of bindings, which provides O(n) lookups and O(1) copies. This sounds inefficient, but in practice turns out to be just as good or better than more complicated schemes for O(1) lookup.
Constructor Summary | |
---|---|
Env()
|
Method Summary | |
---|---|
void |
add(T item)
Push one item. |
void |
addAll(java.util.List<T> items)
Push multiple items, in the order they appear in the list. |
Env<T> |
clone()
Create an independent copy of the environment. |
Env<T> |
extend(T item)
Create an independent copy of the environment, extended with a new item. |
Env<T> |
extendAll(java.util.List<T> items)
Create an independent copy of the environment, extended with a list of new item. |
java.util.List<T> |
items()
Return a list of items in the order they were pushed. |
T |
lookup(int index)
Look up a variable's value in the environment. |
int |
search(T target)
Content-addressable mode. |
java.lang.String |
toString()
|
void |
unwind(int n)
Pop n items. |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Env()
Method Detail |
---|
public void add(T item)
public void addAll(java.util.List<T> items)
public java.util.List<T> items()
public T lookup(int index) throws LookupFailureException
index
- Stack depth (a deBruijn index)
LookupFailureException
public int search(T target) throws SearchFailureException
target
- The item
SearchFailureException
public void unwind(int n)
public Env<T> clone()
clone
in class java.lang.Object
public Env<T> extend(T item)
public Env<T> extendAll(java.util.List<T> items)
public java.lang.String toString()
toString
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |