|
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.CType
This class is the root for type hierarchy. It contains methods for generating type-signatures in bytecode, finding appropriate op-codes for operations on various types, and answering questions about the appropriateness of casts and assignments.
| Nested Class Summary | |
static class |
CType.MethodSignature
This data structure represents a method type signature as an array of specialized parameter types, a return type, and a receiver type (which may be null for regular Java method signatures). |
static class |
CType.MethodSignatureParser
This inner class provides methods for converting a bytecode type signature into an instance of (a subclass of) CType for use in compilation. |
static class |
CType.StringBuffers
This inner class optimizes performance by maintaining a stack of FastStringBuffers to be recycled. |
static class |
CType.TupleCollection
This nested class defines a collection of tuples where only the most general type tuples are retained in the collection. |
| Field Summary | |
static CType[] |
EMPTY
|
protected static CType.MethodSignatureParser |
instance
|
protected boolean |
isMethodTypeVariable
|
protected boolean |
isTypeVariable
|
protected int |
type
|
| Fields inherited from class org.multijava.util.Utils |
DBG_LEVEL_HIGH, DBG_LEVEL_LOW, DBG_LEVEL_NO |
| Constructor Summary | |
protected |
CType(int type)
Constructs a type signature |
| Method Summary | |
void |
appendGenericSignature(FastStringBuffer buff)
|
boolean |
changesByErasure()
Returns whether this type differs from its type erasure (JLS3 4.6). |
boolean |
checked()
|
abstract CType |
checkType(CContextType context)
Checks that this type is valid, throwing an exception if it is not. |
int |
compareTo(Object o)
Compares this to another type alphabetically by identifier. |
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)
|
static String |
genGenericMethodSignature(CTypeVariable[] tvs,
CType returnType,
CType receiverType,
CSpecializedType[] parameters,
boolean skipSynthParameter)
Generates a multimethod signature as used in custom bytecode attributes. |
static String |
genGenericMethodSignature(CTypeVariable[] tvs,
CType returnType,
CType[] parameters)
|
static String |
genGenericMethodSignatureHelper(CTypeVariable[] tvs,
CType returnType,
CType receiverType,
CTypeSignatureAppender[] parameters,
boolean skipSynthParameter)
|
static String |
genMethodSignature(CType returnType,
CType[] parameters)
Generates a method signature as used in regular Java bytecode. |
private static String |
genMethodSignatureHelper(CType returnType,
CType receiverType,
CTypeSignatureAppender[] parameters,
boolean skipSynthParameter)
Helper method generates a method signature as used in regular Java bytecode if receiverType is null, or a multimethod signature otherwise. |
static String |
genMultimethodSignature(CType returnType,
CType receiverType,
CSpecializedType[] parameters,
boolean skipSynthParameter)
Generates a multimethod signature as used in custom bytecode attributes. |
CClassType[][] |
getAllArguments()
|
CClassType[] |
getArguments()
|
CType |
getCapture(CContextType context)
Returns the result of applying capture conversion (JLS3 5.1.10) to this type. |
CClass |
getCClass()
|
CType |
getErasure()
|
CType |
getErasure(CContextType context)
|
String |
getGenericSignature()
|
String |
getIdent()
|
int |
getLoadOpcode()
Returns the opcode to load a local variable of this type. |
int |
getReturnOpcode()
Returns the opcode to return a value of this type. |
String |
getSignature()
Transforms this type to a string |
abstract int |
getSize()
Returns the size used in stack by value of this type |
int |
getStoreOpcode()
Returns the opcode to store a local variable of this type. |
int |
getTypeID()
Returns the ID of this type |
JExpression |
getValue()
|
boolean |
implicitlyCastTo(CType dest)
implicitlyCastTo |
abstract boolean |
isAlwaysAssignableTo(CType dest)
Is this type assignable to the given type by assignment type conversion [JLS2 5.2]. |
boolean |
isAlwaysAssignableTo(CType dest,
boolean inst)
|
boolean |
isAlwaysAssignableTo(CType dest,
CClassType[] substitution)
|
boolean |
isArrayType()
|
boolean |
isAssignableTo(CType dest)
|
boolean |
isBoolean()
Check if a type is the boolean type |
boolean |
isCapture()
Returns whether this is a wildcard capture type as resulting from capture conversion (JLS3 5.1.10). |
abstract boolean |
isCastableTo(CType dest)
Can this type be converted to the specified type by casting conversion (JLS 5.5) ? |
boolean |
isCheckedException()
|
boolean |
isClassType()
Check if a type is a reference type (a class, interface, or array) |
boolean |
isClassTypeVariable()
Returns whether this type is a type variable introduced by a generic class declaration (JLS3 8.1.2) or a generic interface declaration (JLS3 9.1.2) as opposed to a method type variable. |
boolean |
isCodedAsInt()
|
boolean |
isConcrete()
Indicates whether this type is concrete. |
boolean |
isFloatingPoint()
Check if a type is a real number type |
boolean |
isGenericType()
Indicates whether this type is a Generic class type |
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 |
isMethodTypeVariable()
|
boolean |
isNestedType()
Indicates whether this type is a nested type, i.e., a member type. |
boolean |
isNumeric()
Check if a type is a numeric type |
boolean |
isOrdinal()
Check if a type is an integer type |
boolean |
isPrimitive()
Check if a type is a primitive scalar type |
boolean |
isRawType()
Returns whether this is a raw type (JLS3 4.8). |
boolean |
isReference()
Check if a type is a pointer type (which is the same as a class type) |
boolean |
isReifiableType()
Returns whether this is a reifiable type (JLS3 4.7). |
boolean |
isTypeVariable()
Check if a type is a type variable |
boolean |
isValueType()
|
boolean |
isVoid()
Check if a type is void type |
boolean |
isWildcard()
Returns whether this is a wildcard type. |
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. |
static CType |
parseGenericTypeSignature(String signature)
|
static CType |
parseGenericTypeSignature(String signature,
CUniverseTypeAnnotation univAnnot)
|
static CType.MethodSignature |
parseMethodSignature(String sig)
Returns a MethodSignature data structure by parsing the given method or multimethod signature as read from bytecode. |
static CType.MethodSignature |
parseMethodSignature(String sig,
CUniverseMethodAnnotation univAnnot)
|
static CType |
parseSignature(String signature)
Parse a java type signature Description : Attempts to parse the provided string as if it started with the Java VM-standard signature for a type. |
static CType |
parseSignature(String signature,
CUniverseTypeAnnotation univAnnot)
|
void |
plantDispatchTest(CodeSequence code,
CodeLabel nextInstruction)
|
abstract void |
resolveValueType(CExpressionContextType context)
Compute the value of a specializer expression used to dispatch on a compile-time constant. |
void |
setMethodTypeVariable(boolean isMTV)
|
void |
setTypeVariable(boolean isTV)
|
String |
specializerSymbol()
Returns the specializer symbol to use when this type is the specializer. |
abstract String |
toString()
Transforms this type to a string |
String |
toVerboseString()
A more verbose version of toString only used for error reporting. |
static String |
tupleToString(CType recvType,
CType[] actuals)
Constructs a nicely format string representing the type tuple given by the arguments. |
static String |
tupleToString(CType[] argTuple)
Constructs a nicely formatted string representing the type tuple given by the argument array. |
| 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, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface org.multijava.mjc.CTypeSignatureAppender |
appendSignature |
| Field Detail |
public static final CType[] EMPTY
protected int type
protected boolean isTypeVariable
protected boolean isMethodTypeVariable
protected static final CType.MethodSignatureParser instance
| Constructor Detail |
protected CType(int type)
| Method Detail |
public boolean equals(Object other)
equals in class Objectother - the object to compare with
other is a CType object
representing the same Java type as this represents
public boolean equals(Object other,
boolean enableUniv)
other - 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)
public boolean equals(CType other,
CClassType[] substitution,
boolean enableUniv)
public int compareTo(Object o)
throws ClassCastException
compareTo in interface ComparableClassCastExceptionpublic abstract String toString()
toString in class Objectpublic String toVerboseString()
public boolean isNestedType()
public String getSignature()
public String getGenericSignature()
public void appendGenericSignature(FastStringBuffer buff)
appendGenericSignature in interface CTypeSignatureAppenderpublic abstract int getSize()
public boolean isNumeric()
public boolean isVoid()
public boolean isCodedAsInt()
public boolean isOrdinal()
public boolean isFloatingPoint()
public boolean isBoolean()
public boolean isPrimitive()
public boolean isReference()
public boolean isClassType()
public boolean isGenericType()
public boolean isRawType()
public boolean isReifiableType()
public boolean changesByErasure()
public CType getErasure(CContextType context)
throws UnpositionedError
UnpositionedErrorpublic CType getErasure()
public CType getCapture(CContextType context)
throws UnpositionedError
Note that capture conversion only changes a parametrized type with at least one wildcard in its type arguments.
context - The type checking context.
null.
UnpositionedError - if some error occurs during type checking of
the returned type.public CClassType[][] getAllArguments()
public CClassType[] getArguments()
public String getIdent()
public CClass getCClass()
public boolean isTypeVariable()
public boolean isClassTypeVariable()
public boolean isMethodTypeVariable()
public void setMethodTypeVariable(boolean isMTV)
public void setTypeVariable(boolean isTV)
public boolean isWildcard()
public boolean isCapture()
public boolean isInterface()
public boolean isArrayType()
public boolean isValueType()
public boolean checked()
public int getTypeID()
public boolean isConcrete()
assignable objectState;
public boolean isLocalTo(CContextType context)
context - the context in which to check
assignable objectState;
public String specializerSymbol()
public abstract CType checkType(CContextType context)
throws UnpositionedError
UnpositionedError - this unpositioned error
should be positioned
by the calling node of
the AST, typically by
calling the
addPosition method of
UnpositionedError
public abstract void resolveValueType(CExpressionContextType context)
throws PositionedError
context - the context in which this class
declaration appears
PositionedErrorpublic abstract boolean isCastableTo(CType dest)
dest - the destination type
assignable objectState;
public boolean implicitlyCastTo(CType dest)
dest - the expression type to cast to
public abstract boolean isAlwaysAssignableTo(CType dest)
dest - the destination type
//assignable objectState;
public boolean isAlwaysAssignableTo(CType dest,
boolean inst)
public boolean isAlwaysAssignableTo(CType dest,
CClassType[] substitution)
public boolean isAssignableTo(CType dest)
public boolean needsUncheckedConversion(CType dest)
dest.
dest - The target type.
dest.isAlwaysAssignableTo(CType)
public boolean needsUncheckedConversion(CType dest,
CClassType[] substitution)
dest, eventually
using the given generic substitution.
dest - The target type.substitution - The generic substitution for class type variables.
dest.isAlwaysAssignableTo(CType)public boolean isCheckedException()
public JExpression getValue()
public int getLoadOpcode()
public int getStoreOpcode()
public int getReturnOpcode()
public void plantDispatchTest(CodeSequence code,
CodeLabel nextInstruction)
public static CType parseSignature(String signature)
public static CType parseSignature(String signature,
CUniverseTypeAnnotation univAnnot)
public static CType parseGenericTypeSignature(String signature)
public static CType parseGenericTypeSignature(String signature,
CUniverseTypeAnnotation univAnnot)
public static CType.MethodSignature parseMethodSignature(String sig)
public static CType.MethodSignature parseMethodSignature(String sig,
CUniverseMethodAnnotation univAnnot)
public static String genMethodSignature(CType returnType,
CType[] parameters)
public static String genGenericMethodSignature(CTypeVariable[] tvs,
CType returnType,
CType[] parameters)
public static String genMultimethodSignature(CType returnType,
CType receiverType,
CSpecializedType[] parameters,
boolean skipSynthParameter)
public static String genGenericMethodSignature(CTypeVariable[] tvs,
CType returnType,
CType receiverType,
CSpecializedType[] parameters,
boolean skipSynthParameter)
public static String genGenericMethodSignatureHelper(CTypeVariable[] tvs,
CType returnType,
CType receiverType,
CTypeSignatureAppender[] parameters,
boolean skipSynthParameter)
private static String genMethodSignatureHelper(CType returnType,
CType receiverType,
CTypeSignatureAppender[] parameters,
boolean skipSynthParameter)
public static String tupleToString(CType[] argTuple)
argTuple - length > 0
public static String tupleToString(CType recvType,
CType[] actuals)
recvType - the type of the first element in the tupleactuals - length >= 0
|
JML | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||