polyglot.ast
Interface Node

All Superinterfaces:
java.lang.Cloneable, Copy, JL, NodeOps
All Known Subinterfaces:
AmbAssign, AmbExpr, Ambiguous, AmbInstOrAccess, AmbKeySetNode, AmbNameParam, AmbNewArray, AmbPrefix, AmbQualifierNode, AmbReceiver, AmbTypeNode, ArrayAccess, ArrayAccessAssign, ArrayInit, ArrayTypeNode, Assert, Assign, Binary, Block, BooleanLit, Branch, Call, CanonicalKeySetNode, CanonicalTypeNode, Case, Cast, Catch, CharLit, ClassBody, ClassConstraint, ClassDecl, ClassLit, ClassMember, CodeDecl, CofferClassDecl, CofferConstructorDecl, CofferMethodDecl, CompoundStmt, Conditional, ConstArrayTypeNode, ConstructorCall, ConstructorConstraint, ConstructorDecl, Do, Empty, Eval, Expr, ExprParam, Field, FieldAssign, FieldDecl, FloatLit, For, ForInit, Formal, ForUpdate, Free, If, Import, Initializer, Instanceof, InstTypeNode, IntLit, KeyNode, KeySetNode, Labeled, Lit, Local, LocalAssign, LocalClassDecl, LocalDecl, Loop, MethodConstraint, MethodDecl, New, NewArray, NullLit, NumLit, PackageNode, ParamNode, PolyJArrayAccess, PolyJAssign, PolyJBinary, PolyJCall, PolyJCanonicalTypeNode, PolyJCast, PolyJClassBody, PolyJClassDecl, PolyJConstructorCall, PolyJConstructorDecl, PolyJField, PolyJFieldDecl, PolyJInitializer, PolyJInstanceof, PolyJLocalDecl, PolyJMethodDecl, PolyJNew, PolyJNewArray, PragmaNode, Prefix, ProcedureCall, ProcedureConstraint, ProcedureDecl, QualifierNode, Receiver, Return, SourceCollection, SourceFile, Special, Stmt, StringLit, Switch, SwitchBlock, SwitchElement, Synchronized, Term, Throw, ThrowConstraintNode, TopLevelDecl, TrackedTypeNode, Try, TypeNode, TypeParam, Unary, VarDecl, Variable, While
All Known Implementing Classes:
AbstractBlock_c, AmbAssign_c, AmbExpr_c, AmbInstOrAccess_c, AmbKeySetNode_c, AmbNameParam_c, AmbNewArray_c, AmbPrefix_c, AmbQualifierNode_c, AmbReceiver_c, AmbTypeNode_c, ArrayAccess_c, ArrayAccessAssign_c, ArrayInit_c, ArrayTypeNode_c, Assert_c, Assign_c, Binary_c, Block_c, BooleanLit_c, Branch_c, Call_c, CanonicalKeySetNode_c, CanonicalTypeNode_c, Case_c, Cast_c, Catch_c, CharLit_c, ClassBody_c, ClassConstraint_c, ClassDecl_c, ClassLit_c, CofferClassDecl_c, CofferConstructorDecl_c, CofferMethodDecl_c, Conditional_c, ConstArrayTypeNode_c, ConstructorCall_c, ConstructorConstraint_c, ConstructorDecl_c, Do_c, Empty_c, Eval_c, Expr_c, ExprParam_c, Field_c, FieldAssign_c, FieldDecl_c, FloatLit_c, For_c, Formal_c, Free_c, If_c, Import_c, Initializer_c, Instanceof_c, InstTypeNode_c, IntLit_c, KeyNode_c, Labeled_c, Lit_c, Local_c, LocalAssign_c, LocalClassDecl_c, LocalDecl_c, Loop_c, MethodConstraint_c, MethodDecl_c, New_c, NewArray_c, Node_c, NullLit_c, NumLit_c, PackageNode_c, PolyJArrayAccess_c, PolyJArrayAccessAssign_c, PolyJBinary_c, PolyJCall_c, PolyJCanonicalTypeNode_c, PolyJCast_c, PolyJClassBody_c, PolyJClassDecl_c, PolyJConstructorCall_c, PolyJConstructorDecl_c, PolyJField_c, PolyJFieldAssign_c, PolyJFieldDecl_c, PolyJInitializer_c, PolyJInstanceof_c, PolyJLocalAssign_c, PolyJLocalDecl_c, PolyJMethodDecl_c, PolyJNew_c, PolyJNewArray_c, PragmaNode_c, ProcedureConstraint_c, Return_c, SourceCollection_c, SourceFile_c, Special_c, Stmt_c, StringLit_c, Switch_c, SwitchBlock_c, Synchronized_c, Term_c, Throw_c, ThrowConstraintNode_c, TrackedTypeNode_c, Try_c, TypeNode_c, TypeParam_c, Unary_c, While_c

