polyglot.ext.jl.ast
Class FieldDecl_c

java.lang.Object
  extended by polyglot.ext.jl.ast.Node_c
      extended by polyglot.ext.jl.ast.Term_c
          extended by polyglot.ext.jl.ast.FieldDecl_c
All Implemented Interfaces:
java.lang.Cloneable, ClassMember, FieldDecl, JL, Node, NodeOps, Term, Copy

public class FieldDecl_c
extends Term_c
implements FieldDecl

A FieldDecl is an immutable representation of the declaration of a field of a class.


Field Summary
protected  FieldInstance fi
           
protected  Flags flags
           
protected  InitializerInstance ii
           
protected  Expr init
           
protected  java.lang.String name
           
protected  TypeNode type
           
 
Fields inherited from class polyglot.ext.jl.ast.Term_c
exceptions, reachable
 
Fields inherited from class polyglot.ext.jl.ast.Node_c
del, ext, position
 
Constructor Summary
FieldDecl_c(Position pos, Flags flags, TypeNode type, java.lang.String name, Expr init)
           
 
Method Summary
 java.util.List acceptCFG(CFGBuilder v, java.util.List succs)
          Visit this term in evaluation order.
 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.
protected  void checkFieldInstanceConstant()
           
 Type childExpectedType(Expr child, AscriptionVisitor av)
          Get the expected type of a child expression of this.
 Type declType()
          Get the type of the declaration.
 Node disambiguate(AmbiguityRemover ar)
          Remove any remaining ambiguities from the AST.
 NodeVisitor disambiguateEnter(AmbiguityRemover ar)
          Build type objects for the declaration.
 void dump(CodeWriter w)
          Dump the AST node for debugging purposes.
 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.
 Term entry()
          Return the first (sub)term performed when evaluating this term.
 Node exceptionCheck(ExceptionChecker ec)
          Check that exceptions are properly propagated throughout the AST.
 FieldInstance fieldInstance()
          Get the field instance of the declaration.
 FieldDecl fieldInstance(FieldInstance fi)
          Set the field instance of the declaration.
 Flags flags()
          Get the flags of the declaration.
 FieldDecl flags(Flags flags)
          Set the flags of the declaration.
 Expr init()
          Get the initializer of the declaration.
 FieldDecl init(Expr init)
          Set the initializer of the declaration.
 InitializerInstance initializerInstance()
          Get the initializer instance of the initializer.
 FieldDecl initializerInstance(InitializerInstance ii)
          Set the initializer instance of the initializer.
 java.lang.String name()
          Get the name of the declaration.
 FieldDecl name(java.lang.String name)
          Set the name of the declaration.
 void prettyPrint(CodeWriter w, PrettyPrinter tr)
          Pretty-print the AST using the given CodeWriter.
protected  FieldDecl_c reconstruct(TypeNode type, Expr init)
          Reconstruct the declaration.
 java.lang.String toString()
           
 TypeNode type()
          Get the type node of the declaration.
 FieldDecl type(TypeNode type)
          Set the type of the declaration.
 Node typeCheck(TypeChecker tc)
          Type check the declaration.
 Node visitChildren(NodeVisitor v)
          Visit the children of the declaration.
 
Methods inherited from class polyglot.ext.jl.ast.Term_c
exceptions, exceptions, listEntry, reachable, reachable
 
Methods inherited from class polyglot.ext.jl.ast.Node_c
addDecls, addMembers, addMembersOverride, buildTypesOverride, copy, del, del, disambiguateOverride, enterScope, exceptionCheckEnter, exceptionCheckOverride, ext, ext, ext, ext, init, node, position, position, print, printBlock, printSubStmt, throwTypes, translate, typeCheckEnter, typeCheckOverride, visit, visitChild, visitEdge, visitList
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface polyglot.ast.Term
exceptions, exceptions, reachable, reachable
 
Methods inherited from interface polyglot.ast.Node
del, del, ext, ext, ext, ext, position, position, visit, visitChild, visitEdge, visitList
 
Methods inherited from interface polyglot.ast.JL
init, node
 
Methods inherited from interface polyglot.ast.NodeOps
addDecls, addMembers, enterScope, exceptionCheckEnter, throwTypes, translate, typeCheckEnter
 
Methods inherited from interface polyglot.util.Copy
copy
 

Field Detail

flags

protected Flags flags

type

protected TypeNode type

name

protected java.lang.String name

init

protected Expr init

fi

protected FieldInstance fi

ii

protected InitializerInstance ii
Constructor Detail

FieldDecl_c

