JML

org.multijava.mjc
Class CSpecializedType

java.lang.Object
  extended byorg.multijava.util.Utils
      extended byorg.multijava.mjc.CSpecializedType
All Implemented Interfaces:
Cloneable, CTypeSignatureAppender

public class CSpecializedType
extends Utils
implements CTypeSignatureAppender

This class represents a specialized type like type1@type2.


Field Summary
private  CType dynamicType
           
static CSpecializedType[] EMPTY
           
private  boolean isSpecialized
           
private  CType staticType
           
 
Fields inherited from class org.multijava.util.Utils
DBG_LEVEL_HIGH, DBG_LEVEL_LOW, DBG_LEVEL_NO
 
Constructor Summary
CSpecializedType(CType type)
          Constructs a type specification without an explicit specializer.
CSpecializedType(CType staticType, CType specializerType)
          Constructs a specialized type specification.
 
Method Summary
 void appendGenericSignature(FastStringBuffer buff)
           
 void appendSignature(FastStringBuffer buff)
          Transforms this type to a string
 boolean couldOverload(CSpecializedType other)
          Checks whether a method with this specialized type in a parameter position could overload a method with other in the same position.
 CType dynamicType()
          Return the dynamic type of this specialized type.
static CType[] dynamicTypeTupleFrom(CSpecializedType[] specTypes)
          Converts the given array of specialized types to an array of the dynamic types of arguments sent to formals with these specialized types.
static CType[] dynamicTypeTupleFrom(CType recvType, CSpecializedType[] specTypes)
          Converts the given array of specialized types to an array of the dynamic types of arguments sent to formals with these specialized types.
 boolean equals(Object other)
           
 boolean equals(Object other, boolean enableUniv)
           
 boolean equals(Object other, CClassType[] args)
          Checks whether this specialized type is made up of the same pair of types as a given specialized type.
 boolean equals(Object other, CClassType[] args, boolean enableUniv)
           
 int getSize()
          Returns the size used in stack by value of this type
 int hashCode()
          Returns the hashcode for this.
 boolean isAlwaysAssignableTo(CSpecializedType dest, CClassType[] args)
          Is this type assignable to the given type by assignment type conversion [JLS2 5.2].
 boolean isSpecialized()
           
 boolean specializes(CSpecializedType other, CClassType[] args)
          Checks whether this specialized type is a specializing type for the given specialized type
 CType staticType()
          Returns the static type part of this specialized type.
static CType[] staticTypeTupleFrom(CType recvType, CSpecializedType[] specTypes)
          Converts the given array of specialized types to an array of the static type parts.
 String toString()
          Transforms this type to a string
 String toVerboseString()
          Transforms this type to a verbose string including universe annotations.
static CType[] tupleOfSpecializersFrom(CSpecializedType[] specTypes)
          Converts the given array of specialized types to an array of specializers.
static CType[] tupleOfSpecializersFrom(CSpecializedType[] specTypes, CClassType[] args)
           
 CSpecializedType unspecializedType()
          Returns an unspecialized type with the same static type as this.
static CSpecializedType[] unspecializedTypeTupleFrom(CSpecializedType[] specTypes)
          Converts the given array of specialized types to an array of unspecialized types.
static CSpecializedType[] unspecializedTypeTupleFrom(CType[] simpleTypes)
           
 
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

EMPTY

public static final CSpecializedType[] EMPTY

staticType

private CType staticType

dynamicType

private CType dynamicType

isSpecialized

private boolean isSpecialized
Constructor Detail

CSpecializedType

public CSpecializedType(CType type)
Constructs a type specification without an explicit specializer.


CSpecializedType

public CSpecializedType(CType staticType,
                        CType specializerType)
Constructs a specialized type specification.

Parameters:
staticType - the static type of the specification, must not be null
specializerType - the dynamic type of the specification, must not be null
Method Detail

staticType

public CType staticType()
Returns the static type part of this specialized type.


dynamicType

public CType dynamicType()
Return the dynamic type of this specialized type.


equals

