|
|||||||||
| 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
public class ErrorHandlingVisitor
| Field Summary | |
|---|---|
protected boolean |
error
|
protected Job |
job
|
protected NodeFactory |
nf
|
protected TypeSystem |
ts
|
| Constructor Summary | |
|---|---|
ErrorHandlingVisitor(Job job,
TypeSystem ts,
NodeFactory nf)
|
|
| Method Summary | |
|---|---|
NodeVisitor |
begin()
Part of the initialization done by begin() in an ErrorHandlingVisitor method is initializing the error-handling state. |
protected boolean |
catchErrors(Node n)
Return true if we should catch errors thrown when visiting the node. |
NodeVisitor |
enter(Node parent,
Node n)
Begin normal traversal of a subtree rooted at n. |
protected NodeVisitor |
enterCall(Node n)
|
protected NodeVisitor |
enterCall(Node parent,
Node n)
Replaces the functionality of the enter() method; all
sub-classes should over-ride this method instead of
enter() if there is any chance of exceptions being
generated. |
protected NodeVisitor |
enterError(Node n)
This method determines what should be returned by enter()
should its call to enterCall() throw a
SemanticException. |
ErrorQueue |
errorQueue()
Returns the ErrorQueue for the current Job. |
Job |
job()
Returns the Job that this Visitor is part of. |
Node |
leave(Node parent,
Node old,
Node n,
NodeVisitor v)
This method is called after all of the children of n
have been visited. |
protected Node |
leaveCall(Node n)
|
protected Node |
leaveCall(Node old,
Node n,
NodeVisitor v)
Contains all of the functionality that can be done in the leave
method, but allows SemanticExceptions to be
thrown. |
NodeFactory |
nodeFactory()
Returns the NodeFactory that this Visitor is using. |
TypeSystem |
typeSystem()
Returns the TypeSystem that this Visitor is using. |
| 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 boolean error
protected Job job
protected TypeSystem ts
protected NodeFactory nf
| Constructor Detail |
|---|
public ErrorHandlingVisitor(Job job,
TypeSystem ts,
NodeFactory nf)
| Method Detail |
|---|
public Job job()
Job that this Visitor is part of.
Jobpublic NodeVisitor begin()
begin in class NodeVisitorNodeVisitor to traverse the ast with. If
null is returned, the ast is not traversed.public ErrorQueue errorQueue()
ErrorQueue for the current Job.
ErrorQueuepublic NodeFactory nodeFactory()
NodeFactory that this Visitor is using.
NodeFactorypublic TypeSystem typeSystem()
TypeSystem that this Visitor is using.
TypeSystem
protected NodeVisitor enterCall(Node parent,
Node n)
throws SemanticException
enter() method; all
sub-classes should over-ride this method instead of
enter() if there is any chance of exceptions being
generated.
This method is the replacement for the enter() method,
so that all of its subclasses gain the error handling capabilities
of this visitor without having to rewrite it for the
enter() for each sub-class.
This method allows for a SemanticException to be
thrown in the body, while enter() does not.
n - The root of the subtree to be traversed.
ErrorHandlingVisitor which should be
used to visit the children of n.
SemanticExceptionNodeVisitor.enter(Node, Node)
protected NodeVisitor enterCall(Node n)
throws SemanticException
SemanticExceptionprotected NodeVisitor enterError(Node n)
enter()
should its call to enterCall() throw a
SemanticException.
n - The root of the subtree that was traversed.
ErrorHandlingVisitor which should be
used to visit the childre of n.
protected Node leaveCall(Node old,
Node n,
NodeVisitor v)
throws SemanticException
leave
method, but allows SemanticExceptions to be
thrown.
This method is in addition to the leave method,
and allows the compiler writer to write code that can throw errors
and let the polyglot infrastructure handle the exceptions.
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.
SemanticExceptionNodeVisitor.leave(Node, Node, NodeVisitor)
protected Node leaveCall(Node n)
throws SemanticException
SemanticExceptionprotected boolean catchErrors(Node n)
public NodeVisitor enter(Node parent,
Node n)
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 NodeVisitorn - The root of the subtree to be traversed.parent - The parent of n, null if n has no parent.
NodeVisitor which should be used to visit the
children of n.
public Node leave(Node parent,
Node old,
Node n,
NodeVisitor v)
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 NodeVisitorold - 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.parent - The parent of old,
null if old has no parent.
n.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||