public FieldDecl_c(Position pos,
                   Flags flags,
                   TypeNode type,
                   java.lang.String name,
                   Expr init)
Method Detail

initializerInstance

public InitializerInstance initializerInstance()
Get the initializer instance of the initializer.

Specified by:
initializerInstance in interface FieldDecl

initializerInstance

public FieldDecl initializerInstance(InitializerInstance ii)
Set the initializer instance of the initializer.

Specified by:
initializerInstance in interface FieldDecl

declType

public Type declType()
Get the type of the declaration.

Specified by:
declType in interface FieldDecl

flags

public Flags flags()
Get the flags of the declaration.

Specified by:
flags in interface FieldDecl

flags

public FieldDecl flags(Flags flags)
Set the flags of the declaration.

Specified by:
flags in interface FieldDecl

type

public TypeNode type()
Get the type node of the declaration.

Specified by:
type in interface FieldDecl

type

public FieldDecl type(TypeNode type)
Set the type of the declaration.

Specified by:
type in interface FieldDecl

name

public java.lang.String name()
Get the name of the declaration.

Specified by:
name in interface FieldDecl

name

public FieldDecl name(java.lang.String name)
Set the name of the declaration.

Specified by:
name in interface FieldDecl

init

public Expr init()
Get the initializer of the declaration.

Specified by:
init in interface FieldDecl

init

public FieldDecl init(Expr init)
Set the initializer of the declaration.

Specified by:
init in interface FieldDecl

fieldInstance

public FieldDecl fieldInstance(FieldInstance fi)
Set the field instance of the declaration.

Specified by:
fieldInstance in interface FieldDecl

fieldInstance

public FieldInstance fieldInstance()
Get the field instance of the declaration.

Specified by:
fieldInstance in interface FieldDecl

reconstruct

protected FieldDecl_c reconstruct(TypeNode type,
                                  Expr init)
Reconstruct the declaration.


visitChildren

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

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

buildTypesEnter

public NodeVisitor buildTypesEnter(TypeBuilder tb)
                            throws SemanticException
Description copied from interface: NodeOps
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
Overrides:
buildTypesEnter in class Node_c
Parameters:
tb - The visitor which adds new type objects to the TypeSystem.
Throws:
SemanticException

buildTypes

public Node buildTypes(TypeBuilder tb)
                throws SemanticException
Description copied from interface: NodeOps
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
Overrides:
buildTypes in class Node_c
Parameters:
tb - The visitor which adds new type objects to the TypeSystem.
Throws:
SemanticException

disambiguateEnter

public NodeVisitor disambiguateEnter(AmbiguityRemover ar)
                              throws SemanticException
Build type objects for the declaration.

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

disambiguate

public Node disambiguate(AmbiguityRemover ar)
                  throws SemanticException
Description copied from interface: NodeOps
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
Overrides:
disambiguate in class Node_c
Parameters:
ar - The visitor which disambiguates.
Throws:
SemanticException

checkFieldInstanceConstant

protected void checkFieldInstanceConstant()

addMembersEnter

public NodeVisitor addMembersEnter(AddMemberVisitor am)
Description copied from interface: NodeOps
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
Overrides:
addMembersEnter in class Node_c
Parameters:
am - The visitor which builds types.

enterScope

public Context enterScope(Context c)
Description copied from class: Node_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.

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

typeCheck

public Node typeCheck(TypeChecker tc)
               throws SemanticException
Type check the declaration.

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

exceptionCheck

public Node exceptionCheck(ExceptionChecker ec)
                    throws SemanticException
Description copied from interface: NodeOps
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
Overrides:
exceptionCheck in class Term_c
Parameters:
ec - The visitor.
Throws:
SemanticException

childExpectedType

public Type childExpectedType(Expr child,
                              AscriptionVisitor av)
Description copied from interface: Node
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.

Specified by:
childExpectedType in interface Node
Overrides:
childExpectedType in class Node_c
Parameters:
child - A child expression of this node.
av - An ascription visitor.
Returns:
The expected type of child.

entry

public Term entry()
Return the first (sub)term performed when evaluating this term.

Specified by:
entry in interface Term
Specified by:
entry in class Term_c

acceptCFG

public java.util.List acceptCFG(CFGBuilder v,
                                java.util.List succs)
Visit this term in evaluation order.

Specified by:
acceptCFG in interface Term
Specified by:
acceptCFG in class Term_c

toString

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

prettyPrint

public void prettyPrint(CodeWriter w,
                        PrettyPrinter tr)
Description copied from class: Node_c
Pretty-print the AST using the given CodeWriter.

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

dump

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

Specified by:
dump in interface Node
Overrides:
dump in class Node_c