JML

org.multijava.mjc
Interface JMethodDeclarationType

All Superinterfaces:
Annotatable, Comparable, JMemberDeclarationType, PhylumType
All Known Subinterfaces:
JConstructorDeclarationType
All Known Implementing Classes:
JConstructorDeclaration, JMethodDeclaration, JmlConstructorDeclaration, JmlMethodDeclaration, RacParser.RacMethodDeclaration

public interface JMethodDeclarationType
extends JMemberDeclarationType, Comparable

This type represents a java method in the syntax tree.


Method Summary
 void addParameter(JFormalParameter param)
          Adds an additional formal parameter to this method, appending it to the end of the existing parameter list.
 JBlock body()
          WMD TODO remove WMD TODO remove
 CMember checkInterface(CContextType context)
          Checks the basic interfaces to make sure things generally look OK.
 CSourceMethod checkInterfaceType(CContextType context, MemberAccess access, String ident)
          Performs the interface checks that are common to all sorts of methods.
 void checkOverriding(CContextType context, CMethodSet superMethods)
          Checks that this method appropriately overrides the given superclass methods.
 int compareTo(Object o)
          Compares this method to a given method and returns 0 if the methods belong to the same generic function, otherwise returns -1 or +1 to sort the methods.
 CMethodContextType createSelfContext(CClassContextType parent)
          Creates a context for this method declaration AST node.
 CClassType[] getExceptions()
           
 boolean hasBody()
           
 String ident()
           
 boolean isDeclaredNonNull()
           
 boolean isExternal()
          Indicates whether this member is external.
 boolean isOverriding()
          Return true if this method declaration overrides any of its superclass (or interfaces) method declarations.
 long modifiers()
           
 CMethodSet overriddenMethods()
          Return the set of methods that are directly overriden (specialized) by this method declaration.
 JFormalParameter[] parameters()
           
 void resolveExtMethods(CContextType context)
          Makes sure that all in-scope external generic functions are added to the appropriate augmentation maps before top method searches occur in later passes.
 void resolveSpecializers(CContextType context)
          Computes the values of specializer expressions used to dispatch on compile-time constants.
 void resolveTopMethods()
          Finds the top method of every declared method.
 CType returnType()
           
 void setModifiers(long modifiers)
          Sets the modifiers of this method declaration
 void setParameters(JFormalParameter[] parameters)
           
 void typecheck(CContextType context)
          Typechecks this method declaration.
 boolean usesMultipleDispatch()
          Indicates whether this method uses multiple dispatch
 
Methods inherited from interface org.multijava.mjc.JMemberDeclarationType
accept, genComments, getCClass, getField, getMethod, isDeprecated
 
Methods inherited from interface org.multijava.util.compiler.PhylumType
getTokenReference, setTokenReference
 
Methods inherited from interface org.multijava.javadoc.Annotatable
javadocComment
 

Method Detail

parameters

public JFormalParameter[] parameters()

setParameters

public void setParameters(JFormalParameter[] parameters)

addParameter

public void addParameter(JFormalParameter param)
Adds an additional formal parameter to this method, appending it to the end of the existing parameter list.

 requires param != null;
 


ident

public String ident()
Specified by:
ident in interface JMemberDeclarationType
Returns:
the identifier of the object being declared

returnType

public CType returnType()

getExceptions

public CClassType[] getExceptions()

modifiers

public long modifiers()
Specified by:
modifiers in interface JMemberDeclarationType
Returns:
the modifiers of this declaration

isDeclaredNonNull

public boolean isDeclaredNonNull()

setModifiers

public void setModifiers(long modifiers)
Sets the modifiers of this method declaration


body

public JBlock body()
WMD TODO remove WMD TODO remove


hasBody

public boolean hasBody()

usesMultipleDispatch

public boolean usesMultipleDispatch()
Indicates whether this method uses multiple dispatch

Returns:
true iff a parameter of this method has a dynamic dispatch annotation or, for an external method, this methods receiver is of a different type than the generic function's top method

