public class TVCaster extends AscriptionVisitor
outer, type
context, prune, rethrowMissingDependencies
error, job, nf, ts
bypass, bypassParent
Constructor and Description |
---|
TVCaster(Job job,
TypeSystem ts,
NodeFactory nf) |
Modifier and Type | Method and Description |
---|---|
Expr |
ascribe(Expr e,
Type toType)
The
ascribe() method is called for each expression
and is passed the type the expression is used at rather
than the type the type
checker assigns to it. |
NodeVisitor |
enterCall(Node parent,
Node n)
Sets up the expected type information for later calls to
ascribe() . |
protected Node |
leaveCall(Node parent,
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. |
lang, leaveCall, pop, toType
addDecls, addDecls, begin, context, context, enter, enter, enterScope, leave, rethrowMissingDependencies, superEnter
catchErrors, enterCall, enterError, errorQueue, hasErrors, job, leaveCall, nodeFactory, typeSystem
bypass, bypass, bypassChildren, override, visitChildren
copy, finish, finish, leave, override, toString, visitEdge, visitEdgeNoOverride
public TVCaster(Job job, TypeSystem ts, NodeFactory nf)
public Expr ascribe(Expr e, Type toType) throws SemanticException
AscriptionVisitor
ascribe()
method is called for each expression
and is passed the type the expression is used at rather
than the type the type
checker assigns to it.
For instance, with the following code:
Object o = new Integer(3);
ascribe()
will be called with expression
new Integer(3)
and type Object
.ascribe
in class AscriptionVisitor
e
- The expression that is being visitedtoType
- The type that the parent node is expecting.SemanticException
public NodeVisitor enterCall(Node parent, Node n) throws SemanticException
AscriptionVisitor
ascribe()
. Other than that, plays the same role
as the enterCall
method in
ErrorHandlingVisitor
.enterCall
in class AscriptionVisitor
n
- The root of the subtree to be traversed.ErrorHandlingVisitor
which should be
used to visit the children of n
.SemanticException
NodeVisitor.enter(Node, Node)
protected Node leaveCall(Node parent, Node old, Node n, NodeVisitor v) throws SemanticException
ErrorHandlingVisitor
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.leaveCall
in class ErrorHandlingVisitor
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
.SemanticException
NodeVisitor.leave(Node, Node, NodeVisitor)