polyglot.ext.jl.ast
Class JL_c

java.lang.Object
  extended by polyglot.ext.jl.ast.Ext_c
      extended by polyglot.ext.jl.ast.JL_c
All Implemented Interfaces:
java.lang.Cloneable, Ext, JL, NodeOps, Copy
Direct Known Subclasses:
AssignDel_c, PaoInstanceofDel_c

public class JL_c
extends Ext_c
implements JL

JL_c is the super class of JL node delegates objects. It defines default implementations of the methods which implement compiler passes, dispatching to the node to perform the actual work of the pass. Language extensions may subclass JL_c for individual node classes or may reimplement all compiler passes in a new class implementing the JL interface.


Field Summary
 
Fields inherited from class polyglot.ext.jl.ast.Ext_c
ext, node
 
Constructor Summary
JL_c()
           
 
Method Summary
 void addDecls(Context c)
          Add any declarations to the context that should be in scope when visiting later sibling nodes.
 Node addMembers(AddMemberVisitor am)
          Adds disambiguated methods and fields to the types.
 NodeVisitor addMembersEnter(AddMemberVisitor am)
          Adds disambiguated methods and fields to the types.
 Node buildTypes(TypeBuilder tb)
          Collects classes, methods, and fields from the AST rooted at this node and constructs type objects for these.
 NodeVisitor buildTypesEnter(TypeBuilder tb)
          Collects classes, methods, and fields from the AST rooted at this node and constructs type objects for these.
 Node disambiguate(AmbiguityRemover ar)
          Remove any remaining ambiguities from the AST.
 NodeVisitor disambiguateEnter(AmbiguityRemover ar)
          Remove any remaining ambiguities from the AST.
 Context enterScope(Context c)
          Push a new scope upon entering this node, and add any declarations to the context that should be in scope when visiting children of this node.
 Context enterScope(Node child, Context c)
          Push a new scope for visiting the child node child.
 Node exceptionCheck(ExceptionChecker ec)
          Check that exceptions are properly propagated throughout the AST.
 NodeVisitor exceptionCheckEnter(ExceptionChecker ec)
          Check that exceptions are properly propagated throughout the AST.
 JL jl()
          The JL object we dispatch to, by default, the node itself, but possibly another delegate.
 void prettyPrint(CodeWriter w, PrettyPrinter pp)
          Pretty-print the AST using the given code writer.
 java.util.List throwTypes(TypeSystem ts)
          List of Types of exceptions that might get thrown.
 void translate(CodeWriter w, Translator tr)
          Translate the AST using the given code writer.
 Node typeCheck(TypeChecker tc)
          Type check the AST.
 NodeVisitor typeCheckEnter(TypeChecker tc)
          Type check the AST.
 Node visitChildren(NodeVisitor v)
          Visit the children of the node.
 
Methods inherited from class polyglot.ext.jl.ast.Ext_c
copy, dump, ext, ext, init, node, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface polyglot.ast.JL
init, node
 
Methods inherited from interface polyglot.util.Copy
copy
 

Constructor Detail

JL_c

public JL_c()
Method Detail

jl

public JL jl()
The JL object we dispatch to, by default, the node itself, but possibly another delegate.


visitChildren

public Node visitChildren(NodeVisitor v)
Visit the children of the node.

Specified by:
visitChildren in interface NodeOps
Parameters:
v - The visitor that will traverse/rewrite the AST.
Returns:
A new AST if a change was made, or this.

enterScope

public Context enterScope(Context c)
Push a new scope upon entering this node, and add any declarations to the context that should be in scope when visiting children of this node. This should not update the old context imperatively. Use addDecls when leaving the node for that.

Specified by:
enterScope in interface NodeOps
Parameters:
c - the current Context
Returns:
the Context to be used for visiting this node.

enterScope

public Context enterScope(Node child,
                          Context c)
Push a new scope for visiting the child node child. The default behavior is to delegate the call to the child node, and let it add appropriate declarations that should be in scope. However, this method gives parent nodes have the ability to modify this behavior.

Specified by:
enterScope in interface NodeOps
Parameters:
child - the child node about to be entered.
c - the current Context
Returns:
the Context to be used for visiting node child

addDecls

public void addDecls(Context c)
Add any declarations to the context that should be in scope when visiting later sibling nodes.

Specified by:
addDecls in interface NodeOps
Parameters:
c - The context to which to add declarations.

buildTypesEnter

public NodeVisitor buildTypesEnter(TypeBuilder tb)
                            throws SemanticException
Collects classes, methods, and fields from the AST rooted at this node and constructs type objects for these. These type objects may be ambiguous. Inserts classes into the TypeSystem. This method is called by the enter() method of the visitor. The * method should perform work that should be done before visiting the children of the node. The method may return this or a new copy of the node on which visitChildren() and leave() will be invoked.