compareTo

public int compareTo(Object o)
                       throws ClassCastException
Compares this method to a given method and returns 0 if the methods belong to the same generic function, otherwise returns -1 or +1 to sort the methods. This comparator is used to separate methods by generic function in the MJGenericFunctionDispatcher class.

Specified by:
compareTo in interface Comparable
Parameters:
o - the object to be compared against, must be a JMethodDeclarationType
Returns:
-1, +1, or 0
Throws:
ClassCastException - if o is not an instance of CType

isExternal

public boolean isExternal()
Indicates whether this member is external. Always returns false for this but is overridden for external subclasses.

Returns:
a flag indicating whether this member is external

isOverriding

public boolean isOverriding()
Return true if this method declaration overrides any of its superclass (or interfaces) method declarations.


overriddenMethods

public CMethodSet overriddenMethods()
Return the set of methods that are directly overriden (specialized) by this method declaration.


checkInterface

public CMember checkInterface(CContextType context)
                                throws PositionedError
Checks the basic interfaces to make sure things generally look OK. This pass gathers information about the type signatures of everything (imported class files, classes being compiled, methods, fields, etc...) needed for the later passes. This information is stored in a context hierarchy that is bound to the AST.

Returns:
a source code representation of the method, iff sub tree is correct enough to check code
Throws:
PositionedError - an error with reference to the source file

checkInterfaceType

public CSourceMethod checkInterfaceType(CContextType context,
                                        MemberAccess access,
                                        String ident)
                                          throws PositionedError
Performs the interface checks that are common to all sorts of methods. Gets the signatures of the return type, parameters and exceptions, and generates the source code representation, CSourceMethod.

Parameters:
context - the context in which this method appears
access - the MemberAccess object for this method
ident - the method name (passed as a parameter instead of using the field to properly handle constructors where the field is the class name but ident is <init>
Returns:
a source code representation of the method, iff sub tree is correct enough to check code
Throws:
PositionedError - an error with reference to the source file

resolveSpecializers

public void resolveSpecializers(CContextType context)
                                  throws PositionedError
Computes the values of specializer expressions used to dispatch on compile-time constants.

Parameters:
context - the context in which this class declaration appears
Throws:
PositionedError - if the check fails

resolveExtMethods

public void resolveExtMethods(CContextType context)
Makes sure that all in-scope external generic functions are added to the appropriate augmentation maps before top method searches occur in later passes.


resolveTopMethods

public void resolveTopMethods()
                                throws PositionedError
Finds the top method of every declared method. Called after the resolveSpecializers pass. This cannot be done before then because the external generic function mappings are not complete until the end of the checkInterface pass and the constant value specializers are not known until after the resolveSpecializers pass. This must be done before the typecheck pass so that all specialized argument positions for generic functions are known for ambiguity checking.

Throws:
PositionedError

createSelfContext

public CMethodContextType createSelfContext(CClassContextType parent)
Creates a context for this method declaration AST node.

Parameters:
parent - the parent context

typecheck

public void typecheck(CContextType context)
                        throws PositionedError
Typechecks this method declaration. Mutates the context to record the information gathered during the checks.

Parameters:
context - the context in which this method appears
Throws:
PositionedError - if the checks fail and the failure cannot be recovered from

checkOverriding

public void checkOverriding(CContextType context,
                            CMethodSet superMethods)
                              throws PositionedError
Checks that this method appropriately overrides the given superclass methods. The checks are those given in JLS2, section 8.4.6.3 and CLCM 00 4.1.3.1 (extended per Clifton's thesis).

Parameters:
context - the context in which this appears
superMethods - the super type methods that this may override
Throws:
PositionedError - if a check fails

JML

JML is Copyright (C) 1998-2002 by Iowa State University and is distributed under the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This release depends on code from the MultiJava project and is based in part on the Kopi project Copyright (C) 1990-99 DMS Decision Management Systems Ges.m.b.H.