- 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
).-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interface
An array type.static interface
Instances of this class are used to model types which are associated to a declaration in the foreign language (seeDeclaration
).static interface
A delegated type is used to model a type which contains an indirection to some other underlying type.static interface
A function type.static interface
A primitive type.static interface
Type visitor interface. -
Method Summary
Modifier and TypeMethodDescription<R,
D> R accept
(Type.Visitor<R, D> visitor, D data) Entry point for visiting type instances.static Type.Array
Creates a new array type with given element count and element type.static Type.Array
Creates a new array type with given element type.static Type.Declared
declared
(Declaration.Scoped tree) Creates a new declared type with given foreign declaration.static Optional<FunctionDescriptor>
descriptorFor
(Type.Function function) Compute the function descriptor for a given function type.boolean
Compares the specified object with this Type for equality.static Type
error()
Creates an erroneous type.static Type.Function
Creates a new function type with given parameter types and return type.int
hashCode()
Returns the hash code value for this Type.boolean
Is this type the erroneous type?static Optional<MemoryLayout>
Compute the layout for a given type.static Type.Delegated
pointer()
Creates a new pointer type with no associated pointee information.static Type.Delegated
Creates a new pointer type with given pointee type.static Type.Delegated
Creates a new pointer type with given pointee type.static Type.Primitive
primitive
(Type.Primitive.Kind kind) Creates a new primitive type given kind.static Type.Delegated
qualified
(Type.Delegated.Kind kind, Type type) Creates a new qualified type given kind and underlying type.static Type.Delegated
Creates a new typedef type given name and underlying type.static Type.Array
Creates a new vector type with given element count and element type.static Type.Primitive
void_()
Create thevoid
type.
-
Method Details
-
isErroneous
boolean isErroneous()Is this type the erroneous type?- Returns:
- true, if this type is the erroneous type.
-
accept
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
Compares the specified object with this Type for equality. Returnstrue
if and only if the specified object is also a Type and both the Types are equal. -
hashCode
int hashCode()Returns the hash code value for this Type. -
layoutFor
Compute the layout for a given type.- Parameters:
t
- the type.- Returns:
- the layout for given type.
-
descriptorFor
Compute the function descriptor for a given function type.- Parameters:
function
- the function type.- Returns:
- the function descriptor for given function type.
-
void_
Create thevoid
type.- Returns:
- the
void
type.
-
primitive
Creates a new primitive type given kind.- Parameters:
kind
- the primitive type kind.- Returns:
- a new primitive type with given kind.
-
qualified
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
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
Creates a new pointer type with no associated pointee information.- Returns:
- a new pointer type with no associated pointee information.
-
pointer
Creates a new pointer type with given pointee type.- Parameters:
pointee
- the pointee type.- Returns:
- a new pointer type with given pointee type.
-
pointer
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
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
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
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
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
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
Creates an erroneous type.- Returns:
- an erroneous type.
-