jltools.ast
Interface Node

All Superinterfaces:
java.lang.Cloneable, Copy, java.io.Serializable
All Known Subinterfaces:
ActsFor, ActsForConstraintNode, AmbDynamicLabelNode, AmbExpr, Ambiguous, AmbNewArray, AmbParam, AmbParamTypeOrAccess, AmbPrefix, AmbPrincipalNode, AmbQualifierNode, AmbReceiver, AmbThisLabelNode, AmbTypeNode, AmbVarLabelNode, ArrayAccess, ArrayInit, ArrayTypeNode, Assign, AuthConstraintNode, Binary, Block, BooleanLit, Branch, Call, CallerConstraintNode, CanonicalConstraintNode, CanonicalLabelNode, CanonicalPrincipalNode, CanonicalTypeNode, Case, Cast, Catch, CharLit, ClassBody, ClassDecl, ClassMember, Conditional, ConstraintNode, ConstructorCall, ConstructorDecl, DeclassifyExpr, DeclassifyStmt, Do, Empty, Eval, Expr, Field, FieldDecl, FloatLit, For, ForInit, Formal, ForUpdate, If, Import, Initializer, Instanceof, InstTypeNode, IntLit, JifClassDecl, JifConstructorDecl, JifMethodDecl, JoinLabelNode, LabelCase, Labeled, LabeledTypeNode, LabelNode, Lit, Local, LocalClassDecl, LocalDecl, MethodDecl, New, NewArray, NewLabel, NullLit, NumLit, PackageNode, ParamDecl, ParamNode, PolicyLabelNode, Prefix, PrincipalNode, ProcedureDecl, QualifiedNew, QualifierNode, Receiver, Return, SourceFile, Special, Stmt, StringLit, Switch, SwitchBlock, SwitchElement, SwitchLabel, Synchronized, Throw, TopLevelDecl, Try, TypeNode, Unary, While
All Known Implementing Classes:
Node_c

public interface Node
extends Copy, java.io.Serializable

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.


Method Summary
 Node 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.
 java.lang.Object copy()
          Clone the node.
 Node disambiguate_(AmbiguityRemover ar)
           
 Node disambiguateOverride_(AmbiguityRemover ar)
          Remove any remaining ambiguities from the AST.
 Node disambiguateTypes_(TypeAmbiguityRemover sc)
           
 Node disambiguateTypesOverride_(TypeAmbiguityRemover sc)
          Constructs a context for each type declared in the AST.
 void dump(CodeWriter w)
          Dump the AST node for debugging purposes.
 void enterScope(Context c)
          Adjust the environment on entering the scope of the method.
 Node exceptionCheck_(ExceptionChecker ec)
           
 Node exceptionCheckOverride_(ExceptionChecker ec)
          Check that exceptions are properly propagated throughout the AST.
 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)
           
 Node foldConstantsOverride_(ConstantFolder cf)
          Fold constants in the AST.
 void leaveScope(Context c)
          Adjust the environment on leaving the scope of the method.
 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 translate_(CodeWriter w, Translator tr)
          Translate the AST using the given code writer.
 Node typeCheck_(TypeChecker tc)
           
 Node typeCheckOverride_(TypeChecker tc)
          Type check the AST.
 Node visit(NodeVisitor v)
          Visit the node.
 Node visitChildren(NodeVisitor v)
          Visit the children of the node.
 

Method Detail

ext

public Ext ext()
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)
 

ext

public Node ext(Ext ext)
Create a copy of the node with a new delegate.

position

public Position position()
Get the position of the node in the source file. Returns null if the position is not set.

position

public Node position(Position position)
Create a copy of the node with a new position.

copy

public java.lang.Object copy()
Clone the node.
Specified by:
copy in interface Copy

visit

public Node visit(NodeVisitor v)
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.
Parameters:
v - The visitor which will traverse/rewrite the AST.
Returns:
A new AST if a change was made, or this.

visitChildren

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

enterScope

public void enterScope(Context c)
Adjust the environment on entering the scope of the method.

leaveScope

public void leaveScope(Context c)
Adjust the environment on leaving the scope of the method.

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.

buildTypesOverride_

public Node buildTypesOverride_(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.
Parameters:
cb - The visitor which adds new type objects to the TypeSystem.

buildTypes_

public Node buildTypes_(TypeBuilder tb)
                 throws SemanticException

disambiguateTypesOverride_

public Node disambiguateTypesOverride_(TypeAmbiguityRemover sc)
                                throws SemanticException
Constructs a context for each type declared in the AST. A context is used to look up names when cleaning class signatures.
Parameters:
cb - The visitor which builds contexts.

disambiguateTypes_

public Node disambiguateTypes_(TypeAmbiguityRemover sc)
                        throws SemanticException

disambiguateOverride_

public Node disambiguateOverride_(AmbiguityRemover ar)
                           throws SemanticException
Remove any remaining ambiguities from the AST.
Parameters:
ar - The visitor which disambiguates.

disambiguate_

public Node disambiguate_(AmbiguityRemover ar)
                   throws SemanticException

foldConstantsOverride_

public Node foldConstantsOverride_(ConstantFolder cf)
Fold constants in the AST.
Parameters:
cf - The constant folding visitor.

foldConstants_

public Node foldConstants_(ConstantFolder cf)

typeCheckOverride_

public Node typeCheckOverride_(TypeChecker tc)
                        throws SemanticException
Type check the AST.
Parameters:
tc - The type checking visitor.

typeCheck_

public Node typeCheck_(TypeChecker tc)
                throws SemanticException

exceptionCheckOverride_

public Node exceptionCheckOverride_(ExceptionChecker ec)
                             throws SemanticException
Check that exceptions are properly propagated throughout the AST.
Parameters:
ec - The visitor.

exceptionCheck_

public Node exceptionCheck_(ExceptionChecker ec)
                     throws SemanticException

translate_

public void translate_(CodeWriter w,
                       Translator tr)
Translate the AST using the given code writer.
Parameters:
w - The code writer to which to write.
tr - The translation pass. This is not a visitor.

dump

public void dump(CodeWriter w)
Dump the AST node for debugging purposes.