Class ParametricType


  • public class ParametricType
    extends Object
    A template type.

    Template types are resolved at code-generation type rather than at Instruction generation type. They let you bind the concrete type for opcodes at the last minute, so the same max conditional could be used for all primative types, with the type only being bound at the last moment.

    Two ParametricType instances are the same if they are the same object, regardless of their names.

    Author:
    Matthew Pocock
    • Method Detail

      • createType

        public static ParametricType createType​(String name)
        Create a new ParametricType that claims nothing.
        Parameters:
        name - the name given to this type
        Returns:
        a new ParametricType instance with that name
      • createPrimitiveType

        public static ParametricType createPrimitiveType​(String name)
        Create a new ParametricType that claims to resolve to a primative type.
        Parameters:
        name - the name given to this type
        Returns:
        a new ParametricType instance with that name
      • createObjectType

        public static ParametricType createObjectType​(String name)
        Create a new ParametricType that claims to resolve to an object type.
        Parameters:
        name - the name given to this type
        Returns:
        a new ParametricType instance with that name
      • createArrayType

        public static ParametricType createArrayType​(String name)
        Create a new ParametricType that claims to resolve to an array type. All array types are object types.
        Parameters:
        name - the name given to this type
        Returns:
        a new ParametricType instance with that name
      • createType

        public static ParametricType createType​(String name,
                                                CodeClass[] classes)
        Create a new ParametricType that claims to be castable to all the classes in a list. Since neither Java nor bytecode support multiple inheritance, the classes must either be interfaces, or classes that fall into an inheritance path.
        Parameters:
        name - the name given to this type
        classes - an array of Class objects that any bound type must be castable to
        Returns:
        a new ParametricType that can bind to classes with these properties
      • getName

        public String getName()
        Get the name of this type. Names are not unique.
        Returns:
        the name given to this type
      • isPrimitive

        public boolean isPrimitive()
        Discover if this type must resolve to a primative.

        It is an error for a parametric type to resolve to a non-primative if this flag is set.

        Returns:
        true if this is guaranteed to resolve to a primative
      • isArray

        public boolean isArray()