public class Initializer_c extends Term_c implements Initializer
Initializer
is an immutable representation of an
initializer block in a Java class (which appears outside of any
method). Such a block is executed before the code for any of the
constructors. Such a block can optionally be static, in which case
it is executed when the class is loaded.Term.Instance
Modifier and Type | Field and Description |
---|---|
protected Block |
body |
protected Flags |
flags |
protected InitializerInstance |
ii |
exceptions, reachable
Constructor and Description |
---|
Initializer_c(Position pos,
Flags flags,
Block body) |
Initializer_c(Position pos,
Flags flags,
Block 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.
|
Block |
body()
The body of the method, constructor, or initializer.
|
CodeBlock |
body(Block body)
Set the body of the method, constructor, or initializer.
|
protected <N extends Initializer_c> |
body(N n,
Block 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.
|
Term |
codeBody()
The body of the method, constructor, initializer, or field initializer.
|
CodeInstance |
codeInstance()
The CodeInstance of the method, constructor, or initializer.
|
Node |
copy(NodeFactory nf)
Produce a copy of this node using the given NodeFactory.
|
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.
|
Term |
firstChild()
Return the first direct subterm performed when evaluating this term.
|
Flags |
flags()
Get the initializer's flags.
|
Initializer |
flags(Flags flags)
Set the initializer's flags.
|
protected <N extends Initializer_c> |
flags(N n,
Flags flags) |
InitializerInstance |
initializerInstance()
Get the initializer's type object.
|
Initializer |
initializerInstance(InitializerInstance ii)
Set the initializer's type object.
|
protected <N extends Initializer_c> |
initializerInstance(N n,
InitializerInstance ii) |
boolean |
isDisambiguated() |
MemberInstance |
memberInstance() |
void |
prettyPrint(CodeWriter w,
PrettyPrinter tr)
Pretty-print the AST using the given
CodeWriter . |
protected <N extends Initializer_c> |
reconstruct(N n,
Block body)
Reconstruct the initializer.
|
java.lang.String |
toString() |
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, disambiguate, 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, 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, disambiguate, disambiguateEnter, disambiguateOverride, dump, dump, dump, dump, enterChildScope, exceptionCheck, extRewriteEnter, lang, prettyPrint, prettyPrint, prettyPrint, prettyPrint, throwTypes, translate, typeCheckEnter, typeCheckOverride, visitChild, visitList
protected Flags flags
protected Block body
protected InitializerInstance ii
public boolean isDisambiguated()
isDisambiguated
in interface Node
isDisambiguated
in class Node_c
public Flags flags()
Initializer
flags
in interface Initializer
public Initializer flags(Flags flags)
Initializer
flags
in interface Initializer
protected <N extends Initializer_c> N flags(N n, Flags flags)
public CodeInstance codeInstance()
CodeNode
codeInstance
in interface CodeNode
public MemberInstance memberInstance()
memberInstance
in interface ClassMember
public InitializerInstance initializerInstance()
Initializer
initializerInstance
in interface Initializer
public Initializer initializerInstance(InitializerInstance ii)
Initializer
initializerInstance
in interface Initializer
protected <N extends Initializer_c> N initializerInstance(N n, InitializerInstance ii)
public Term codeBody()
CodeNode
public Block body()
CodeBlock
public CodeBlock body(Block body)
CodeBlock
protected <N extends Initializer_c> N body(N n, Block body)
protected <N extends Initializer_c> N reconstruct(N n, Block 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 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 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 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 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