public class ContextVisitor extends ErrorHandlingVisitor
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') v.addDecls(n') n'.addDecls(c)
Modifier and Type | Field and Description |
---|---|
protected Context |
context
The current context of this visitor.
|
protected ContextVisitor |
outer |
protected boolean |
prune |
protected boolean |
rethrowMissingDependencies
Should MissingDependencyExceptions be rethrown? If not,
then the dependency is added to the scheduler, and
the visitor continues.
|
error, job, nf, ts
bypass, bypassParent
Constructor and Description |
---|
ContextVisitor(Job job,
TypeSystem ts,
NodeFactory nf) |
Modifier and Type | Method and Description |
---|---|
protected void |
addDecls(Node n)
Imperatively update the context with declarations to be added after
visiting the node.
|
protected void |
addDecls(Node old,
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 n)
Begin normal traversal of a subtree rooted at
n . |
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. |
ContextVisitor |
rethrowMissingDependencies(boolean rethrow) |
NodeVisitor |
superEnter(Node parent,
Node n) |
catchErrors, enterCall, enterCall, enterError, errorQueue, hasErrors, job, leaveCall, leaveCall, leaveCall, nodeFactory, typeSystem
bypass, bypass, bypassChildren, override, visitChildren
copy, finish, finish, lang, leave, override, toString, visitEdge, visitEdgeNoOverride
protected ContextVisitor outer
protected boolean rethrowMissingDependencies
protected Context context
protected boolean prune
public ContextVisitor(Job job, TypeSystem ts, NodeFactory nf)
public ContextVisitor rethrowMissingDependencies(boolean rethrow)
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 old, Node n)
protected void addDecls(Node n)
public final NodeVisitor enter(Node n)
NodeVisitor
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 is typically called by the method
enter(parent, n)
. If a subclass overrides the
method enter(parent, n)
then this method
may not be called.
enter
in class NodeVisitor
n
- The root of the subtree to be traversed.NodeVisitor
which should be used to visit the
children of n
.public final 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 final 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 overridden, enter
and
leave
are each called exactly once.
Note that if old == n
then the visitor 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
.