jltools.ext.jl.ast
Class Node_c

java.lang.Object
  |
  +--jltools.ext.jl.ast.Node_c
All Implemented Interfaces:
java.lang.Cloneable, Copy, Node, java.io.Serializable
Direct Known Subclasses:
AmbParam_c, AmbParamTypeOrAccess_c, AmbPrefix_c, AmbQualifierNode_c, ClassBody_c, ClassDecl_c, ConstraintNode_c, ConstructorDecl_c, Expr_c, FieldDecl_c, Formal_c, Import_c, Initializer_c, LabelNode_c, MethodDecl_c, PackageNode_c, ParamDecl_c, PrincipalNode_c, SourceFile_c, Stmt_c, TypeNode_c

public abstract class Node_c
extends java.lang.Object
implements Node

A Node represents an AST node. All AST nodes must implement this interface. Nodes should be immutable: methods which set fields of the node should copy the node, set the field in the copy, and then return the copy.

See Also:
Serialized Form

Inner Class Summary
 class Node_c.StringCodeWriter
           
 
Field Summary
protected  Ext ext
           
protected  Position position
           
 
Constructor Summary
Node_c(Ext ext, Position pos)
           
 
Method Summary
 Node buildTypes_(TypeBuilder tb)
           
 void buildTypes(TypeBuilder tb)
           
 Node buildTypesOverride_(TypeBuilder tb)
          Collects classes, methods, and fields from the AST rooted at this node and constructs type objects for these.
 void buildTypesOverride(TypeBuilder tb)
           
 java.lang.Object copy()
          Clone the node.
 Node disambiguate_(AmbiguityRemover ar)
           
 void disambiguate(AmbiguityRemover ar)
           
 Node disambiguateOverride_(AmbiguityRemover ar)
          Remove any remaining ambiguities from the AST.
 void disambiguateOverride(AmbiguityRemover ar)
           
 Node disambiguateTypes_(TypeAmbiguityRemover sc)
           
 void disambiguateTypes(TypeAmbiguityRemover sc)
           
 Node disambiguateTypesOverride_(TypeAmbiguityRemover sc)
          Clean type signatures.
 void disambiguateTypesOverride(TypeAmbiguityRemover sc)
           
 void dump(CodeWriter w)
          Dump the AST node for debugging purposes.
 void enterScope(Context c)
          Adjust the environment for entering a new scope.
 Node exceptionCheck_(ExceptionChecker ec)
           
 void exceptionCheck(ExceptionChecker ec)
           
 Node exceptionCheckOverride_(ExceptionChecker ec)
          Check that exceptions are properly propagated throughout the AST.
 void exceptionCheckOverride(ExceptionChecker ec)
           
 Ext ext()
          Return the delegate for this node.
 Node ext(Ext ext)
          Create a copy of the node with a new delegate.
 Node foldConstants_(ConstantFolder cf)
           
 void foldConstants(ConstantFolder cf)
           
 Node foldConstantsOverride_(ConstantFolder cf)
          Fold all constants.
 void foldConstantsOverride(ConstantFolder cf)
           
 void leaveScope(Context c)
          Adjust the environment for leaving the current scope.
 Position position()
          Get the position of the node in the source file.
 Node position(Position position)
          Create a copy of the node with a new position.
 Node reconstructTypes_(NodeFactory nf, TypeSystem ts, Context c)
          This method can be called after a node is visited to ensure its type information is reconstructed.
 void reconstructTypes(NodeFactory nf, TypeSystem ts, Context c)
           
 java.lang.String toString()
           
 void translate_(CodeWriter w, Translator tr)
          Translate the AST using the given CodeWriter.
 void translate(CodeWriter w, Translator tr)
           
 void translateBlock(Node n, CodeWriter w, Translator tr)
           
 void translateSubstmt(Stmt stmt, CodeWriter w, Translator tr)
           
 Node typeCheck_(TypeChecker tc)
           
 void typeCheck(TypeChecker tc)
           
 Node typeCheckOverride_(TypeChecker tc)
          Type check the AST.
 void typeCheckOverride(TypeChecker tc)
           
 Node visit(NodeVisitor v)
          Visit the node.
 Node visitChildren(NodeVisitor v)
          Visit the children of the node.
static java.util.List visitList(java.util.List l, NodeVisitor v)
          Visit all the elements of a list.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ext

protected Ext ext

position

protected Position position
Constructor Detail

Node_c

public Node_c(Ext ext,
              Position pos)
Method Detail

copy

public java.lang.Object copy()
Description copied from interface: Node
Clone the node.
Specified by:
copy in interface Node

ext

public Ext ext()
Description copied from interface: Node
Return the delegate for this node. Some operations on the node should be invoked only through the delegate, for instance as:
    n.delegate().typeCheck(c)
 
rather than:
    n.typeCheck_(c)
 
Specified by:
ext in interface Node

ext

public Node ext(Ext ext)
Description copied from interface: Node
Create a copy of the node with a new delegate.
Specified by:
ext in interface Node

position

public Position position()
Description copied from interface: Node
Get the position of the node in the source file. Returns null if the position is not set.
Specified by:
position in interface Node

position

public Node position(Position position)
Description copied from interface: Node
Create a copy of the node with a new position.
Specified by:
position in interface Node

visit

public Node visit(NodeVisitor v)
Description copied from interface: Node
Visit the node. This method is called by a NodeVisitor to traverse the AST starting at this node. This method should call the override, enter, and leave methods of the visitor. The method may return a new version of the node.
Specified by:
visit in interface Node
Following copied from interface: jltools.ast.Node
Parameters:
v - The visitor which will traverse/rewrite the AST.
Returns:
A new AST if a change was made, or this.

