|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorc.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 the deBruijn index conversion in the compiler.
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. |
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. |
void |
unwind(int n)
Pop n items. |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, 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)
index
- Stack depth (a deBruijn index)
public int search(T target)
target
- The item
public void unwind(int n)
public Env<T> clone()
clone
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |