Class MappedArrayType

All Implemented Interfaces:
TypeValue, Type

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.
  • Field Details

    • implementationType

      protected ObjectType implementationType
  • Constructor Details

    • MappedArrayType

      public MappedArrayType(Type elementType)
  • Method Details

    • maybe

      public static Type maybe(Type type, int nesting)
    • getComponentType

      public Type getComponentType()
    • getImplementationType

      public Type getImplementationType()
      Description copied from class: Type
      Return 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:
      getImplementationType in interface TypeValue
      Overrides:
      getImplementationType in class Type
    • getRealType

      public Type getRealType()
      Description copied from class: Type
      If this is a type alias, get the aliased type. This is semi-deprecated.
      Overrides:
      getRealType in class Type
    • emitTestIf

      public void emitTestIf(Variable incoming, Declaration decl, Compilation comp)
      Description copied from interface: TypeValue
      Emit 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:
      emitTestIf in interface TypeValue
      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.
    • toString

      public String toString()
      Overrides:
      toString in class Type
    • getName

      public String getName()
      Overrides:
      getName in class Type
    • isCompatibleWithValue

      public int isCompatibleWithValue(Type valueType)
      Description copied from class: Type
      If this is the target type, is a given source type compatible?
      Overrides:
      isCompatibleWithValue in class Type
      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: TypeValue
      Return converted expression or null.
      Specified by:
      convertValue in interface TypeValue
    • getConstructor

      public Procedure getConstructor()
      Description copied from interface: TypeValue
      Get 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:
      getConstructor in interface TypeValue
    • emitIsInstance

      public void emitIsInstance(Variable incoming, Compilation comp, Target target)
      Description copied from interface: TypeValue
      Emit code for incoming instanceof this_type. The implementation can use InstanceOf .emitIsInstance which is a conveniece method that calls emitTestIf.
      Specified by:
      emitIsInstance in interface TypeValue
      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:
      encodeType in interface TypeValue
    • emitCoerceFromObject

      public void emitCoerceFromObject(CodeAttr code)
      Description copied from class: ObjectType
      Compile (in given method) cast from Object to this Type.
      Overrides:
      emitCoerceFromObject in class ObjectType