Package gnu.kawa.reflect
Class MappedArrayType
- java.lang.Object
-
- gnu.bytecode.Type
-
- gnu.bytecode.ObjectType
-
- gnu.kawa.reflect.MappedArrayType
-
public class MappedArrayType extends ObjectType implements TypeValue
An array type where elements are copied from a sequence. A MappedArrayType[T] is implemented using a T (native) array. It is compatible with a sequence whose elements are compatible with T. Each element is copied (with coercion) from the sequence into the array.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class gnu.bytecode.Type
Type.NeverReturns
-
-
Field Summary
Fields Modifier and Type Field Description protected ObjectTypeimplementationType-
Fields inherited from class gnu.bytecode.ObjectType
flags
-
Fields inherited from class gnu.bytecode.Type
boolean_ctype, boolean_type, booleanType, booleanValue_method, byte_type, byteType, char_type, charType, clone_method, double_type, doubleType, doubleValue_method, errorType, float_type, floatType, floatValue_method, int_type, intType, intValue_method, java_lang_Class_type, javalangannotationAnnotationType, javalangBooleanType, javalangCharacterType, javalangClassType, javalanginvokeMethodHandleType, javalangNumberType, javalangObjectType, javalangStringType, javalangThrowableType, long_type, longType, longValue_method, neverReturnsType, nullType, number_type, objectType, pointer_type, reflectClass, short_type, shortType, string_type, throwable_type, toString_method, tostring_type, toStringType, typeArray0, void_type, voidType
-
-
Constructor Summary
Constructors Constructor Description MappedArrayType(Type elementType)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description ExpressionconvertValue(Expression value)Return converted expression or null.voidemitCoerceFromObject(CodeAttr code)Compile (in given method) cast from Object to this Type.voidemitIsInstance(Variable incoming, Compilation comp, Target target)Emit code for incoming instanceof this_type.voidemitTestIf(Variable incoming, Declaration decl, Compilation comp)Emit code for if (incoming instanceof this_type) decl = incoming ....StringencodeType(Language language)TypegetComponentType()ProceduregetConstructor()Get the constructor function for this type.TypegetImplementationType()Return Java-level implementation type.StringgetName()TypegetRealType()If this is a type alias, get the aliased type.intisCompatibleWithValue(Type valueType)If this is the target type, is a given source type compatible?static Typemaybe(Type type, int nesting)StringtoString()-
Methods inherited from class gnu.bytecode.ObjectType
coerceFromObject, compare, getContextClass, getContextClassLoader, getField, getInterfaces, getInternalName, getMethod, getMethods, getMethods, getReflectClass, getSuperclass, isExisting, isInstance, setExisting
-
Methods inherited from class gnu.bytecode.Type
coerceToObject, emitCoerceToObject, emitConvertFromPrimitive, emitIsInstance, getGenericSignature, getMaybeGenericSignature, getRawType, getSignature, getSize, getSizeInWords, getType, hashCode, isCompatibleWithValue, isInterface, isMoreSpecific, isSame, isSubtype, isValidJavaTypeName, isVoid, lookupType, lowestCommonSharedType, lowestCommonSuperType, make, make, printSignature, promote, promoteIfUnsigned, registerTypeForClass, setGenericSignature, setName, setReflectClass, setSignature, signatureLength, signatureLength, signatureToName, signatureToPrimitive, signatureToType, signatureToType, swappedCompareResult
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.lang.reflect.Type
getTypeName
-
-
-
-
Field Detail
-
implementationType
protected ObjectType implementationType
-
-
Constructor Detail
-
MappedArrayType
public MappedArrayType(Type elementType)
-
-
Method Detail
-
getComponentType
public Type getComponentType()
-
getImplementationType
public Type getImplementationType()
Description copied from class:TypeReturn Java-level implementation type. The type used to implement types not natively understood by the JVM or the Java language. Usually, the identity function. However, a language might handle union types or template types or type expressions calculated at run time. In that case return the type used at the Java level, and known at compile time.- Specified by:
getImplementationTypein interfaceTypeValue- Overrides:
getImplementationTypein classType
-
getRealType
public Type getRealType()
Description copied from class:TypeIf this is a type alias, get the aliased type. This is semi-deprecated.- Overrides:
getRealTypein classType
-
emitTestIf
public void emitTestIf(Variable incoming, Declaration decl, Compilation comp)
Description copied from interface:TypeValueEmit code for if (incoming instanceof this_type) decl = incoming .... This method is designed for typeswitch applications, where this call is the first part of a conditional, so it must be followed by calls to emitElse and emitFi.- Specified by:
emitTestIfin interfaceTypeValue- Parameters:
incoming- Contains the value we are testing to see if it has the type of this. If null, use top-of-stack. May not be null if decl is non-null.decl- If non-null, assign value after coercion to Declaration.comp- The compilation state.
-
isCompatibleWithValue
public int isCompatibleWithValue(Type valueType)
Description copied from class:TypeIf this is the target type, is a given source type compatible?- Overrides:
isCompatibleWithValuein classType- Returns:
- -1 if not compatible; 0 if need to check at run-time; 1 if compatible; 2 if compatible and no conversion or cast needed. We also return 0 for some "narrowing" conversions even if we know they will always succeed, so as to make such conversions less preferred when doing method overloading.
-
convertValue
public Expression convertValue(Expression value)
Description copied from interface:TypeValueReturn converted expression or null.- Specified by:
convertValuein interfaceTypeValue
-
getConstructor
public Procedure getConstructor()
Description copied from interface:TypeValueGet the constructor function for this type. Returns null if there is no contructor function. Also returns null if this extends ClassType or ArrayType and standard Java constructors (<init>methods) should be used.- Specified by:
getConstructorin interfaceTypeValue
-
emitIsInstance
public void emitIsInstance(Variable incoming, Compilation comp, Target target)
Description copied from interface:TypeValueEmit code for incoming instanceof this_type. The implementation can useInstanceOf .emitIsInstancewhich is a conveniece method that callsemitTestIf.- Specified by:
emitIsInstancein interfaceTypeValue- Parameters:
incoming- Contains the value we are testing to see if it has the the type of 'this'. If null, use top-of-stack.comp- The compilation state.target- Where to leave the result.
-
encodeType
public String encodeType(Language language)
- Specified by:
encodeTypein interfaceTypeValue
-
emitCoerceFromObject
public void emitCoerceFromObject(CodeAttr code)
Description copied from class:ObjectTypeCompile (in given method) cast from Object to this Type.- Overrides:
emitCoerceFromObjectin classObjectType
-
-