polyglot.ast
Class ClassDecl_c

java.lang.Object
  extended by polyglot.ast.Node_c
      extended by polyglot.ast.Term_c
          extended by polyglot.ast.ClassDecl_c
All Implemented Interfaces:
java.lang.Cloneable, ClassDecl, ClassMember, JL, Node, NodeOps, Term, TopLevelDecl, Copy
Direct Known Subclasses:
CofferClassDecl_c

public class ClassDecl_c
extends Term_c
implements ClassDecl

A ClassDecl is the definition of a class, abstract class, or interface. It may be a public or other top-level class, or an inner named class, or an anonymous class.


Field Summary
protected  ClassBody body
           
protected  ConstructorInstance defaultCI
           
protected  Flags flags
           
protected  java.util.List interfaces
           
protected  java.lang.String name
           
protected  TypeNode superClass
           
protected  ParsedClassType type
           
 
Fields inherited from class polyglot.ast.Term_c
exceptions, reachable
 
Fields inherited from class polyglot.ast.Node_c
del, error, ext, position
 
Constructor Summary
ClassDecl_c(Position pos, Flags flags, java.lang.String name, TypeNode superClass, java.util.List interfaces, ClassBody body)
           
 
Method Summary
 java.util.List acceptCFG(CFGBuilder v, java.util.List succs)
          Visit this term in evaluation order.
protected  Node addDefaultConstructor(TypeSystem ts, NodeFactory nf)
           
protected  Node addDefaultConstructorIfNeeded(TypeSystem ts, NodeFactory nf)
           
 ClassBody body()
          The class's body.
 ClassDecl body(ClassBody body)
          Set the class's body.
 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 checkSupertypeCycles(TypeSystem ts)
           
protected  boolean defaultConstructorNeeded()
           
 Node disambiguate(AmbiguityRemover ar)
          Remove any remaining ambiguities from the AST.
 Node disambiguateOverride(Node parent, AmbiguityRemover ar)
          Remove any remaining ambiguities from the AST.
protected  ClassDecl_c disambiguateSupertypes(AmbiguityRemover ar)
           
 void dump(CodeWriter w)
          Dump the AST node for debugging purposes.
 Context enterChildScope(Node child, Context c)
          Push a new scope for visiting the child node child.
 Term entry()
          Return the first (sub)term performed when evaluating this term.
 Flags flags()
          The class declaration's flags.
 ClassDecl flags(Flags flags)
          Set the class declaration's flags.
 java.util.List interfaces()
          The class's interface list.
 ClassDecl interfaces(java.util.List interfaces)
          Set the class's interface list.
 boolean isDisambiguated()
           
 MemberInstance memberInstance()
           
 java.lang.String name()
          The class declaration's name.
 ClassDecl name(java.lang.String name)
          Set the class declaration's name.
 void prettyPrint(CodeWriter w, PrettyPrinter tr)
          Pretty-print the AST using the given CodeWriter.
 void prettyPrintFooter(CodeWriter w, PrettyPrinter tr)
           
 void prettyPrintHeader(CodeWriter w, PrettyPrinter tr)
           
protected  ClassDecl_c reconstruct(TypeNode superClass, java.util.List interfaces, ClassBody body)
           
protected  void setInterfaces(AmbiguityRemover ar, java.util.List newInterfaces)
           
protected  void setSuperClass(AmbiguityRemover ar, TypeNode superClass)
           
 TypeNode superClass()
          The class's super class.
 ClassDecl superClass(TypeNode superClass)
          Set the class's super class.
 java.lang.String toString()
           
 ParsedClassType type()
          The type of the class declaration.
 ClassDecl type(ParsedClassType type)
          Set the type of the class declaration.
 Node typeCheck(TypeChecker tc)
           
 Node visitChildren(NodeVisitor v)
          Visit the children of the node.
 
Methods inherited from class polyglot.ast.Term_c
exceptionCheck, exceptions, exceptions, listEntry, reachable, reachable
 
Methods inherited from class polyglot.ast.Node_c
addDecls, checkConstants, childExpectedType, copy, del, del, disambiguateEnter, dump, dump, enterScope, error, error, exceptionCheckEnter, ext, ext, ext, ext, init, isTypeChecked, node, position, position, prettyPrint, prettyPrint, 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
 

Field Detail

flags

protected Flags flags

name

protected java.lang.String name

superClass

protected TypeNode superClass

interfaces

protected java.util.List interfaces

body

protected ClassBody body

defaultCI

protected ConstructorInstance defaultCI

type

protected ParsedClassType type
Constructor Detail

ClassDecl_c

public ClassDecl_c(Position pos,
                   Flags flags,
                   java.lang.String name,
                   TypeNode superClass,
                   java.util.List interfaces,
                   ClassBody body)
Method Detail

isDisambiguated