public interface Node
extends JL, Copy

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
 Type childExpectedType(Expr child, AscriptionVisitor av)
          Get the expected type of a child expression of this.
 JL del()
          Get the node's delegate.
 Node del(JL del)
          Set the delegate of the node.
 void dump(CodeWriter w)
          Dump the AST node for debugging purposes.
 Ext ext()
          Get the node's extension.
 Node ext(Ext ext)
          Set the extension of the node.
 Ext ext(int n)
          Get the node's nth extension, n >= 1.
 Node ext(int n, Ext ext)
          Set the node's nth extension, n >= 1.
 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 visit(NodeVisitor v)
          Visit the node.
 Node visitChild(Node child, NodeVisitor v)
          Visit a single child of the node.
 Node visitEdge(Node parent, NodeVisitor v)
          Visit the node, passing in the node's parent.
 
Methods inherited from interface polyglot.ast.JL
init, node
 
Methods inherited from interface polyglot.ast.NodeOps
addDecls, addMembers, addMembersEnter, buildTypes, buildTypesEnter, disambiguate, disambiguateEnter, enterScope, enterScope, exceptionCheck, exceptionCheckEnter, prettyPrint, throwTypes, translate, typeCheck, typeCheckEnter, visitChildren
 
Methods inherited from interface polyglot.util.Copy
copy
 

Method Detail

del

public Node del(JL del)
Set the delegate of the node.


del

public JL del()
Get the node's delegate.


ext

public Node ext(Ext ext)
Set the extension of the node.


ext

public Ext ext()
Get the node's extension.


ext

public Node ext(int n,
                Ext ext)
Set the node's nth extension, n >= 1.


ext

public Ext ext(int n)
Get the node's nth extension, n >= 1.


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.


visit

public Node visit(NodeVisitor v)
Visit the node. This method is equivalent to visitEdge(null, v).

Parameters:
v - The visitor which will traverse/rewrite the AST.
Returns:
A new AST if a change was made, or this.

visitEdge

public Node visitEdge(Node parent,
                      NodeVisitor v)
Visit the node, passing in the node's parent. 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:
parent - The parent of this in the AST.
v - The visitor which will traverse/rewrite the AST.
Returns:
A new AST if a change was made, or this.

visitChild

public Node visitChild(Node child,
                       NodeVisitor v)
Visit a single child of the node.

Parameters:
v - The visitor which will traverse/rewrite the AST.
child - The child to visit.
Returns:
The result of child.visit(v), or null if child was null.

childExpectedType

public Type childExpectedType(Expr child,
                              AscriptionVisitor av)
Get the expected type of a child expression of this. The expected type is determined by the context in that the child occurs (e.g., for x = e, the expected type of e is the declared type of x. The expected type should impose the least constraints on the child's type that are allowed by the parent node.

Parameters:
child - A child expression of this node.
av - An ascription visitor.
Returns:
The expected type of child.

dump

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