polyglot.ext.jl.ast
Class MethodDecl_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.MethodDecl_c
All Implemented Interfaces:
java.lang.Cloneable, ClassMember, CodeDecl, JL, MethodDecl, Node, NodeOps, ProcedureDecl, Term, Copy
Direct Known Subclasses:
CofferMethodDecl_c

public class MethodDecl_c
extends Term_c
implements MethodDecl

A method declaration.


Field Summary
protected  Block body
           
protected  Flags flags
           
protected  java.util.List formals
           
protected  MethodInstance mi
           
protected  java.lang.String name
           
protected  TypeNode returnType
           
protected  java.util.List throwTypes
           
 
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
MethodDecl_c(Position pos, Flags flags, TypeNode returnType, java.lang.String name, java.util.List formals, java.util.List throwTypes, 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 method.
 CodeDecl body(Block body)
          Set the body of the method.
 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.
 CodeInstance codeInstance()
          The CodeInstance of the method, constructor, or initializer.
 Node disambiguate(AmbiguityRemover ar)
          Remove any remaining ambiguities from the AST.
 NodeVisitor disambiguateEnter(AmbiguityRemover ar)
          Build type objects for the method.
 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 method.
 Flags flags()
          Get the flags of the method.
 MethodDecl flags(Flags flags)
          Set the flags of the method.
 java.util.List formals()
          Get the formals of the method.
 MethodDecl formals(java.util.List formals)
          Set the formals of the method.
protected  MethodInstance makeMethodInstance(ClassType ct, TypeSystem ts)
           
 MethodInstance methodInstance()
          Get the method instance of the method.
 MethodDecl methodInstance(MethodInstance mi)
          Set the method instance of the method.
 java.lang.String name()
          Get the name of the method.
 MethodDecl name(java.lang.String name)
          Set the name of the method.
protected  void overrideMethodCheck(TypeChecker tc)
           
 void prettyPrint(CodeWriter w, PrettyPrinter tr)
          Pretty-print the AST using the given CodeWriter.
 void prettyPrintHeader(Flags flags, CodeWriter w, PrettyPrinter tr)
          Write the method to an output file.
 ProcedureInstance procedureInstance()
          Get the procedure instance of the method.
protected  MethodDecl_c reconstruct(TypeNode returnType, java.util.List formals, java.util.List throwTypes, Block body)
          Reconstruct the method.
 TypeNode returnType()
          Get the return type of the method.
 MethodDecl returnType(TypeNode returnType)
          Set the return type of the method.
 java.util.List throwTypes()
          Get the exception types of the method.
 MethodDecl throwTypes(java.util.List throwTypes)
          Set the exception types of the method.
 java.lang.String toString()
           
 void translate(CodeWriter w, Translator tr)
          Translate the AST using the given CodeWriter.
 Node typeCheck(TypeChecker tc)
          Type check the method.
 Node visitChildren(NodeVisitor v)
          Visit the children of the method.
 
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, disambiguateOverride, enterScope, exceptionCheckEnter, exceptionCheckOverride, ext, ext, ext, ext, init, node, position, position, print, printBlock, printSubStmt, throwTypes, 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, enterScope, exceptionCheckEnter, throwTypes, typeCheckEnter
 
Methods inherited from interface polyglot.util.Copy
copy
 

Field Detail

flags

protected Flags flags

returnType

protected TypeNode returnType

name

protected java.lang.String name

formals

protected java.util.List formals

throwTypes

protected java.util.List throwTypes

body

protected Block body

mi

protected MethodInstance mi
Constructor Detail

MethodDecl_c

public MethodDecl_c(Position pos,
                    Flags flags,
                    TypeNode returnType,
                    java.lang.String name,
                    java.util.List formals,
                    java.util.List throwTypes,
                    Block body)
Method Detail

flags

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

Specified by:
flags in interface MethodDecl
Specified by:
flags in interface ProcedureDecl

flags

public MethodDecl flags(Flags flags)
Set the flags of the method.

Specified by:
flags in interface MethodDecl

returnType

public TypeNode returnType()
Get the return type of the method.

Specified by:
returnType in interface MethodDecl

returnType

public MethodDecl returnType(TypeNode returnType)
Set the return type of the method.

Specified by:
returnType in interface MethodDecl

name

public java.lang.String name()
Get the name of the method.

Specified by:
name in interface MethodDecl
Specified by:
name in interface ProcedureDecl

name

public MethodDecl name(java.lang.String name)
Set the name of the method.

Specified by:
name in interface MethodDecl

formals

public java.util.List formals()
Get the formals of the method.

Specified by:
formals in interface MethodDecl
Specified by:
formals in interface ProcedureDecl
Returns:
A list of Formal.

formals

public MethodDecl formals(java.util.List formals)
Set the formals of the method.

Specified by:
formals in interface MethodDecl
Parameters:
formals - A list of Formal.

throwTypes

public java.util.List throwTypes()
Get the exception types of the method.

Specified by:
throwTypes in interface MethodDecl
Specified by:
throwTypes in interface ProcedureDecl
Returns:
A list of TypeNode.

throwTypes

public MethodDecl throwTypes(java.util.List throwTypes)
Set the exception types of the method.

Specified by:
throwTypes in interface MethodDecl
Parameters:
throwTypes - A list of TypeNode.

body

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

Specified by:
body in interface CodeDecl

body

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

Specified by:
body in interface CodeDecl

methodInstance

public MethodInstance methodInstance()
Get the method instance of the method.

Specified by:
methodInstance in interface MethodDecl

methodInstance

public MethodDecl methodInstance(MethodInstance mi)
Set the method instance of the method.

Specified by:
methodInstance in interface MethodDecl

codeInstance

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

Specified by:
codeInstance in interface CodeDecl

procedureInstance

public ProcedureInstance procedureInstance()
Get the procedure instance of the method.

Specified by:
procedureInstance in interface ProcedureDecl

reconstruct

protected MethodDecl_c reconstruct(TypeNode returnType,
                                   java.util.List formals,
                                   java.util.List throwTypes,
                                   Block body)
Reconstruct the method.


visitChildren

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

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

disambiguateEnter

public NodeVisitor disambiguateEnter(AmbiguityRemover ar)
                              throws SemanticException
Build type objects for the method.

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

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.

Specified by:
disambiguate in interface NodeOps
Overrides:
disambiguate in class Node_c
Parameters:
ar - The visitor which disambiguates.
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.

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.

typeCheck

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

Specified by:
typeCheck in interface NodeOps
Overrides:
typeCheck in class Node_c
Parameters:
tc - The type checking visitor.
Throws:
SemanticException

overrideMethodCheck

protected void overrideMethodCheck(TypeChecker tc)
                            throws SemanticException
Throws:
SemanticException

exceptionCheck

public Node exceptionCheck(ExceptionChecker ec)
                    throws SemanticException
Check exceptions thrown by the method.

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

toString

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

prettyPrintHeader

public void prettyPrintHeader(Flags flags,
                              CodeWriter w,
                              PrettyPrinter tr)
Write the method to an output file.


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.

translate

public void translate(CodeWriter w,
                      Translator tr)
Description copied from class: Node_c
Translate the AST using the given CodeWriter.

Specified by:
translate in interface NodeOps
Overrides:
translate in class Node_c
Parameters:
w - The code writer to which to write.
tr - The translation pass. 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

makeMethodInstance

protected MethodInstance makeMethodInstance(ClassType ct,
                                            TypeSystem ts)
                                     throws SemanticException
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)
Visit this term in evaluation order.

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