visitList

public static java.util.List visitList(java.util.List l,
                                       NodeVisitor v)
Visit all the elements of a list.
Parameters:
l - The list to visit.
v - The visitor to use.
Returns:
A new list with each element from the old list replaced by the result of visiting that element. If l is a TypedList, the new list will also be typed with the same type as l. If l is null, null is returned.

visitChildren

public Node visitChildren(NodeVisitor v)
Description copied from interface: Node
Visit the children of the node.
Specified by:
visitChildren in interface Node

enterScope

public void enterScope(Context c)
Adjust the environment for entering a new scope.
Specified by:
enterScope in interface Node

leaveScope

public void leaveScope(Context c)
Adjust the environment for leaving the current scope.
Specified by:
leaveScope in interface Node

reconstructTypes_

public Node reconstructTypes_(NodeFactory nf,
                              TypeSystem ts,
                              Context c)
                       throws SemanticException
This method can be called after a node is visited to ensure its type information is reconstructed.
Specified by:
reconstructTypes_ in interface Node

buildTypesOverride_

public Node buildTypesOverride_(TypeBuilder tb)
                         throws SemanticException
Description copied from interface: Node
Collects classes, methods, and fields from the AST rooted at this node and constructs type objects for these. These type objects may be ambiguous.
Specified by:
buildTypesOverride_ in interface Node
Following copied from interface: jltools.ast.Node
Parameters:
cb - The visitor which adds new type objects to the TypeSystem.

buildTypes_

public Node buildTypes_(TypeBuilder tb)
                 throws SemanticException
Specified by:
buildTypes_ in interface Node

disambiguateTypesOverride_

public Node disambiguateTypesOverride_(TypeAmbiguityRemover sc)
                                throws SemanticException
Clean type signatures.
Specified by:
disambiguateTypesOverride_ in interface Node
Following copied from interface: jltools.ast.Node
Parameters:
cb - The visitor which builds contexts.

disambiguateTypes_

public Node disambiguateTypes_(TypeAmbiguityRemover sc)
                        throws SemanticException
Specified by:
disambiguateTypes_ in interface Node

disambiguateOverride_

public Node disambiguateOverride_(AmbiguityRemover ar)
                           throws SemanticException
Remove any remaining ambiguities from the AST.
Specified by:
disambiguateOverride_ in interface Node
Following copied from interface: jltools.ast.Node
Parameters:
ar - The visitor which disambiguates.

disambiguate_

public Node disambiguate_(AmbiguityRemover ar)
                   throws SemanticException
Specified by:
disambiguate_ in interface Node

foldConstantsOverride_

public Node foldConstantsOverride_(ConstantFolder cf)
Fold all constants.
Specified by:
foldConstantsOverride_ in interface Node
Following copied from interface: jltools.ast.Node
Parameters:
cf - The constant folding visitor.

foldConstants_

public Node foldConstants_(ConstantFolder cf)
Specified by:
foldConstants_ in interface Node

typeCheckOverride_

public Node typeCheckOverride_(TypeChecker tc)
                        throws SemanticException
Type check the AST.
Specified by:
typeCheckOverride_ in interface Node
Following copied from interface: jltools.ast.Node
Parameters:
tc - The type checking visitor.

typeCheck_

public Node typeCheck_(TypeChecker tc)
                throws SemanticException
Specified by:
typeCheck_ in interface Node

exceptionCheckOverride_

public Node exceptionCheckOverride_(ExceptionChecker ec)
                             throws SemanticException
Check that exceptions are properly propagated throughout the AST.
Specified by:
exceptionCheckOverride_ in interface Node
Following copied from interface: jltools.ast.Node
Parameters:
ec - The visitor.

exceptionCheck_

public Node exceptionCheck_(ExceptionChecker ec)
                     throws SemanticException
Specified by:
exceptionCheck_ in interface Node

translate_

public void translate_(CodeWriter w,
                       Translator tr)
Translate the AST using the given CodeWriter.
Specified by:
translate_ in interface Node
Following copied from interface: jltools.ast.Node
Parameters:
w - The code writer to which to write.
tr - The translation pass. This is not a visitor.

translateBlock

public void translateBlock(Node n,
                           CodeWriter w,
                           Translator tr)

translateSubstmt

public void translateSubstmt(Stmt stmt,
                             CodeWriter w,
                             Translator tr)

dump

public void dump(CodeWriter w)
Description copied from interface: Node
Dump the AST node for debugging purposes.
Specified by:
dump in interface Node

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

buildTypesOverride

public final void buildTypesOverride(TypeBuilder tb)

buildTypes

public final void buildTypes(TypeBuilder tb)

disambiguateTypesOverride

public final void disambiguateTypesOverride(TypeAmbiguityRemover sc)

disambiguateTypes

public final void disambiguateTypes(TypeAmbiguityRemover sc)

disambiguateOverride

public final void disambiguateOverride(AmbiguityRemover ar)

disambiguate

public final void disambiguate(AmbiguityRemover ar)

foldConstantsOverride

public final void foldConstantsOverride(ConstantFolder cf)

foldConstants

public final void foldConstants(ConstantFolder cf)

typeCheckOverride

public final void typeCheckOverride(TypeChecker tc)

typeCheck

public final void typeCheck(TypeChecker tc)

exceptionCheckOverride

public final void exceptionCheckOverride(ExceptionChecker ec)

exceptionCheck

public final void exceptionCheck(ExceptionChecker ec)

translate

public final void translate(CodeWriter w,
                            Translator tr)

reconstructTypes

public final void reconstructTypes(NodeFactory nf,
                                   TypeSystem ts,
                                   Context c)