|
JML | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectorg.multijava.util.Utils
org.multijava.mjc.CMember
org.multijava.mjc.CMethod
This class represents an actual method, whether generated from source code or read from a class file. It includes the type signature of the method and operations for checking the method's applicability and whether it is more specfic than a given method.
| Field Summary | |
private boolean |
cachedPure
The pureness of this method. |
protected CContextType |
declarationContext
The context in which this method was declared. |
private CClassType[] |
exceptions
|
protected CMethod |
generatefrom
|
private int |
gfID
Integers used in bodyIdent() to give a unique name to a multimethod's associated $body method. |
private boolean |
isMixedPleomorphic
Indicates whether this method is pleomorphic with one external generic function and one or more internal generic functions. |
private int |
methodID
|
boolean |
needsPrivacyModifierRemoved
Indicates whether this method should have its privacy modifier removed for the purposes of code generation. |
private CMethodSet |
overriddenMethodSet
The set of methods overridden by this method, may be null. |
private CSpecializedType[] |
parameters
|
private boolean |
pureCached
Indicates if the pureness of this method has been calculated and cached in the field cachedPure. |
private boolean |
purityWasChanged
Indicates if the pureness of this method was inherited from a supermethod or a class/interface. |
private CClassType |
receiverType
|
private CType |
returnType
|
protected BitSet |
specArgs
If this is a top method, we record which arguments of the generic function are specialized. |
boolean |
synthetic
|
protected CMethod |
topConcreteMethod
The top concrete method of the generic function to which this belongs. |
private CTypeVariable[] |
typevariables
|
| Fields inherited from class org.multijava.mjc.CMember |
|
| Fields inherited from class org.multijava.util.Utils |
DBG_LEVEL_HIGH, DBG_LEVEL_LOW, DBG_LEVEL_NO |
| Constructor Summary | |
CMethod(MemberAccess access,
String ident,
CType returnType,
CSpecializedType[] parameters,
CClassType[] exceptions,
CTypeVariable[] typevariables,
boolean deprecated,
CContextType declarationContext)
Constructs a method member. |
|
| Method Summary | |
abstract CAmbiguousDispatcherClass |
ambiguousDispatcherClass()
Returns the ambiguous-method dispatcher class for this. |
abstract CClass |
anchorClass()
Returns the $anchor class for this generic function. |
boolean |
apparentlySpecializes(CMethod other)
|
boolean |
apparentlySpecializes(CMethod other,
CClassType[] args)
Checks whether this method apparently specializes a given method. |
boolean |
apparentlySpecializes(CMethod other,
CClassType[] args,
boolean enableUniv)
|
protected String |
bodyGenericSignature()
|
protected String |
bodyIdent()
|
protected String |
bodySignature()
|
int |
compareTo(Object o)
Allows methods to be sorted. |
CContextType |
declarationContext()
Returns the declaration context. |
abstract CDispatcherSignature |
dispatcherSignature()
Returns the $signature class for this. |
boolean |
equalParameters(CMethod other)
Returns true if the given method and
this method have parameters with the same types. |
boolean |
equalParametersNoUniverses(CMethod other)
|
boolean |
equals(Object other)
Returns true if the given object is a CMethod and
the two methods have same signature. |
abstract int |
functionNumber()
Returns the function field number for this generic function within its $anchor class. |
boolean |
genDispatch(CodeSequence code,
CodeLabel nextAlternative,
CMethod topConcreteMethod,
String dispatcherName)
Generates the dispatch code for the specialized arguments of this method. |
GenericFunctionInfo |
genGenericFunctionInfo()
Generates the generic function information for this required when generating a class file, or returns null if this method requires no such information. |
void |
genGenFuncInvocation(CodeSequence code,
boolean nonVirtual)
Generates a sequence of bytecode for invoking this method, assuming appropriate argument values have already been pushed to the JVM stack. |
ArrayList |
genMethodInfo()
Generate the method information for this for constructing a class file [JVM2 4.6]. |
CMethod |
getGenerateFrom()
|
String |
getGenericSignature()
|
CMethod |
getMethod()
|
String |
getSignature()
Returns the bytecode type signature of this method as seen by callers. |
BitSet |
getSpecArgs()
Return the bit set indicating which arguments of the associated generic function are specialized. |
CTypeVariable[] |
getTypeVariable()
|
int |
hashCode()
Returns the hash code for this, calculated from the hash codes of the methods identifier, receiver, and argument types. |
boolean |
hasSameSignature(CMethod other)
Has this method the same signature as the one given as argument ? |
boolean |
hasSameSignature(CMethod other,
CClassType[] substitution)
Has this method the same signature as the one given as argument ? |
boolean |
hasSameSignatureNoUniverses(CMethod other)
|
boolean |
isAbstract()
Returns true iff this method is abstract. |
boolean |
isApplicable(String ident,
CType recvType,
CType[] actuals,
CClassType[] args)
Returns true if this method is applicable to a method call with the given identifier and actual (static) argument types. |
private boolean |
isApplicableArgTypes(CType recvType,
CType[] actuals,
boolean initStyleCheck,
CClassType[] args)
Returns true if the given actual argument types are assignable to this methods formals and receiver. |
boolean |
isConstructor()
Returns true iff this method is a constructor. |
boolean |
isExternal()
Indicates whether this method is external, i.e., whether its host is different than its logical owner. |
boolean |
isGenericMethod()
whether this method is generic or not |
boolean |
isInExternalGF()
Indicates whether this method belongs to an external generic function. |
boolean |
isLocalTo(CContextType context)
Indicates whether this method is declared local to the given context. |
boolean |
isMixedPleomorphic()
Indicates whether this method is pleomorphic with one external generic function and one or more internal generic functions. |
boolean |
isMoreSpecificThan(CMethod other)
|
boolean |
isMoreSpecificThan(CMethod other,
boolean b)
|
boolean |
isMoreSpecificThan(CMethod other,
CClassType[] args)
Returns true if this method is strictly more specific than the given method. |
boolean |
isMoreSpecificThan(CMethod other,
CClassType[] args,
boolean intrsDoNotExtendObject)
Returns true if this method is strictly more specific than the given method. |
boolean |
isMoreSpecificThan(CMethod other,
CClassType[] args,
boolean intrsDoNotExtendObject,
boolean enableUniv)
|
boolean |
isNative()
Returns true iff this method is native. |
boolean |
isPure()
Returns true if this method is pure. |
private boolean |
isPureInherited()
Returns true if this method inherits pureness from its owner or supertypes, including both superclasses and interfaces. |
boolean |
isSynthetic()
|
CTypeVariable |
lookupTypeVariable(String ident)
|
protected String |
mmGenericSignature()
|
protected String |
mmSignature()
Returns the type signature of this method in the multimethod descriptor format, which is like a regular bytecode method descriptor but includes explicit specializers. |
protected CMethodSet |
overriddenMethodSet()
Returns the set of methods overridden by this method, may be null. |
CSpecializedType[] |
parameters()
Returns the static and dynamic types of this methods parameters. |
int |
parametersSize()
Returns the size (in stack slots) of the parameters of this. |
abstract void |
plantFunctionRef(CodeSequence code)
Generates bytecode to put a reference to the external function field for the external generic function
on the JVM stack. |
protected void |
plantMMInvocation(CodeSequence code,
String dispatcherName)
Plants an invocation of the multimethod body represented by this. |
abstract void |
plantOldFunctionRef(CodeSequence code,
boolean forSuper,
boolean fromOuter)
Generates bytecode to put a reference to the oldFunction field for the external generic function
on the JVM stack. |
protected void |
plantSelfArguments(CodeSequence code,
CMethod topConcreteMethod)
Plants bytecode to push the arguments for a call to this multimethod body from within a dispatcher of this generic function. |
boolean |
purityWasChanged()
This method can be used to determine that the purity of this method was not given explicitly by the programmer, but inherited from an overridden method or the class/interface. |
CType |
receiverType()
Returns the type of this methods receiver. |
CType |
returnType()
|
void |
setGenerateFrom(CMethod me)
|
void |
setIDs(int gfID,
int mID)
Set the method's gfID and methodID, used to give its associated $body method (if any) a unique name. |
protected void |
setIsMixedPleomorphic()
Indicates that this method is pleomorphic with one external generic function and one or more internal generic functions. |
CMethodSet |
setOverriddenMethodSet()
A version that uses default parameters. |
protected CMethodSet |
setOverriddenMethodSet(CClassType[] args,
ArrayList needbridge,
CContextType context)
Calculates and returns the set of methods overridden by this method. |
protected void |
setParameters(CSpecializedType[] parameters)
|
protected void |
setReturnType(CType type)
|
void |
setSynthetic(boolean syn)
|
void |
setThrowables(Set throwables)
Set the exceptions that may be thrown by this method. |
boolean |
specializes(CMethod other)
Checks whether this method specializes a given method. |
protected void |
swallowReceiver()
Swallow the receiver, which is passed as the first argument to an external generic function. |
CClassType[] |
throwables()
|
CMethod |
topConcreteMethod()
Finds the top concrete method of the generic function to which this belongs. |
String |
toString()
Returns a human-readable string representation of this method signature. |
protected String |
toString(boolean omitReceiver)
Utility method allows the generation of a string representation of this with or without the receiver type. |
| Methods inherited from class org.multijava.mjc.CMember |
access, addModifiers, deprecated, getCClass, getCCompilationUnit, getField, getIdent, getJavaName, getOwnerName, getQualNameWithSeparator, hasDefaultAccess, hasProtectedVisibilityIn, host, ident, isAccessibleFrom, isDeclaredNonNull, isDeprecated, isFinal, isLocalTo, isPrivate, isProtected, isPublic, isStatic, modifiers, owner, qualifiedName, setModifiers |
| Methods inherited from class org.multijava.util.Utils |
assertTrue, assertTrue, combineArrays, escapeString, escapeString, fail, fail, getFilePath, hasFlag, hasOtherFlags, parsePathParts, relativePathTo, splitQualifiedName, splitQualifiedName, stripJavaModifiers, stripNonJavaModifiers, stripPrivateModifier, unescapeString, vectorToArray, vectorToIntArray |
| Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
private boolean cachedPure
private boolean pureCached
cachedPure.
private boolean purityWasChanged
private CMethodSet overriddenMethodSet
private CClassType receiverType
private CType returnType
private CSpecializedType[] parameters
private CClassType[] exceptions
protected CContextType declarationContext
protected CMethod topConcreteMethod
protected BitSet specArgs
private boolean isMixedPleomorphic
public boolean needsPrivacyModifierRemoved
private int gfID
private int methodID
private CTypeVariable[] typevariables
protected CMethod generatefrom
public boolean synthetic
| Constructor Detail |
public CMethod(MemberAccess access,
String ident,
CType returnType,
CSpecializedType[] parameters,
CClassType[] exceptions,
CTypeVariable[] typevariables,
boolean deprecated,
CContextType declarationContext)
access - contains the info used to determine accessibility of this methodident - the ident of this methodreturnType - the return type of this methodparameters - the parameters type of this methodexceptions - a list of all exceptions of the throws listdeprecated - is this method deprecateddeclarationContext - the context in which this method is declared| Method Detail |
public CContextType declarationContext()
public CType receiverType()
public CMethod getMethod()
getMethod in class CMemberpublic final CType returnType()
public final CSpecializedType[] parameters()
public final int parametersSize()
protected final void setParameters(CSpecializedType[] parameters)
protected final void setReturnType(CType type)
public String getSignature()
public String getGenericSignature()
public CClassType[] throwables()
public void setThrowables(Set throwables)
throwables - the exceptions that can be thrown by this method
public boolean isInExternalGF()
throws UnpositionedError
UnpositionedError - if the top method of the generic function
is ambiguous
assignable topConcreteMethod;
public boolean hasSameSignature(CMethod other,
CClassType[] substitution)
other - the method to compare topublic boolean equalParametersNoUniverses(CMethod other)
public boolean hasSameSignatureNoUniverses(CMethod other)
public boolean hasSameSignature(CMethod other)
other - the method to compare to
public CMethod topConcreteMethod()
throws UnpositionedError
requires topConcreteMethod != null || declarationContext != null || (* this is overridden in subclass to not depend on declarationContext *); assignable topConcreteMethod; ensures topConcreteMethod != null;
UnpositionedErrorpublic BitSet getSpecArgs()
public void setIDs(int gfID,
int mID)
public boolean isNative()
public boolean isAbstract()
public boolean isConstructor()
public boolean isExternal()
public boolean isLocalTo(CContextType context)
context - the context in which to check
protected void setIsMixedPleomorphic()
public boolean isMixedPleomorphic()
public boolean equalParameters(CMethod other)
method and
this method have parameters with the same types.
other - the CMethod to compare this to public boolean equals(Object other)
CMethod and
the two methods have same signature.
equals in class Objectother - the object to compare this topublic int hashCode()
hashCode in class Objectpublic int compareTo(Object o)
compareTo in interface Comparableo - the method to be compared with
public boolean isApplicable(String ident,
CType recvType,
CType[] actuals,
CClassType[] args)
ident - the identifier to matchrecvType - receiver type actuals - the method call static argument types
private boolean isApplicableArgTypes(CType recvType,
CType[] actuals,
boolean initStyleCheck,
CClassType[] args)
recvType - receiver typeactuals - the method call static argument typesinitStyleCheck - if true then perform an initializer
applicability check (i.e., receiver types
must be equal), otherwise perform a pointwise
subtype check on the argument type tuples
public boolean isMoreSpecificThan(CMethod other,
CClassType[] args)
other - the method to compare to
other public boolean isMoreSpecificThan(CMethod other)
public boolean isMoreSpecificThan(CMethod other,
boolean b)
public boolean isMoreSpecificThan(CMethod other,
CClassType[] args,
boolean intrsDoNotExtendObject)
other - the method to compare tointrsDoNotExtendObject - true if we should not treat interfaces
as inheriting from Object
other
public boolean isMoreSpecificThan(CMethod other,
CClassType[] args,
boolean intrsDoNotExtendObject,
boolean enableUniv)
public boolean apparentlySpecializes(CMethod other,
CClassType[] args)
Checks whether this method apparently specializes a given
method. This method apparently specializes other
iff this method is more specific than other, the
two methods' static parameter types are identical, and the
receiver type of this is a (possibly reflexive) subtype of the
receiver type of other.
This relationship is apparently because
other is not necessarily visible to this. For
example, other could be a method of an external
generic function that is not imported in the context of the
declaration of this.
other - the method to compare to
otherspecializes(CMethod)
public boolean apparentlySpecializes(CMethod other,
CClassType[] args,
boolean enableUniv)
public boolean apparentlySpecializes(CMethod other)
public boolean specializes(CMethod other)
throws UnpositionedError
Checks whether this method specializes a given method. This
method specializes other iff this method
apparently specializes other, and the two methods
have belong to the same generic function as determined by their
top methods.
other - the method to compare to
requires other != null; assignable topConcreteMethod, other.topConcreteMethod; ensures \result <==> this.topConcreteMethod == other.topConcreteMethod && this.apparentlySpecializes( other );
other
UnpositionedError - if the top method of either this or
other is ambiguousapparentlySpecializes(CMethod)public String toString()
toString in class Objectprotected String toString(boolean omitReceiver)
public CTypeVariable[] getTypeVariable()
public boolean isGenericMethod()
public CTypeVariable lookupTypeVariable(String ident)
public boolean isPure()
pure modifier or it
inherits pureness from its owner or supertypes. A non-static
method (including a constructor) is pure if its owner class or
interface is pure, or if it overrides a pure method inherited
from supertypes (classes and interfaces).
public boolean purityWasChanged()
private boolean isPureInherited()
public CMethodSet setOverriddenMethodSet()
throws UnpositionedError
UnpositionedError
protected CMethodSet setOverriddenMethodSet(CClassType[] args,
ArrayList needbridge,
CContextType context)
throws UnpositionedError
overriddenMethodSet().
UnpositionedErrorprotected CMethodSet overriddenMethodSet()
protected void swallowReceiver()
requires topConcreteMethod != null && topConcreteMethod.isExternal(); assignable parameters; ensures parameters.length == \old(parameters).length + 1; ensures parameters[0].staticType() == topConcreteMethod.receiverType(); ensures parameters[0].dynamicType() == this.receiverType();
public void genGenFuncInvocation(CodeSequence code,
boolean nonVirtual)
code - the code sequencenonVirtual - force non-virtual dispatching if possible (ignored if
this method belongs to an interface or is external)
requires topConcreteMethod != null;
public abstract void plantFunctionRef(CodeSequence code)
function field for the external generic function
on the JVM stack.
requires this.isExternal();
public abstract void plantOldFunctionRef(CodeSequence code,
boolean forSuper,
boolean fromOuter)
oldFunction field for the external generic function
on the JVM stack.
requires this.isExternal();
code - the code sequence to add the bytecode toforSuper - if true, then this is for a super send, which,
under RMJ, should start from the oldSuperFunction
rather than oldFunctionfromOuter - if true, then generates a reference that works from the
outer class context, otherwise generates a reference that
works from within the dispatcher classpublic abstract CDispatcherSignature dispatcherSignature()
requires this.isExternal();
public abstract CAmbiguousDispatcherClass ambiguousDispatcherClass()
requires this.isExternal();
public abstract CClass anchorClass()
requires this.isExternal();
public abstract int functionNumber()
requires this.isExternal();
public boolean genDispatch(CodeSequence code,
CodeLabel nextAlternative,
CMethod topConcreteMethod,
String dispatcherName)
if ( !(this is applicable) ) then goto nextAlternative;
execute this method body;
protected void plantSelfArguments(CodeSequence code,
CMethod topConcreteMethod)
protected void plantMMInvocation(CodeSequence code,
String dispatcherName)
protected String bodyIdent()
protected String bodySignature()
protected String bodyGenericSignature()
protected String mmSignature()
protected String mmGenericSignature()
public ArrayList genMethodInfo()
MethodInfo, just a single element
here, but overridden in CSourceDispatcherMethod to include
separate elements for the dispatcher and each multimethod bodypublic GenericFunctionInfo genGenericFunctionInfo()
public CMethod getGenerateFrom()
public void setGenerateFrom(CMethod me)
public boolean isSynthetic()
public void setSynthetic(boolean syn)
|
JML | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||