polyglot.ext.jl.ast
Class Initializer_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.Initializer_c
All Implemented Interfaces:
java.lang.Cloneable, ClassMember, CodeDecl, Initializer, JL, Node, NodeOps, Term, Copy

public class Initializer_c
extends Term_c
implements Initializer

An 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.


Field Summary
protected  Block body
           
protected  Flags flags
           
protected  InitializerInstance ii
           
 
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
Initializer_c(Position pos, Flags flags, Block body)
           
 
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.
 Block body()
          Get the body of the initializer.
 CodeDecl body(Block body)
          Set the body of the initializer.
 Node buildTypes(TypeBuilder tb)
          Build type objects for the method.
 NodeVisitor buildTypesEnter(TypeBuilder tb)
          Collects classes, methods, and fields from the AST rooted at this node and constructs type objects for these.
 CodeInstance codeInstance()
          The CodeInstance of the method, constructor, or initializer.
 NodeVisitor disambiguateEnter(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.
 Term entry()
          Return the first (sub)term performed when evaluating this term.
 Node exceptionCheck(ExceptionChecker ec)
          Check exceptions thrown by the initializer.
 Flags flags()
          Get the flags of the initializer.
 Initializer flags(Flags flags)
          Set the flags of the initializer.
 InitializerInstance initializerInstance()
          Get the initializer instance of the initializer.
 Initializer initializerInstance(InitializerInstance ii)
          Set the initializer instance of the initializer.
 void prettyPrint(CodeWriter w, PrettyPrinter tr)
          Write the initializer to an output file.
protected  Initializer_c reconstruct(Block body)
          Reconstruct the initializer.
 java.lang.String toString()
           
 Node typeCheck(TypeChecker tc)
          Type check the initializer.
 Node visitChildren(NodeVisitor v)
          Visit the children of the initializer.
 
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, childExpectedType, copy, del, del, disambiguate, 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
childExpectedType, 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, disambiguate, enterScope, exceptionCheckEnter, throwTypes, translate, typeCheckEnter
 
Methods inherited from interface polyglot.util.Copy
copy
 

Field Detail

flags

protected Flags flags

body

protected Block body

ii

protected InitializerInstance ii
Constructor Detail

Initializer_c

public Initializer_c(Position pos,
                     Flags flags,
                     Block body)
Method Detail

flags

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

Specified by:
flags in interface Initializer

flags

public Initializer flags(Flags flags)
Set the flags of the initializer.

Specified by:
flags in interface Initializer

initializerInstance

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

Specified by:
initializerInstance in interface Initializer

codeInstance

public CodeInstance codeInstance()
Description copied from interface: CodeDecl
The CodeInstance of the method, constructor, or initializer.

Specified by:
codeInstance in interface CodeDecl

initializerInstance

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

Specified by:
initializerInstance in interface Initializer

body

public Block body()
Get the body of the initializer.

Specified by:
body in interface CodeDecl

body

public CodeDecl body(Block body)
Set the body of the initializer.

Specified by:
body in interface CodeDecl

reconstruct

protected Initializer_c reconstruct(Block body)
Reconstruct the initializer.


visitChildren

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

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.

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.

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

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)
Description copied from class: Term_c
Visit this term in evaluation order.

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

buildTypes

public Node buildTypes(TypeBuilder tb)
                throws SemanticException
Build type objects for the method.

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

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.

disambiguateEnter

public NodeVisitor disambiguateEnter(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:
disambiguateEnter in interface NodeOps
Overrides:
disambiguateEnter in class Node_c
Parameters:
ar - The visitor which disambiguates.
Throws:
SemanticException

typeCheck

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

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
Check exceptions thrown by the initializer.

Specified by:
exceptionCheck in interface NodeOps
Overrides:
exceptionCheck in class Term_c
Parameters:
ec - The visitor.
Throws:
SemanticException

prettyPrint

public void prettyPrint(CodeWriter w,
                        PrettyPrinter tr)
Write the initializer to an output file.

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

toString

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