Specified by:
buildTypesEnter in interface NodeOps
Parameters:
tb - The visitor which adds new type objects to the TypeSystem.
Throws:
SemanticException

buildTypes

public Node buildTypes(TypeBuilder tb)
                throws SemanticException
Collects classes, methods, and fields from the AST rooted at this node and constructs type objects for these. These type objects may be ambiguous. Inserts classes into the TypeSystem. This method is called by the leave() method of the visitor. The method should perform work that should be done after visiting the children of the node. The method may return this or a new copy of the node which will be installed as a child of the node's parent.

Specified by:
buildTypes in interface NodeOps
Parameters:
tb - The visitor which adds new type objects to the TypeSystem.
Throws:
SemanticException

disambiguateEnter

public NodeVisitor disambiguateEnter(AmbiguityRemover ar)
                              throws SemanticException
Remove any remaining ambiguities from the AST. This method is called by the enter() method of the visitor. The * method should perform work that should be done before visiting the children of the node. The method may return this or a new copy of the node on which visitChildren() and leave() will be invoked.

Specified by:
disambiguateEnter in interface NodeOps
Parameters:
ar - The visitor which disambiguates.
Throws:
SemanticException

disambiguate

public Node disambiguate(AmbiguityRemover ar)
                  throws SemanticException
Remove any remaining ambiguities from the AST. This method is called by the leave() method of the visitor. The method should perform work that should be done after visiting the children of the node. The method may return this or a new copy of the node which will be installed as a child of the node's parent.

Specified by:
disambiguate in interface NodeOps
Parameters:
ar - The visitor which disambiguates.
Throws:
SemanticException

addMembersEnter

public NodeVisitor addMembersEnter(AddMemberVisitor am)
                            throws SemanticException
Adds disambiguated methods and fields to the types. This method is called by the enter() method of the visitor. The * method should perform work that should be done before visiting the children of the node. The method may return this or a new copy of the node on which visitChildren() and leave() will be invoked.

Specified by:
addMembersEnter in interface NodeOps
Parameters:
am - The visitor which builds types.
Throws:
SemanticException

addMembers

public Node addMembers(AddMemberVisitor am)
                throws SemanticException
Adds disambiguated methods and fields to the types. This method is called by the leave() method of the visitor. The method should perform work that should be done after visiting the children of the node. The method may return this or a new copy of the node which will be installed as a child of the node's parent.

Specified by:
addMembers in interface NodeOps
Parameters:
am - The visitor which builds types.
Throws:
SemanticException

typeCheckEnter

public NodeVisitor typeCheckEnter(TypeChecker tc)
                           throws SemanticException
Type check the AST. This method is called by the enter() method of the visitor. The * method should perform work that should be done before visiting the children of the node. The method may return this or a new copy of the node on which visitChildren() and leave() will be invoked.

Specified by:
typeCheckEnter in interface NodeOps
Parameters:
tc - The type checking visitor.
Throws:
SemanticException

typeCheck

public Node typeCheck(TypeChecker tc)
               throws SemanticException
Type check the AST. This method is called by the leave() method of the visitor. The method should perform work that should be done after visiting the children of the node. The method may return this or a new copy of the node which will be installed as a child of the node's parent.

Specified by:
typeCheck in interface NodeOps
Parameters:
tc - The type checking visitor.
Throws:
SemanticException

exceptionCheckEnter

public NodeVisitor exceptionCheckEnter(ExceptionChecker ec)
                                throws SemanticException
Check that exceptions are properly propagated throughout the AST. This method is called by the enter() method of the visitor. The * method should perform work that should be done before visiting the children of the node. The method may return this or a new copy of the node on which visitChildren() and leave() will be invoked.

Specified by:
exceptionCheckEnter in interface NodeOps
Parameters:
ec - The visitor.
Throws:
SemanticException

exceptionCheck

public Node exceptionCheck(ExceptionChecker ec)
                    throws SemanticException
Check that exceptions are properly propagated throughout the AST. This method is called by the leave() method of the visitor. The method should perform work that should be done after visiting the children of the node. The method may return this or a new copy of the node which will be installed as a child of the node's parent.

Specified by:
exceptionCheck in interface NodeOps
Parameters:
ec - The visitor.
Throws:
SemanticException

throwTypes

public java.util.List throwTypes(TypeSystem ts)
List of Types of exceptions that might get thrown. The result is not necessarily correct until after type checking.

Specified by:
throwTypes in interface NodeOps

prettyPrint

public void prettyPrint(CodeWriter w,
                        PrettyPrinter pp)
Pretty-print the AST using the given code writer.

Specified by:
prettyPrint in interface NodeOps
Parameters:
w - The code writer to which to write.
pp - The pretty printer. This is not a visitor.

translate

public void translate(CodeWriter w,
                      Translator tr)
Translate the AST using the given code writer.

Specified by:
translate in interface NodeOps
Parameters:
w - The code writer to which to write.
tr - The translation pass. This is not a visitor.