Interface Type

All Known Subinterfaces:
Type.Array, Type.Declared, Type.Delegated, Type.Function, Type.Primitive

public interface Type
Instances of this class are used to model types in the foreign language. Instances of this class support the visitor pattern (see accept(Type.Visitor, Object) and Type.Visitor).
  • Method Details

    • isErroneous

      boolean isErroneous()
      Is this type the erroneous type?
      Returns:
      true, if this type is the erroneous type.
    • accept

      <R, D> R accept(Type.Visitor<R,D> visitor, D data)
      Entry point for visiting type instances.
      Type Parameters:
      R - the visitor's return type.
      D - the visitor's argument type.
      Parameters:
      visitor - the type visitor.
      data - optional data to be passed to the visitor.
      Returns:
      the result of visiting this type through the specified type visitor.
    • equals

      boolean equals(Object o)
      Compares the specified object with this Type for equality. Returns true if and only if the specified object is also a Type and both the Types are equal.
      Overrides:
      equals in class Object
      Parameters:
      o - the object to be compared for equality with this Type
      Returns:
      true if the specified object is equal to this Type
      See Also:
    • hashCode

      int hashCode()
      Returns the hash code value for this Type.
      Overrides:
      hashCode in class Object
      Returns:
      the hash code value for this Type.
      See Also:
    • layoutFor

      static Optional<MemoryLayout> layoutFor(Type t)
      Compute the layout for a given type.
      Parameters:
      t - the type.
      Returns:
      the layout for given type.
    • descriptorFor

      static Optional<FunctionDescriptor> descriptorFor(Type.Function function)
      Compute the function descriptor for a given function type.
      Parameters:
      function - the function type.
      Returns:
      the function descriptor for given function type.
    • void_

      static Type.Primitive void_()
      Create the void type.
      Returns:
      the void type.
    • primitive

      static Type.Primitive primitive(Type.Primitive.Kind kind)
      Creates a new primitive type given kind.
      Parameters:
      kind - the primitive type kind.
      Returns:
      a new primitive type with given kind.
    • qualified

      static Type.Delegated qualified(Type.Delegated.Kind kind, Type type)
      Creates a new qualified type given kind and underlying type.
      Parameters:
      kind - the qualified type kind.
      type - the qualified type underlying type.
      Returns:
      a new qualified type with given name and underlying type.
    • typedef

      static Type.Delegated typedef(String name, Type aliased)
      Creates a new typedef type given name and underlying type.
      Parameters:
      name - the typedef type name.
      aliased - the typeef type underlying type.
      Returns:
      a new typedef type with given name and underlying type.
    • pointer

      static Type.Delegated pointer()
      Creates a new pointer type with no associated pointee information.
      Returns:
      a new pointer type with no associated pointee information.
    • pointer

      static Type.Delegated pointer(Type pointee)
      Creates a new pointer type with given pointee type.
      Parameters:
      pointee - the pointee type.
      Returns:
      a new pointer type with given pointee type.
    • pointer

      static Type.Delegated pointer(Supplier<Type> pointee)
      Creates a new pointer type with given pointee type.
      Parameters:
      pointee - factory to (lazily) build the pointee type.
      Returns:
      a new pointer type with given pointee type (lazily built from factory).
    • function

      static Type.Function function(boolean varargs, Type returnType, Type... arguments)
      Creates a new function type with given parameter types and return type.
      Parameters:
      varargs - is this function type variable-arity?
      returnType - the function type return type.
      arguments - the function type formal parameter types.
      Returns:
      a new function type with given parameter types and return type.
    • declared

      static Type.Declared declared(Declaration.Scoped tree)
      Creates a new declared type with given foreign declaration.
      Parameters:
      tree - the foreign declaration the type refers to.
      Returns:
      a new declared type with given foreign declaration.
    • vector

      static Type.Array vector(long elementCount, Type elementType)
      Creates a new vector type with given element count and element type.
      Parameters:
      elementCount - the vector type element count.
      elementType - the vector type element type.
      Returns:
      a new vector type with given element count and element type.
    • array

      static Type.Array array(long elementCount, Type elementType)
      Creates a new array type with given element count and element type.
      Parameters:
      elementCount - the array type element count.
      elementType - the array type element type.
      Returns:
      a new array type with given element count and element type.
    • array

      static Type.Array array(Type elementType)
      Creates a new array type with given element type.
      Parameters:
      elementType - the array type element type.
      Returns:
      a new array type with given element type.
    • error

      static Type error()
      Creates an erroneous type.
      Returns:
      an erroneous type.