public class ClassDecl_c extends Term_c implements ClassDecl, ClassDeclOps
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.Term.Instance
Modifier and Type | Field and Description |
---|---|
protected ClassBody |
body |
protected ConstructorInstance |
defaultCI |
protected Flags |
flags |
protected boolean |
implicitMembersAdded |
protected java.util.List<TypeNode> |
interfaces |
protected Id |
name |
protected TypeNode |
superClass |
protected ParsedClassType |
type |
exceptions, reachable
Constructor and Description |
---|
ClassDecl_c(Position pos,
Flags flags,
Id name,
TypeNode superClass,
java.util.List<TypeNode> interfaces,
ClassBody body) |
ClassDecl_c(Position pos,
Flags flags,
Id name,
TypeNode superClass,
java.util.List<TypeNode> interfaces,
ClassBody body,
Ext ext) |
Modifier and Type | Method and Description |
---|---|
<T> java.util.List<T> |
acceptCFG(CFGBuilder<?> v,
java.util.List<T> succs)
Visit this term in evaluation order, calling v.edge() for each successor
in succs, if data flows on that edge.
|
Node |
addDefaultConstructor(TypeSystem ts,
NodeFactory nf,
ConstructorInstance defaultCI) |
protected Node |
addDefaultConstructorIfNeeded(TypeSystem ts,
NodeFactory nf) |
ClassBody |
body()
The class's body.
|
ClassDecl |
body(ClassBody body)
Set the class's body.
|
protected <N extends ClassDecl_c> |
body(N n,
ClassBody 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) |
Node |
copy(NodeFactory nf)
Produce a copy of this node using the given NodeFactory.
|
protected boolean |
defaultConstructorNeeded() |
Node |
disambiguate(AmbiguityRemover ar)
Remove any remaining ambiguities from the AST.
|
Node |
disambiguateOverride(Node parent,
AmbiguityRemover ar)
Disambiguate 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 . |
Node |
extRewrite(ExtensionRewriter rw)
Rewrite the AST for the compilation in this language.
|
Term |
firstChild()
Return the first direct subterm performed when evaluating this term.
|
Flags |
flags()
The class declaration's flags.
|
ClassDecl |
flags(Flags flags)
Set the class declaration's flags.
|
protected <N extends ClassDecl_c> |
flags(N n,
Flags flags) |
Id |
id()
The class declaration's name.
|
ClassDecl |
id(Id name)
Set the class declaration's name.
|
protected <N extends ClassDecl_c> |
id(N n,
Id name) |
java.util.List<TypeNode> |
interfaces()
The class's interface list.
|
ClassDecl |
interfaces(java.util.List<TypeNode> interfaces)
Set the class's interface list.
|
protected <N extends ClassDecl_c> |
interfaces(N n,
java.util.List<TypeNode> interfaces) |
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 <N extends ClassDecl_c> |
reconstruct(N n,
Id name,
TypeNode superClass,
java.util.List<TypeNode> interfaces,
ClassBody body) |
protected void |
setInterfaces(AmbiguityRemover ar,
java.util.List<TypeNode> newInterfaces) |
protected void |
setSuperClass(AmbiguityRemover ar,
TypeNode superClass) |
TypeNode |
superClass()
The class's super class.
|
protected <N extends ClassDecl_c> |
superClass(N n,
TypeNode superClass) |
ClassDecl |
superClass(TypeNode superClass)
Set the class's super class.
|
java.lang.String |
toString() |
ParsedClassType |
type()
The type of the class declaration.
|
protected <N extends ClassDecl_c> |
type(N n,
ParsedClassType type) |
ClassDecl |
type(ParsedClassType type)
Set the type of the class declaration.
|
Node |
typeCheck(TypeChecker tc)
Type check the AST.
|
Node |
visitChildren(NodeVisitor v)
Visit the children of the node.
|
exceptionCheck, exceptions, exceptions, exceptions, listChild, reachable, reachable, reachable
addDecls, checkConstants, childExpectedType, copy, copy, copyIfNeeded, del, del, disambiguateEnter, dump, dump, dump, dump, enterScope, error, error, error, exceptionCheckEnter, ext, ext, ext, ext, extRewriteEnter, isTypeChecked, lang, position, position, position, prettyPrint, prettyPrint, prettyPrint, prettyPrint, print, printBlock, printSubStmt, throwTypes, translate, typeCheckEnter, typeCheckOverride, visit, visitChild, visitEdge, visitList
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
exceptions, exceptions, reachable, reachable
del, del, error, error, ext, ext, ext, ext, isTypeChecked, position, position, visit, visitEdge
addDecls, checkConstants, childExpectedType, copy, disambiguateEnter, dump, dump, dump, dump, enterScope, exceptionCheck, exceptionCheckEnter, extRewriteEnter, lang, prettyPrint, prettyPrint, prettyPrint, prettyPrint, throwTypes, translate, typeCheckEnter, typeCheckOverride, visitChild, visitList
protected Flags flags
protected Id name
protected TypeNode superClass
protected java.util.List<TypeNode> interfaces
protected ClassBody body
protected ConstructorInstance defaultCI
protected boolean implicitMembersAdded
protected ParsedClassType type
public ClassDecl_c(Position pos, Flags flags, Id name, TypeNode superClass, java.util.List<TypeNode> interfaces, ClassBody body)
public boolean isDisambiguated()
isDisambiguated
in interface Node
isDisambiguated
in class Node_c
public MemberInstance memberInstance()
memberInstance
in interface ClassMember
public ParsedClassType type()
ClassDecl
public ClassDecl type(ParsedClassType type)
ClassDecl
protected <N extends ClassDecl_c> N type(N n, ParsedClassType type)
public Flags flags()
ClassDecl
flags
in interface ClassDecl
flags
in interface TopLevelDecl
public ClassDecl flags(Flags flags)
ClassDecl
protected <N extends ClassDecl_c> N flags(N n, Flags flags)
public ClassDecl id(Id name)
ClassDecl
protected <N extends ClassDecl_c> N id(N n, Id name)
public java.lang.String name()
ClassDecl
name
in interface ClassDecl
name
in interface TopLevelDecl
public ClassDecl name(java.lang.String name)
ClassDecl
public TypeNode superClass()
ClassDecl
superClass
in interface ClassDecl
public ClassDecl superClass(TypeNode superClass)
ClassDecl
superClass
in interface ClassDecl
protected <N extends ClassDecl_c> N superClass(N n, TypeNode superClass)
public java.util.List<TypeNode> interfaces()
ClassDecl
interfaces
in interface ClassDecl
TypeNode
.public ClassDecl interfaces(java.util.List<TypeNode> interfaces)
ClassDecl
interfaces
in interface ClassDecl
interfaces
- A list of TypeNode
.protected <N extends ClassDecl_c> N interfaces(N n, java.util.List<TypeNode> interfaces)
public ClassDecl body(ClassBody body)
ClassDecl
protected <N extends ClassDecl_c> N body(N n, ClassBody body)
protected <N extends ClassDecl_c> N reconstruct(N n, Id name, TypeNode superClass, java.util.List<TypeNode> interfaces, ClassBody body)
public Node visitChildren(NodeVisitor v)
NodeOps
visitChildren
in interface NodeOps
visitChildren
in class Node_c
v
- The visitor that will traverse/rewrite the AST.this
.public NodeVisitor buildTypesEnter(TypeBuilder tb) throws SemanticException
NodeOps
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.buildTypesEnter
in interface NodeOps
buildTypesEnter
in class Node_c
tb
- The visitor which adds new type objects to the
TypeSystem
.SemanticException
public Node buildTypes(TypeBuilder tb) throws SemanticException
NodeOps
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.buildTypes
in interface NodeOps
buildTypes
in class Node_c
tb
- The visitor which adds new type objects to the
TypeSystem
.SemanticException
public Context enterChildScope(Node child, Context c)
NodeOps
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.enterChildScope
in interface NodeOps
enterChildScope
in class Node_c
child
- the child node about to be entered.c
- the current Context
Context
to be used for visiting node
child
public Node disambiguate(AmbiguityRemover ar) throws SemanticException
NodeOps
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.disambiguate
in interface NodeOps
disambiguate
in class Node_c
ar
- The visitor which disambiguates.SemanticException
protected ClassDecl_c disambiguateSupertypes(AmbiguityRemover ar) throws SemanticException
SemanticException
protected void checkSupertypeCycles(TypeSystem ts) throws SemanticException
SemanticException
protected void setSuperClass(AmbiguityRemover ar, TypeNode superClass) throws SemanticException
SemanticException
protected void setInterfaces(AmbiguityRemover ar, java.util.List<TypeNode> newInterfaces) throws SemanticException
SemanticException
protected Node addDefaultConstructorIfNeeded(TypeSystem ts, NodeFactory nf) throws SemanticException
SemanticException
protected boolean defaultConstructorNeeded()
public Node addDefaultConstructor(TypeSystem ts, NodeFactory nf, ConstructorInstance defaultCI) throws SemanticException
addDefaultConstructor
in interface ClassDeclOps
SemanticException
public Node typeCheck(TypeChecker tc) throws SemanticException
NodeOps
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.typeCheck
in interface NodeOps
typeCheck
in class Node_c
tc
- The type checking visitor.SemanticException
public Node extRewrite(ExtensionRewriter rw) throws SemanticException
NodeOps
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.extRewrite
in interface NodeOps
extRewrite
in class Term_c
rw
- The visitor.SemanticException
public Term firstChild()
TermOps
firstChild
in interface TermOps
firstChild
in class Term_c
public <T> java.util.List<T> acceptCFG(CFGBuilder<?> v, java.util.List<T> succs)
TermOps
public void prettyPrintHeader(CodeWriter w, PrettyPrinter tr)
prettyPrintHeader
in interface ClassDeclOps
public void prettyPrintFooter(CodeWriter w, PrettyPrinter tr)
prettyPrintFooter
in interface ClassDeclOps
public void prettyPrint(CodeWriter w, PrettyPrinter tr)
Node_c
CodeWriter
.prettyPrint
in interface NodeOps
prettyPrint
in class Node_c
w
- The code writer to which to write.tr
- The pretty printer. This is not a visitor.public void dump(CodeWriter w)
Node
public Node disambiguateOverride(Node parent, AmbiguityRemover ar) throws SemanticException
NodeOps
override()
method of the
visitor. If this method returns non-null, the node's children
will not be visited automatically. Thus, the method should check
both the node this
and it's children, usually by
invoking visitChildren
with tc
or
with another visitor, returning a non-null node. OR, the method
should do nothing and simply return null
to allow
enter
, visitChildren
, and leave
to be invoked on the node.
The default implementation returns null
.
Overriding of this method is discouraged, but sometimes necessary.disambiguateOverride
in interface NodeOps
disambiguateOverride
in class Node_c
ar
- The visitor which disambiguates.SemanticException