public class FieldDecl_c extends Term_c implements FieldDecl
FieldDecl
is an immutable representation of the declaration
of a field of a class.Modifier and Type | Class and Description |
---|---|
static class |
FieldDecl_c.AddDependenciesVisitor |
Term.Instance
Modifier and Type | Field and Description |
---|---|
protected FieldInstance |
fi |
protected Flags |
flags |
protected InitializerInstance |
ii |
protected Expr |
init |
protected Id |
name |
protected TypeNode |
type |
exceptions, reachable
Constructor and Description |
---|
FieldDecl_c(Position pos,
Flags flags,
TypeNode type,
Id name,
Expr init) |
FieldDecl_c(Position pos,
Flags flags,
TypeNode type,
Id name,
Expr init,
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 |
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.
|
Node |
checkConstants(ConstantChecker cc)
Check if the node is a compile-time constant.
|
Type |
childExpectedType(Expr child,
AscriptionVisitor av)
Get the expected type of a child expression of
this . |
Term |
codeBody()
The body of the method, constructor, initializer, or field initializer.
|
CodeInstance |
codeInstance()
The CodeInstance of the method, constructor, or initializer.
|
boolean |
constantValueSet()
Whether the initializer has been determined to be constant or not.
|
Node |
copy(NodeFactory nf)
Produce a copy of this node using the given NodeFactory.
|
Type |
declType()
Get the type object for the declaration's type.
|
Node |
disambiguate(AmbiguityRemover ar)
Remove any remaining ambiguities from the AST.
|
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.
|
NodeVisitor |
exceptionCheckEnter(ExceptionChecker ec)
Check that exceptions are properly propagated throughout the AST.
|
Node |
extRewrite(ExtensionRewriter rw)
Rewrite the AST for the compilation in this language.
|
FieldInstance |
fieldInstance()
Get the type object for the field we are declaring.
|
FieldDecl |
fieldInstance(FieldInstance fi)
Set the type object for the field we are declaring.
|
protected <N extends FieldDecl_c> |
fieldInstance(N n,
FieldInstance fi) |
Term |
firstChild()
Return the first direct subterm performed when evaluating this term.
|
Flags |
flags()
Get the declaration's flags.
|
FieldDecl |
flags(Flags flags)
Set the declaration's flags.
|
protected <N extends FieldDecl_c> |
flags(N n,
Flags flags) |
Id |
id()
Get the declaration's name.
|
FieldDecl |
id(Id name)
Set the declaration's name.
|
protected <N extends FieldDecl_c> |
id(N n,
Id name) |
Expr |
init()
Get the declaration's initializer, or null.
|
FieldDecl |
init(Expr init)
Set the declaration's initializer.
|
protected <N extends FieldDecl_c> |
init(N n,
Expr init) |
InitializerInstance |
initializerInstance()
Get the type object for the initializer expression, or null.
|
FieldDecl |
initializerInstance(InitializerInstance ii)
Set the type object for the initializer expression.
|
protected <N extends FieldDecl_c> |
initializerInstance(N n,
InitializerInstance ii) |
boolean |
isDisambiguated() |
MemberInstance |
memberInstance() |
java.lang.String |
name()
Get the declaration's name.
|
FieldDecl |
name(java.lang.String name)
Set the declaration's name.
|
void |
prettyPrint(CodeWriter w,
PrettyPrinter tr)
Pretty-print the AST using the given
CodeWriter . |
protected <N extends FieldDecl_c> |
reconstruct(N n,
TypeNode type,
Id name,
Expr init)
Reconstruct the declaration.
|
java.lang.String |
toString() |
TypeNode |
type()
Get the declaration's type.
|
protected <N extends FieldDecl_c> |
type(N n,
TypeNode type) |
FieldDecl |
type(TypeNode type)
Set the declaration's type.
|
Node |
typeCheck(TypeChecker tc)
Type check the AST.
|
Node |
typeCheckOverride(Node parent,
TypeChecker tc)
Type check the AST.
|
VarInstance |
varInstance()
The variable being initialized.
|
Node |
visitChildren(NodeVisitor v)
Visit the children of the node.
|
exceptionCheck, exceptions, exceptions, exceptions, listChild, reachable, reachable, reachable
addDecls, copy, copy, copyIfNeeded, del, del, disambiguateEnter, disambiguateOverride, dump, dump, dump, dump, enterChildScope, error, error, error, ext, ext, ext, ext, extRewriteEnter, isTypeChecked, lang, position, position, position, prettyPrint, prettyPrint, prettyPrint, prettyPrint, print, printBlock, printSubStmt, throwTypes, translate, typeCheckEnter, 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, copy, disambiguateEnter, disambiguateOverride, dump, dump, dump, dump, enterChildScope, exceptionCheck, extRewriteEnter, lang, prettyPrint, prettyPrint, prettyPrint, prettyPrint, throwTypes, translate, typeCheckEnter, visitChild, visitList
protected Flags flags
protected TypeNode type
protected Id name
protected Expr init
protected FieldInstance fi
protected InitializerInstance ii
public boolean isDisambiguated()
isDisambiguated
in interface Node
isDisambiguated
in class Node_c
public MemberInstance memberInstance()
memberInstance
in interface ClassMember
public VarInstance varInstance()
VarInit
varInstance
in interface VarInit
public CodeInstance codeInstance()
CodeNode
codeInstance
in interface CodeNode
public InitializerInstance initializerInstance()
FieldDecl
{ }
or static { }
).initializerInstance
in interface FieldDecl
public FieldDecl initializerInstance(InitializerInstance ii)
FieldDecl
initializerInstance
in interface FieldDecl
protected <N extends FieldDecl_c> N initializerInstance(N n, InitializerInstance ii)
public Type declType()
FieldDecl
public Flags flags()
FieldDecl
public FieldDecl flags(Flags flags)
FieldDecl
protected <N extends FieldDecl_c> N flags(N n, Flags flags)
public TypeNode type()
FieldDecl
public FieldDecl type(TypeNode type)
FieldDecl
protected <N extends FieldDecl_c> N type(N n, TypeNode type)
public FieldDecl id(Id name)
FieldDecl
protected <N extends FieldDecl_c> N id(N n, Id name)
public java.lang.String name()
FieldDecl
public FieldDecl name(java.lang.String name)
FieldDecl
public Term codeBody()
CodeNode
public Expr init()
FieldDecl
public FieldDecl init(Expr init)
FieldDecl
protected <N extends FieldDecl_c> N init(N n, Expr init)
public FieldInstance fieldInstance()
FieldDecl
fieldInstance
in interface FieldDecl
public FieldDecl fieldInstance(FieldInstance fi)
FieldDecl
fieldInstance
in interface FieldDecl
protected <N extends FieldDecl_c> N fieldInstance(N n, FieldInstance fi)
protected <N extends FieldDecl_c> N reconstruct(N n, TypeNode type, Id name, Expr init)
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 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
public Context enterScope(Context c)
Node_c
enterScope
in interface NodeOps
enterScope
in class Node_c
c
- the current Context
Context
to be used for visiting this node.public Node checkConstants(ConstantChecker cc) 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.checkConstants
in interface NodeOps
checkConstants
in class Node_c
cc
- The constant checking visitor.SemanticException
public boolean constantValueSet()
VarInit
constantValueSet
in interface VarInit
public Node typeCheckOverride(Node parent, TypeChecker tc) throws SemanticException
Node_c
typeCheckOverride
in interface NodeOps
typeCheckOverride
in class Node_c
tc
- The type checking visitor.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 NodeVisitor exceptionCheckEnter(ExceptionChecker ec) throws SemanticException
NodeOps
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.exceptionCheckEnter
in interface NodeOps
exceptionCheckEnter
in class Node_c
ec
- The visitor.SemanticException
public Type childExpectedType(Expr child, AscriptionVisitor av)
NodeOps
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.childExpectedType
in interface NodeOps
childExpectedType
in class Node_c
child
- A child expression of this node.av
- An ascription visitor.child
.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 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