public boolean isDisambiguated()
Specified by:
isDisambiguated in interface Node
Overrides:
isDisambiguated in class Node_c
Returns:
true if the all type information for the node (but not necessarily for the node's children) is unambiguous.

memberInstance

public MemberInstance memberInstance()
Specified by:
memberInstance in interface ClassMember

type

public ParsedClassType type()
Description copied from interface: ClassDecl
The type of the class declaration.

Specified by:
type in interface ClassDecl

type

public ClassDecl type(ParsedClassType type)
Description copied from interface: ClassDecl
Set the type of the class declaration.

Specified by:
type in interface ClassDecl

flags

public Flags flags()
Description copied from interface: ClassDecl
The class declaration's flags.

Specified by:
flags in interface ClassDecl
Specified by:
flags in interface TopLevelDecl

flags

public ClassDecl flags(Flags flags)
Description copied from interface: ClassDecl
Set the class declaration's flags.

Specified by:
flags in interface ClassDecl

name

public java.lang.String name()
Description copied from interface: ClassDecl
The class declaration's name.

Specified by:
name in interface ClassDecl
Specified by:
name in interface TopLevelDecl

name

public ClassDecl name(java.lang.String name)
Description copied from interface: ClassDecl
Set the class declaration's name.

Specified by:
name in interface ClassDecl

superClass

public TypeNode superClass()
Description copied from interface: ClassDecl
The class's super class.

Specified by:
superClass in interface ClassDecl

superClass

public ClassDecl superClass(TypeNode superClass)
Description copied from interface: ClassDecl
Set the class's super class.

Specified by:
superClass in interface ClassDecl

interfaces

public java.util.List interfaces()
Description copied from interface: ClassDecl
The class's interface list.

Specified by:
interfaces in interface ClassDecl
Returns:
A list of TypeNode.

interfaces

public ClassDecl interfaces(java.util.List interfaces)
Description copied from interface: ClassDecl
Set the class's interface list.

Specified by:
interfaces in interface ClassDecl
Parameters:
interfaces - A list of TypeNode.

body

public ClassBody body()
Description copied from interface: ClassDecl
The class's body.

Specified by:
body in interface ClassDecl

body

public ClassDecl body(ClassBody body)
Description copied from interface: ClassDecl
Set the class's body.

Specified by:
body in interface ClassDecl

reconstruct

protected ClassDecl_c reconstruct(TypeNode superClass,
                                  java.util.List interfaces,
                                  ClassBody body)

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

visitChildren

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

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

enterChildScope

public Context enterChildScope(Node child,
                               Context c)
Description copied from class: Node_c
Push a new scope for visiting the child node child. The default behavior is to delegate the call to the child node, and let it add appropriate declarations that should be in scope. However, this method gives parent nodes have the ability to modify this behavior.

Specified by:
enterChildScope in interface NodeOps
Overrides:
enterChildScope in class Node_c
Parameters:
child - the child node about to be entered.
c - the current Context
Returns:
the Context to be used for visiting node child

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. The node should not assume that its children have been disambiguated. If it depends on a child being disambiguated, it may just return this without doing any work.

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

disambiguateSupertypes

protected ClassDecl_c disambiguateSupertypes(AmbiguityRemover ar)
                                      throws SemanticException
Throws:
SemanticException

checkSupertypeCycles

protected void checkSupertypeCycles(TypeSystem ts)
                             throws SemanticException
Throws:
SemanticException

setSuperClass

protected void setSuperClass(AmbiguityRemover ar,
                             TypeNode superClass)
                      throws SemanticException
Throws:
SemanticException

setInterfaces

protected void setInterfaces(AmbiguityRemover ar,
                             java.util.List newInterfaces)
                      throws SemanticException
Throws:
SemanticException

addDefaultConstructorIfNeeded

protected Node addDefaultConstructorIfNeeded(TypeSystem ts,
                                             NodeFactory nf)
                                      throws SemanticException
Throws:
SemanticException

defaultConstructorNeeded

protected boolean defaultConstructorNeeded()

addDefaultConstructor

protected Node addDefaultConstructor(TypeSystem ts,
                                     NodeFactory nf)
                              throws SemanticException
Throws:
SemanticException

typeCheck

public Node typeCheck(TypeChecker tc)
               throws SemanticException
Specified by:
typeCheck in interface NodeOps
Overrides:
typeCheck in class Node_c
Throws:
SemanticException

toString

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

prettyPrintHeader

public void prettyPrintHeader(CodeWriter w,
                              PrettyPrinter tr)

prettyPrintFooter

public void prettyPrintFooter(CodeWriter w,
                              PrettyPrinter tr)

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

disambiguateOverride

public Node disambiguateOverride(Node parent,
                                 AmbiguityRemover ar)
                          throws SemanticException
Description copied from interface: NodeOps
Remove any remaining ambiguities from the AST. 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:
disambiguateOverride in interface NodeOps
Overrides:
disambiguateOverride in class Node_c
Parameters:
parent -
ar -
Throws:
SemanticException