|
mjc | ||||||||||
| 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.CType
org.multijava.mjc.CClassType
This class represents a class type in the type structure.
CType| Nested Class Summary |
| Nested classes inherited from class org.multijava.mjc.CType |
CType.MethodSignature, CType.MethodSignatureParser, CType.StringBuffers, CType.TupleCollection |
| Field Summary | |
protected CClassType[][] |
arguments
|
private static CClass |
BAC_CLASS
|
private String |
cachedString
|
private CClass |
clazz
|
static CClassType[] |
EMPTY
|
static CClassType[][] |
EMPTY_ARG
|
protected int |
index
|
protected CUniverse |
universe
Stores the universe modifier that is attached with this class type. |
| Fields inherited from class org.multijava.mjc.CType |
instance, isMethodTypeVariable, isTypeVariable, type |
| Fields inherited from class org.multijava.util.Utils |
DBG_LEVEL_HIGH, DBG_LEVEL_LOW, DBG_LEVEL_NO |
| Constructor Summary | |
protected |
CClassType()
Construct a class type |
|
CClassType(CClass clazz)
Construct a class type with the default universe. |
|
CClassType(CClass clazz,
CUniverse univ)
Construct a class type with a universe. |
| Method Summary | |
void |
appendSignature(FastStringBuffer buff)
Transforms this type to a string |
CClassType |
capture()
Returns the type captured by a type argument. |
CType |
checkType(CContextType context)
Checks that this type is valid, throwing an exception if it is not. |
Object |
clone()
We need to allow cloning of CClassType and its subtypes, in order to be able to create a new CClassType with the correct universe modifier. |
boolean |
contains(CClassType type)
Returns whether this type contains the given type as defined in JLS3 4.5.1.1. |
CClassType |
createSubstitutedType(CClass local,
CClassType prefixType,
CClassType[][] substitution)
|
private boolean |
descendsFrom(CClassType maybeSuper)
Returns whether this type descends from the given maybeSuper
type. |
Collection |
directlyVisibleTypes()
Returns the set of types (excluding non-reference types) that are directly visible from this type. |
boolean |
equals(Object other)
Compares two objects for equality. |
boolean |
equals(Object other,
boolean enableUniv)
Compares two objects for equality. |
boolean |
equals(CType other,
CClassType[] substitution)
|
boolean |
equals(CType other,
CClassType[] substitution,
boolean enableUniv)
|
CClassType[][] |
getAllArguments()
return the arguments of this type |
CClassType[] |
getArguments()
|
private CClass |
getCachedCClass()
Get source class from cached info of all loaded classes in CTopLevel. |
CClass |
getCClass()
Returns the class object associated with this type. |
CUniverse |
getCUniverse()
Return the universe of this class type. |
String |
getCUniverseJMLString()
Return the universe modifier as string, for output in JML specifications. |
String |
getCUniverseMJString()
Returns the universe modifier as String, for output in source code parsed by MultiJava, i.e. the modifiers are written as is. |
String |
getCUniverseString()
Return the universe modifier as string. |
CType |
getErasure()
|
int |
getIndex()
|
int |
getSize()
Returns the size used in stack by value of this type |
byte |
getUniverseByteConstant()
Return the universe byte constant for this class type. |
static Collection |
getVisibleTypesFrom(Collection dirVisTypes)
Returns the set of visible types by finding the reflexive, transitive closure of directlyVisibleTypes() on each type in the given collection. |
int |
hashCode()
Calculates the hash code for this |
boolean |
hasUnboundedWildcardTypeArgumentsOnly()
Returns true if and only if this is a parameterized type
and all its type arguments are unbounded wildcards. |
boolean |
hasWildcardTypeArgument()
Returns whether any of the type arguments of this type is a wildcard. |
String |
ident()
|
boolean |
implicitlyCastTo(CType dest)
implicitlyCastTo |
boolean |
isAlwaysAssignableTo(CType dest)
|
boolean |
isAlwaysAssignableTo(CType dest,
boolean inst)
Is this type assignable to the given type by assignment type conversion [JLS2 5.2] [JLS2 5.1.4] |
boolean |
isAlwaysAssignableTo(CType dest,
CClassType[] substitution)
|
boolean |
isAlwaysAssignableToNoUniverses(CType dest,
CClassType[] substitution)
A version of the Assignable check without considering the Universe types. |
boolean |
isAssignableTo(CType dest)
|
boolean |
isCastableTo(CType dest)
Can this type be converted to the specified type by casting conversion (JLS 5.5) ? |
protected boolean |
isChecked()
Returns true if this class type has been resolved to a CClass singleton. |
boolean |
isCheckedException()
Returns true if this represents the type of a checked exception. |
boolean |
isClassType()
Check if a type is a class type |
boolean |
isConcrete()
Indicates whether this type is concrete. |
boolean |
isInterface()
Check if a type is an interface |
boolean |
isLocalTo(CContextType context)
Indicates whether this type is declared local to the given context. |
boolean |
isNestedType()
Indicates whether this type is a nested type, i.e., a member type. |
boolean |
isParameterizedType()
Returns whether this is a parameterized type (JLS3 4.5). |
boolean |
isRawTypeInvocationOf(CClass superClazz)
Returns whether this type is a raw type invocation of the given superClazz. |
private boolean |
isRawTypeInvocationOfRec(CClass superClazz,
CClassType type,
boolean isRawType)
Helper method which goes up the supertype hierarchy in order to find out whether the given type is a raw type invocation of the
given superClazz. |
private boolean |
isRawTypeInvocationOfSuper(CClass superClazz,
CClassType superType,
boolean isRawType)
Helper method which takes the step from a type to its supertype in order to find out whether the latter is a raw type invocation of the given superClazz. |
boolean |
isReference()
Check if a type is a reference |
boolean |
isValidTypeArgumentFor(CTypeVariable typeVariable,
CClassType[] substitution)
Returns whether this type is a valid type argument for the given typeVariable. |
boolean |
needsUncheckedConversion(CType dest)
Returns whether unchecked conversion (JLS3 5.1.9) is required in order to convert from this type to the given type dest. |
boolean |
needsUncheckedConversion(CType dest,
CClassType[] substitution)
Returns whether unchecked conversion (JLS3 5.1.9) is required in order to convert from this type to the given type dest, eventually
using the given generic substitution. |
String |
originalQualifiedName()
|
void |
plantDispatchTest(CodeSequence code,
CodeLabel nextInstruction)
|
String |
printArgs()
|
String |
qualifiedName()
|
void |
resolveValueType(CExpressionContextType context)
Compute the value of a specializer expression used to dispatch on a compile-time constant. |
void |
setAllArguments(CClassType[][] arguments)
|
protected void |
setClass(CClass clazz)
Sets the CClass singleton that goes with this class type. |
void |
setCUniverse(CUniverse univ)
Set the universe of this class type. |
void |
setIndex(int i)
set the type variable to the given index |
String |
toString()
Transforms this type to a string |
String |
toVerboseString()
Return the universe modifier plus the class type as string. |
| 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 |
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
public static final CClassType[] EMPTY
public static final CClassType[][] EMPTY_ARG
private static final CClass BAC_CLASS
private CClass clazz
protected int index
protected CClassType[][] arguments
protected CUniverse universe
private String cachedString
| Constructor Detail |
protected CClassType()
public CClassType(CClass clazz)
public CClassType(CClass clazz,
CUniverse univ)
clazz - the class that will represent this type| Method Detail |
protected boolean isChecked()
public int getIndex()
public void setIndex(int i)
protected void setClass(CClass clazz)
clazz - the CClass singleton that goes with this class typepublic void setCUniverse(CUniverse univ)
univ - The new universe modifier.
If the parameter is null, then the peer modifier is used.
public Object clone()
throws CloneNotSupportedException
clone in class ObjectCloneNotSupportedExceptionpublic boolean equals(Object other)
equals in class CTypeother - the object to compare with
other is a CType object
representing the same Java type as this represents
WMD: Forward the call to the universe enabled version below.
public boolean equals(Object other,
boolean enableUniv)
equals in class CTypeother - the object to compare withenableUniv - whether to also check the universe part
this is needed sometimes to allow relaxed checks
other is a CType object
representing the same Java type as this represents
public boolean equals(CType other,
CClassType[] substitution)
equals in class CType
public boolean equals(CType other,
CClassType[] substitution,
boolean enableUniv)
equals in class CTypepublic int hashCode()
hashCode in class Objectalso assignable loadedClassInfo, thisClassInfo;
public String toString()
also assignable loadedClassInfo, thisClassInfo; ensures \not_modified(loadedClassInfo);
toString in class CTypepublic String printArgs()
public String originalQualifiedName()
public String toVerboseString()
toVerboseString in class CTypepublic String getCUniverseString()
public String getCUniverseJMLString()
public String getCUniverseMJString()
public boolean isNestedType()
isNestedType in class CTypepublic void appendSignature(FastStringBuffer buff)
appendSignature in interface CTypeSignatureAppenderpublic String ident()
assignable loadedClassInfo, thisClassInfo;
public String qualifiedName()
public int getSize()
public boolean isReference()
isReference in class CTypepublic boolean isClassType()
isClassType in class CTypepublic boolean isInterface()
isInterface in class CTypealso assignable loadedClassInfo, thisClassInfo;
public boolean isConcrete()
isConcrete in class CTypealso assignable loadedClassInfo, thisClassInfo;
public boolean isLocalTo(CContextType context)
isLocalTo in class CTypecontext - the context in which to check
also assignable loadedClassInfo, thisClassInfo;
public CClass getCClass()
getCClass in class CTypepublic CUniverse getCUniverse()
public byte getUniverseByteConstant()
public CClassType createSubstitutedType(CClass local,
CClassType prefixType,
CClassType[][] substitution)
public CType checkType(CContextType context)
throws UnpositionedError
context - the context in which this type was
declared, may be null
UnpositionedError - this unpositioned error
should be positioned
by the calling node of
the AST, typically by
calling the
addPosition method of
UnpositionedError
//also //assignable loadedClassInfo, thisClassInfo;
public void resolveValueType(CExpressionContextType context)
throws PositionedError
context - the context in which this class
declaration appears
PositionedError - if the check fails private boolean descendsFrom(CClassType maybeSuper)
maybeSuper
type.
maybeSuper - The potential supertype of this type.
maybeSuper.
public boolean isAlwaysAssignableTo(CType dest,
boolean inst)
isAlwaysAssignableTo in class CTypedest - the destination type
WMD: In addition the universes have to be assignable, too.//also //assignable_redundantly thisClassInfo;
public boolean isAlwaysAssignableTo(CType dest,
CClassType[] substitution)
isAlwaysAssignableTo in class CType
public boolean isAlwaysAssignableToNoUniverses(CType dest,
CClassType[] substitution)
public boolean isAlwaysAssignableTo(CType dest)
CType
public boolean isValidTypeArgumentFor(CTypeVariable typeVariable,
CClassType[] substitution)
typeVariable.
typeVariable - The type variable for which this type is the actual
type parameter.substitution - All the actual type arguments of the parametrized type.
typeVariable.public boolean isAssignableTo(CType dest)
isAssignableTo in class CTypepublic boolean needsUncheckedConversion(CType dest)
CTypedest.
needsUncheckedConversion in class CType
public boolean needsUncheckedConversion(CType dest,
CClassType[] substitution)
CTypedest, eventually
using the given generic substitution.
needsUncheckedConversion in class CTypepublic boolean isRawTypeInvocationOf(CClass superClazz)
superClazz.
superClazz - The target super class.
superClazz.
private boolean isRawTypeInvocationOfRec(CClass superClazz,
CClassType type,
boolean isRawType)
type is a raw type invocation of the
given superClazz.
superClazz - The target super class.type - The current type in the supertype hierarchy.isRawType - Whether type is a raw type.
type is a raw type invocation of
the given superClazz.
private boolean isRawTypeInvocationOfSuper(CClass superClazz,
CClassType superType,
boolean isRawType)
superClazz.
superClazz - The target super class.superType - The supertype to which to move.isRawType - Whether the current type is a raw type.
superType is a raw
type invocation of superClazz.public boolean contains(CClassType type)
type - The type possibly contained by this type.
type.public CType getErasure()
getErasure in class CTypepublic CClassType capture()
null.public boolean isParameterizedType()
public boolean hasWildcardTypeArgument()
public boolean hasUnboundedWildcardTypeArgumentsOnly()
true if and only if this is a parameterized type
and all its type arguments are unbounded wildcards.
public boolean isCastableTo(CType dest)
dest - the destination type
WMD: added additional conditions for the universe modifiersalso assignable loadedClassInfo, thisClassInfo;
public boolean implicitlyCastTo(CType dest)
implicitlyCastTo in class CTypedest - the expression type to cast to
public boolean isCheckedException()
isCheckedException in class CTypepublic Collection directlyVisibleTypes()
assignable loadedClassInfo, thisClassInfo;
public static Collection getVisibleTypesFrom(Collection dirVisTypes)
dirVisTypes - an initial collection of directly visible types
requires (\forall Object o; dirVisTypes.contains(o); o instanceof CType);
public void plantDispatchTest(CodeSequence code,
CodeLabel nextInstruction)
plantDispatchTest in class CTypeprivate CClass getCachedCClass()
assignable loadedClassInfo, thisClassInfo, cachedString, clazz;
public CClassType[] getArguments()
getArguments in class CTypepublic CClassType[][] getAllArguments()
getAllArguments in class CTypepublic void setAllArguments(CClassType[][] arguments)
|
mjc | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||