polyglot.ext.covarRet
Class CovarRetRewriter
java.lang.Object
polyglot.visit.NodeVisitor
polyglot.visit.HaltingVisitor
polyglot.visit.ErrorHandlingVisitor
polyglot.visit.ContextVisitor
polyglot.visit.AscriptionVisitor
polyglot.ext.covarRet.CovarRetRewriter
- All Implemented Interfaces:
- java.lang.Cloneable, Copy
- public class CovarRetRewriter
- extends AscriptionVisitor
This visitor rewrites the AST to translate from Java with covariant returns
to standard Java.
Method Summary |
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. |
Node |
leaveCall(Node old,
Node n,
NodeVisitor v)
Calls ascribe() with the expected type and expression
as appropriate. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
CovarRetRewriter
public CovarRetRewriter(Job job,
TypeSystem ts,
NodeFactory nf)
ascribe
public Expr ascribe(Expr e,
Type toType)
- Description copied from class:
AscriptionVisitor
- 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.
For instance, with the following code:
Object o = new Integer(3);
ascribe()
will be called with expression
new Integer(3)
and type Object
.
- Overrides:
ascribe
in class AscriptionVisitor
- Parameters:
e
- The expression that is being visitedtoType
- The type that the parent node is expecting.
- Returns:
- The new translated Expr node, or if nothing has changed, just
e.
leaveCall
public Node leaveCall(Node old,
Node n,
NodeVisitor v)
throws SemanticException
- Description copied from class:
AscriptionVisitor
- Calls
ascribe() with the expected type and expression
as appropriate. Otherwise functionally the same as the
leaveCall
method in ErrorHandlingVisitor
.
- Overrides:
leaveCall
in class AscriptionVisitor
- Throws:
SemanticException