polyglot.ext.covarRet
Class CovarRetRewriter

java.lang.Object
  extended bypolyglot.visit.NodeVisitor
      extended bypolyglot.visit.HaltingVisitor
          extended bypolyglot.visit.ErrorHandlingVisitor
              extended bypolyglot.visit.ContextVisitor
                  extended bypolyglot.visit.AscriptionVisitor
                      extended bypolyglot.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.


Field Summary
 
Fields inherited from class polyglot.visit.ContextVisitor
context
 
Fields inherited from class polyglot.visit.ErrorHandlingVisitor
error, job, nf, ts
 
Constructor Summary
CovarRetRewriter(Job job, TypeSystem ts, NodeFactory nf)
           
 
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 polyglot.visit.AscriptionVisitor
enterCall, pop, toType
 
Methods inherited from class polyglot.visit.ContextVisitor
addDecls, begin, context, context, enter, enterScope, leave, superEnter
 
Methods inherited from class polyglot.visit.ErrorHandlingVisitor
catchErrors, enterCall, enterError, errorQueue, job, 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
 

Constructor Detail

CovarRetRewriter

public CovarRetRewriter(Job job,
                        TypeSystem ts,
                        NodeFactory nf)
Method Detail

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 visited
toType - 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