com.sun.tools.javac.comp
public class: Env [javadoc |
source]
java.lang.Object
com.sun.tools.javac.comp.Env
All Implemented Interfaces:
Iterable
Direct Known Subclasses:
AttrContextEnv
A class for environments, instances of which are passed as
arguments to tree visitors. Environments refer to important ancestors
of the subtree that's currently visited, such as the enclosing method,
the enclosing class, or the enclosing toplevel node. They also contain
a generic component, represented as a type parameter, to carry further
information specific to individual passes.
This is NOT part of any supported API.
If you write code that depends on this, you do so at your own risk.
This code and its internal interfaces are subject to change or
deletion without notice.
Field Summary |
---|
public Env<A> | next | The next enclosing environment. |
public Env<A> | outer | The environment enclosing the current class. |
public JCTree | tree | The tree with which this environment is associated. |
public JCCompilationUnit | toplevel | The enclosing toplevel tree. |
public JCClassDecl | enclClass | The next enclosing class definition. |
public JCMethodDecl | enclMethod | The next enclosing method definition. |
public A | info | A generic field for further information. |
public boolean | baseClause | Is this an environment for evaluating a base clause? |
Constructor: |
public Env(JCTree tree,
A info) {
this.next = null;
this.outer = null;
this.tree = tree;
this.toplevel = null;
this.enclClass = null;
this.enclMethod = null;
this.info = info;
}
Create an outermost environment for a given (toplevel)tree,
with a given info field. |
Methods from java.lang.Object: |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method from com.sun.tools.javac.comp.Env Detail: |
public Env<A> dup(JCTree tree) {
return dup(tree, this.info);
}
Duplicate this environment, updating with given tree,
and copying all other fields. |
public Env<A> dup(JCTree tree,
A info) {
return dupto(new Env< A >(tree, info));
}
Duplicate this environment, updating with given tree and info,
and copying all other fields. |
public Env<A> dupto(Env<A> that) {
that.next = this;
that.outer = this.outer;
that.toplevel = this.toplevel;
that.enclClass = this.enclClass;
that.enclMethod = this.enclMethod;
return that;
}
Duplicate this environment into a given Environment,
using its tree and info, and copying all other fields. |
public Env<A> enclosing(int tag) {
Env< A > env1 = this;
while (env1 != null && env1.tree.getTag() != tag) env1 = env1.next;
return env1;
}
Return closest enclosing environment which points to a tree with given tag. |
public Iterator<A> iterator() {
return new Iterator< Env< A > >() {
Env< A > next = Env.this;
public boolean hasNext() {
return next.outer != null;
}
public Env< A > next() {
if (hasNext()) {
Env< A > current = next;
next = current.outer;
return current;
}
throw new NoSuchElementException();
}
public void remove() {
throw new UnsupportedOperationException();
}
};
}
|
public String toString() {
return "Env[" + info + (outer == null ? "" : ",outer=" + outer) + "]";
}
|