polyglot.ast
Interface Node

All Superinterfaces:
java.lang.Cloneable, Copy, JL, NodeOps
All Known Subinterfaces:
AmbAssign, AmbExpr, Ambiguous, AmbKeySetNode, AmbPrefix, AmbQualifierNode, AmbReceiver, AmbTypeNode, ArrayAccess, ArrayAccessAssign, ArrayInit, ArrayTypeNode, Assert, Assign, Binary, Block, BooleanLit, Branch, Call, CanonicalKeySetNode, CanonicalTypeNode, Case, Cast, Catch, CharLit, ClassBody, ClassDecl, ClassLit, ClassMember, CodeDecl, CofferClassDecl, CofferConstructorDecl, CofferMethodDecl, CompoundStmt, Conditional, ConstructorCall, ConstructorDecl, Do, Empty, Eval, Expr, Field, FieldAssign, FieldDecl, FloatLit, For, ForInit, Formal, ForUpdate, Free, If, Import, Initializer, Instanceof, IntLit, KeyNode, KeySetNode, Labeled, Lit, Local, LocalAssign, LocalClassDecl, LocalDecl, Loop, MethodDecl, New, NewArray, NullLit, NumLit, PackageNode, Prefix, ProcedureCall, ProcedureDecl, QualifierNode, Receiver, Return, SourceCollection, SourceFile, Special, Stmt, StringLit, Switch, SwitchBlock, SwitchElement, Synchronized, Term, Throw, ThrowConstraintNode, TopLevelDecl, TrackedTypeNode, Try, TypeNode, Unary, VarDecl, Variable, While
All Known Implementing Classes:
AbstractBlock_c, AmbAssign_c, AmbExpr_c, AmbKeySetNode_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, ClassDecl_c, ClassLit_c, CofferClassDecl_c, CofferConstructorDecl_c, CofferMethodDecl_c, Conditional_c, ConstructorCall_c, ConstructorDecl_c, Do_c, Empty_c, Eval_c, Expr_c, Field_c, FieldAssign_c, FieldDecl_c, FloatLit_c, For_c, Formal_c, Free_c, If_c, Import_c, Initializer_c, Instanceof_c, IntLit_c, KeyNode_c, Labeled_c, Lit_c, Local_c, LocalAssign_c, LocalClassDecl_c, LocalDecl_c, Loop_c, MethodDecl_c, New_c, NewArray_c, Node_c, NullLit_c, NumLit_c, PackageNode_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, 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.
 java.util.List visitList(java.util.List l, NodeVisitor v)
          Visit all the elements of a list.
 
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

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


del

JL del()
Get the node's delegate.


ext

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


ext

Ext ext()
Get the node's extension.


ext

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


ext

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


position

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


position

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


visit

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

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

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.

visitList

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.

childExpectedType

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

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