|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectpolyglot.visit.NodeVisitor
polyglot.visit.HaltingVisitor
polyglot.visit.ErrorHandlingVisitor
polyglot.visit.ContextVisitor
public class ContextVisitor
A visitor which maintains a context throughout the visitor's pass. This is
the base class of the disambiguation and type checking visitors.
TODO: update this documentation.
For a node n
methods are called in this order:
v.enter(n) v.enterScope(n); c' = n.enterScope(c) v' = copy(v) with c' for c n' = n.visitChildren(v') v.leave(n, n', v') v.addDecls(n') n.addDecls(c)
Field Summary | |
---|---|
protected Context |
context
The current context of this visitor. |
protected ContextVisitor |
outer
|
Fields inherited from class polyglot.visit.ErrorHandlingVisitor |
---|
error, job, nf, ts |
Constructor Summary | |
---|---|
ContextVisitor(Job job,
TypeSystem ts,
NodeFactory nf)
|
Method Summary | |
---|---|
protected void |
addDecls(Node n)
Imperatively update the context with declarations to be added after visiting the node. |
NodeVisitor |
begin()
Part of the initialization done by begin() in an ErrorHandlingVisitor method is initializing the error-handling state. |
Context |
context()
Returns the context for this visitor. |
ContextVisitor |
context(Context c)
Returns a new ContextVisitor that is a copy of the current visitor, except with an updated context. |
NodeVisitor |
enter(Node parent,
Node n)
Begin normal traversal of a subtree rooted at n . |
protected Context |
enterScope(Node parent,
Node n)
Returns a new context based on the current context, the Node current being visited ( parent ), and the Node that is being
entered (n ). |
Node |
leave(Node parent,
Node old,
Node n,
NodeVisitor v)
This method is called after all of the children of n
have been visited. |
NodeVisitor |
superEnter(Node parent,
Node n)
|
Methods inherited from class polyglot.visit.ErrorHandlingVisitor |
---|
catchErrors, enterCall, enterCall, enterError, errorQueue, job, leaveCall, leaveCall, nodeFactory, typeSystem |
Methods inherited from class polyglot.visit.HaltingVisitor |
---|
bypass, bypass, bypassChildren, copy, override, visitChildren |
Methods inherited from class polyglot.visit.NodeVisitor |
---|
enter, finish, finish, leave, override, toString, visitEdge |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected ContextVisitor outer
protected Context context
Constructor Detail |
---|
public ContextVisitor(Job job, TypeSystem ts, NodeFactory nf)
Method Detail |
---|
public NodeVisitor begin()
ErrorHandlingVisitor
begin
in class ErrorHandlingVisitor
NodeVisitor
to traverse the ast with. If
null
is returned, the ast is not traversed.public Context context()
Context
public ContextVisitor context(Context c)
c
- The new context that is to be used.
c
.protected Context enterScope(Node parent, Node n)
parent
), and the Node that is being
entered (n
). This new context is to be used
for visiting n
.
n
.protected void addDecls(Node n)
public NodeVisitor enter(Node parent, Node n)
ErrorHandlingVisitor
n
. This gives
the visitor the option of changing internal state or returning a new
visitor which will be used to visit the children of n
.
This method delegates all responsibility of functionality to the
enterCall
method, and handles and reports any exceptions
generated by enterCall
.
In overriding this method, unless the class explicitly does not
want to maintain any of the error handling aspects of this class, a call
super.enter
should be embedded within the method at the
end.
enter
in class ErrorHandlingVisitor
parent
- The parent of n
, null
if n
has no parent.n
- The root of the subtree to be traversed.
NodeVisitor
which should be used to visit the
children of n
.public NodeVisitor superEnter(Node parent, Node n)
public Node leave(Node parent, Node old, Node n, NodeVisitor v)
ErrorHandlingVisitor
n
have been visited. In this case, these children were visited by the
visitor v
. This is the last chance for the visitor to
modify the tree rooted at n
. This method will be called
exactly the same number of times as entry
is called.
That is, for each node that is not overriden, enter
and
leave
are each called exactly once.
Note that if old == n
then the vistior should make a copy
of n
before modifying it. It should then return the
modified copy.
This method delegates all responsibility of functionality to the
leaveCall
method, and handles and reports any exceptions
generated by leaveCall
.
In overriding this method, unless the class explicitly does not
want to maintain any of the error handling aspects of this class, a call
super.leave
should be embedded within the method at the
end.
leave
in class ErrorHandlingVisitor
parent
- The parent of old
,
null
if old
has no parent.old
- The original state of root of the current subtree.n
- The current state of the root of the current subtree.v
- The NodeVisitor
object used to visit the children.
n
.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |