polyglot.ext.jl.types
Class MethodInstance_c

java.lang.Object
  extended by polyglot.ext.jl.types.TypeObject_c
      extended by polyglot.ext.jl.types.ProcedureInstance_c
          extended by polyglot.ext.jl.types.MethodInstance_c
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, CodeInstance, MemberInstance, MethodInstance, ProcedureInstance, TypeObject, Copy
Direct Known Subclasses:
CofferMethodInstance_c

public class MethodInstance_c
extends ProcedureInstance_c
implements MethodInstance

A MethodInstance represents the type information for a Java method.

See Also:
Serialized Form

Field Summary
protected  java.lang.String name
           
protected  Type returnType
           
 
Fields inherited from class polyglot.ext.jl.types.ProcedureInstance_c
container, excTypes, flags, formalTypes
 
Fields inherited from class polyglot.ext.jl.types.TypeObject_c
position, ts
 
Constructor Summary
protected MethodInstance_c()
          Used for deserializing types.
  MethodInstance_c(TypeSystem ts, Position pos, ReferenceType container, Flags flags, Type returnType, java.lang.String name, java.util.List formalTypes, java.util.List excTypes)
           
 
Method Summary
 boolean canOverride(MethodInstance mj)
          Return true if this method can override mi, false otherwise.
 boolean canOverrideImpl(MethodInstance mj)
          Leave this method in for historic reasons, to make sure that extensions modify their code correctly.
 boolean canOverrideImpl(MethodInstance mj, boolean quiet)
          Return true if this method can override mi.
 void checkOverride(MethodInstance mj)
          Return true if this method can override mi, throws a SemanticException otherwise.
 MethodInstance container(ReferenceType container)
          Set the method's containing type.
 java.lang.String designator()
          Returns either "method" or "constructor".
 boolean equalsImpl(TypeObject o)
          Default implementation is pointer equality.
 MethodInstance flags(Flags flags)
          Set the method's flags.
 MethodInstance formalTypes(java.util.List l)
          Set the method's formal parameter types.
 int hashCode()
           
 java.util.List implemented()
          Get the set of methods this method implements.
 java.util.List implementedImpl(ReferenceType rt)
          Get the set of methods in rt and its superinterfaces that this method implements.
 boolean isCanonical()
          Return true if the type object contains no unknown/ambiguous types.
 boolean isSameMethod(MethodInstance m)
          Returns true iff is the same method as
 boolean isSameMethodImpl(MethodInstance m)
          Returns true iff is the same method as
 boolean methodCallValid(java.lang.String name, java.util.List argTypes)
          Return true if this method can be called with name name and actual parameters of types actualTypes.
 boolean methodCallValidImpl(java.lang.String name, java.util.List argTypes)
          Return true if this method can be called with name name and actual parameters of types actualTypes.
 java.lang.String name()
          The method's name.
 MethodInstance name(java.lang.String name)
          Set the method's name.
 java.util.List overrides()
          Get the list of methods this method (potentially) overrides, in order from this class (i.e., including this) to super classes.
 java.util.List overridesImpl()
          Get the list of methods this method (potentially) overrides, in order from this class (i.e., including this) to super classes.
 Type returnType()
          The method's return type.
 MethodInstance returnType(Type returnType)
          Set the method's return type.
 java.lang.String signature()
          Returns a String representing the signature of the procedure.
 MethodInstance throwTypes(java.util.List l)
          Set the method's exception throw types.
 java.lang.String toString()
           
 
Methods inherited from class polyglot.ext.jl.types.ProcedureInstance_c
callValid, callValidImpl, container, flags, formalTypes, hasFormals, hasFormalsImpl, listIsCanonical, moreSpecific, moreSpecificImpl, throwsSubset, throwsSubsetImpl, throwTypes
 
Methods inherited from class polyglot.ext.jl.types.TypeObject_c
copy, equals, position, typeSystem
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface polyglot.types.ProcedureInstance
callValid, callValidImpl, formalTypes, hasFormals, hasFormalsImpl, moreSpecific, moreSpecificImpl, throwsSubset, throwsSubsetImpl, throwTypes
 
Methods inherited from interface polyglot.types.MemberInstance
container, flags
 
Methods inherited from interface polyglot.types.TypeObject
position, typeSystem
 
Methods inherited from interface polyglot.util.Copy
copy
 

Field Detail

name

protected java.lang.String name

returnType

protected Type returnType
Constructor Detail

MethodInstance_c

protected MethodInstance_c()
Used for deserializing types.


MethodInstance_c

public MethodInstance_c(TypeSystem ts,
                        Position pos,
                        ReferenceType container,
                        Flags flags,
                        Type returnType,
                        java.lang.String name,
                        java.util.List formalTypes,
                        java.util.List excTypes)
Method Detail

flags

public MethodInstance flags(Flags flags)
Description copied from interface: MethodInstance
Set the method's flags.

Specified by:
flags in interface MethodInstance

name

public java.lang.String name()
Description copied from interface: MethodInstance
The method's name.

Specified by:
name in interface MethodInstance

name

public MethodInstance name(java.lang.String name)
Description copied from interface: MethodInstance
Set the method's name.

Specified by:
name in interface MethodInstance

returnType

public Type returnType()
Description copied from interface: MethodInstance
The method's return type.

Specified by:
returnType in interface MethodInstance

returnType

public MethodInstance returnType(Type returnType)
Description copied from interface: MethodInstance
Set the method's return type.

Specified by:
returnType in interface MethodInstance

formalTypes

public MethodInstance formalTypes(java.util.List l)
Description copied from interface: MethodInstance
Set the method's formal parameter types.

Specified by:
formalTypes in interface MethodInstance
Parameters:
l - A list of Type.
See Also:
Type

throwTypes

public MethodInstance throwTypes(java.util.List l)
Description copied from interface: MethodInstance
Set the method's exception throw types.

Specified by:
throwTypes in interface MethodInstance
Parameters:
l - A list of Type.
See Also:
Type

container

public MethodInstance container(ReferenceType container)
Description copied from interface: MethodInstance
Set the method's containing type.

Specified by:
container in interface MethodInstance

hashCode

public int hashCode()
Overrides:
hashCode in class ProcedureInstance_c

equalsImpl

public boolean equalsImpl(TypeObject o)
Description copied from class: TypeObject_c
Default implementation is pointer equality.

Specified by:
equalsImpl in interface TypeObject
Overrides:
equalsImpl in class ProcedureInstance_c
See Also:
TypeObject_c.equalsImpl(TypeObject), Object.hashCode()

toString

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

signature

public java.lang.String signature()
Description copied from interface: ProcedureInstance
Returns a String representing the signature of the procedure. This includes just the name of the method (or name of the class, if it is a constructor), and the argument types.

Specified by:
signature in interface ProcedureInstance

designator

public java.lang.String designator()
Description copied from interface: ProcedureInstance
Returns either "method" or "constructor".

Specified by:
designator in interface ProcedureInstance

isSameMethod

public final boolean isSameMethod(MethodInstance m)
Returns true iff is the same method as

Specified by:
isSameMethod in interface MethodInstance

isSameMethodImpl

public boolean isSameMethodImpl(MethodInstance m)
Returns true iff is the same method as

Specified by:
isSameMethodImpl in interface MethodInstance

isCanonical

public boolean isCanonical()
Description copied from interface: TypeObject
Return true if the type object contains no unknown/ambiguous types.

Specified by:
isCanonical in interface TypeObject

methodCallValid

public final boolean methodCallValid(java.lang.String name,
                                     java.util.List argTypes)
Description copied from interface: MethodInstance
Return true if this method can be called with name name and actual parameters of types actualTypes.

Specified by:
methodCallValid in interface MethodInstance
Parameters:
name - The method to call.
argTypes - A list of argument types of type Type.
See Also:
Type

methodCallValidImpl

public boolean methodCallValidImpl(java.lang.String name,
                                   java.util.List argTypes)
Description copied from interface: MethodInstance
Return true if this method can be called with name name and actual parameters of types actualTypes. This method should not be called except by TypeSystem and by subclasses.

Specified by:
methodCallValidImpl in interface MethodInstance

overrides

public java.util.List overrides()
Description copied from interface: MethodInstance
Get the list of methods this method (potentially) overrides, in order from this class (i.e., including this) to super classes.

Specified by:
overrides in interface MethodInstance
Returns:
A list of MethodInstance, starting with this. Note that this list does not include methods declared in interfaces. Use implemented for that.
See Also:
MethodInstance

overridesImpl

public java.util.List overridesImpl()
Description copied from interface: MethodInstance
Get the list of methods this method (potentially) overrides, in order from this class (i.e., including this) to super classes. This method should not be called except by TypeSystem and by subclasses.

Specified by:
overridesImpl in interface MethodInstance
Returns:
A list of MethodInstance, starting with this.
See Also:
MethodInstance

canOverride

public final boolean canOverride(MethodInstance mj)
Description copied from interface: MethodInstance
Return true if this method can override mi, false otherwise.

Specified by:
canOverride in interface MethodInstance

checkOverride

public final void checkOverride(MethodInstance mj)
                         throws SemanticException
Description copied from interface: MethodInstance
Return true if this method can override mi, throws a SemanticException otherwise.

Specified by:
checkOverride in interface MethodInstance
Throws:
SemanticException

canOverrideImpl

public final boolean canOverrideImpl(MethodInstance mj)
                              throws SemanticException
Leave this method in for historic reasons, to make sure that extensions modify their code correctly.

Throws:
SemanticException

canOverrideImpl

public boolean canOverrideImpl(MethodInstance mj,
                               boolean quiet)
                        throws SemanticException
Description copied from interface: MethodInstance
Return true if this method can override mi. This method should not be called except by TypeSystem and by subclasses. If quiet is true and this method cannot override mi, then false is returned; otherwise, if quiet is false and this method cannot override mi, then a SemanticException is thrown.

Specified by:
canOverrideImpl in interface MethodInstance
Parameters:
quiet - If true, then no Semantic Exceptions will be thrown, and the return value will be true or false. Otherwise, if the method cannot override, then a SemanticException will be thrown, else the method will return true.
Throws:
SemanticException

implemented

public java.util.List implemented()
Description copied from interface: MethodInstance
Get the set of methods this method implements. No ordering is specified since the superinterfaces need not form a linear list (i.e., they can form a tree).

Specified by:
implemented in interface MethodInstance
Returns:
List[MethodInstance]

implementedImpl

public java.util.List implementedImpl(ReferenceType rt)
Description copied from interface: MethodInstance
Get the set of methods in rt and its superinterfaces that this method implements. No ordering is specified.

Specified by:
implementedImpl in interface MethodInstance
Parameters:
rt - The point in the type hierarchy to begin looking for methods.
Returns:
List[MethodInstance]