public boolean equals(Object other,
                      CClassType[] args)
Checks whether this specialized type is made up of the same pair of types as a given specialized type.

Parameters:
other - another specialized type to compare with
Returns:
true iff this specialized type is made up of the same pair of types as other

equals

public boolean equals(Object other,
                      CClassType[] args,
                      boolean enableUniv)

equals

public boolean equals(Object other,
                      boolean enableUniv)

equals

public boolean equals(Object other)
Overrides:
equals in class Object

hashCode

public int hashCode()
Returns the hashcode for this.

Overrides:
hashCode in class Object
Returns:
the hashcode for this

specializes

public boolean specializes(CSpecializedType other,
                           CClassType[] args)
Checks whether this specialized type is a specializing type for the given specialized type

Parameters:
other - another specialized type to compare with
Returns:
true iff this specialized type specializes the type given by other

couldOverload

public boolean couldOverload(CSpecializedType other)
Checks whether a method with this specialized type in a parameter position could overload a method with other in the same position.


isSpecialized

public boolean isSpecialized()

toString

public String toString()
Transforms this type to a string

Overrides:
toString in class Object

toVerboseString

public String toVerboseString()
Transforms this type to a verbose string including universe annotations. Added by WMD.


unspecializedType

public CSpecializedType unspecializedType()
Returns an unspecialized type with the same static type as this.


appendSignature

public void appendSignature(FastStringBuffer buff)
Transforms this type to a string

Specified by:
appendSignature in interface CTypeSignatureAppender

appendGenericSignature

public void appendGenericSignature(FastStringBuffer buff)
Specified by:
appendGenericSignature in interface CTypeSignatureAppender

getSize

public int getSize()
Returns the size used in stack by value of this type


isAlwaysAssignableTo

public boolean isAlwaysAssignableTo(CSpecializedType dest,
                                    CClassType[] args)
Is this type assignable to the given type by assignment type conversion [JLS2 5.2].

Parameters:
dest - the destination type
Returns:
true iff assignment is valid

tupleOfSpecializersFrom

public static CType[] tupleOfSpecializersFrom(CSpecializedType[] specTypes)
Converts the given array of specialized types to an array of specializers.

Parameters:
specTypes - the formal parameters
Returns:
the tuple of specializers

tupleOfSpecializersFrom

public static CType[] tupleOfSpecializersFrom(CSpecializedType[] specTypes,
                                              CClassType[] args)

dynamicTypeTupleFrom

public static CType[] dynamicTypeTupleFrom(CSpecializedType[] specTypes)
Converts the given array of specialized types to an array of the dynamic types of arguments sent to formals with these specialized types. This method differs from the method tupleOfSpecializersFrom in that the dynamic type for a value specializer (e.g. int@@3) is the same as the static type.

Parameters:
specTypes - the formal parameters
Returns:
the dynamic type tuple

dynamicTypeTupleFrom

public static CType[] dynamicTypeTupleFrom(CType recvType,
                                           CSpecializedType[] specTypes)
Converts the given array of specialized types to an array of the dynamic types of arguments sent to formals with these specialized types. This method differs from the method tupleOfSpecializersFrom in that the dynamic type for a value specializer (e.g. int@@3) is the same as the static type.

Parameters:
recvType - the receiver type, or null
specTypes - the formal parameters
Returns:
the dynamic type tuple

staticTypeTupleFrom

public static CType[] staticTypeTupleFrom(CType recvType,
                                          CSpecializedType[] specTypes)
Converts the given array of specialized types to an array of the static type parts.

Parameters:
recvType - the receiver type, or null
specTypes - the formal parameters
Returns:
the tuple of specializers

unspecializedTypeTupleFrom

public static CSpecializedType[] unspecializedTypeTupleFrom(CSpecializedType[] specTypes)
Converts the given array of specialized types to an array of unspecialized types. That is, effectively forms the returned array by removing the explicit specializers from each item in the input array.


unspecializedTypeTupleFrom

public static CSpecializedType[] unspecializedTypeTupleFrom(CType[] simpleTypes)

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.