public abstract class Type extends java.lang.Object implements Valuable
| Modifier and Type | Field and Description |
|---|---|
static byte |
ARRAY |
static byte |
BAG |
static TypeConstant |
BOOLEAN |
static byte |
BOXABLE |
static TypeConstant |
CHAR |
static byte |
CLASS |
static byte |
COLLECTION |
static byte |
CONSTANT |
static byte |
DEFINED |
static byte |
FUNCTION |
static TypeConstant |
INT |
static TypeConstant |
INT_RANGE |
static byte |
INT_SORT |
static byte |
LIST |
static byte |
NAMED_TUPLE |
static byte |
OBJECT_SORT |
static byte |
PARAMETER |
static TypeConstant |
REAL |
static TypeConstant |
REAL_RANGE |
static byte |
REAL_SORT |
static byte |
SET |
static TypeConstant |
STRING |
static byte |
TUPLE |
static TypeConstant |
VOID |
static byte |
VOID_SORT |
| Constructor and Description |
|---|
Type() |
| Modifier and Type | Method and Description |
|---|---|
Type |
actualType()
Returns the value of this when this does not have a defining type; or that of
its defining type otherwise.
|
ArrayType |
array(Expression[] dimension)
Returns an array type of the specified dimension with this type as base type.
|
ArrayType |
array(int dimension)
Returns an array type of the specified dimension number (with unspecified dimension types)
with this type as base type.
|
Type |
baseType()
Returns the value of this when this does not have a base type; or that of
its base type otherwise.
|
Type |
baseTypeRef()
Returns this when this does not have a base type; or the (undereferenced)
base type otherwise.
|
static BoxableTypeConstant |
BOOLEAN()
This creates and returns a new type for boolean that may
be boxed by the compiler as the situation dictates.
|
static BoxableTypeConstant |
BOXED_BOOLEAN()
This creates and returns a new type for boolean that may
be unboxed by the compiler as the situation dictates.
|
static BoxableTypeConstant |
BOXED_CHAR()
This creates and returns a new type for integers that may
be unboxed by the compiler as the situation dictates.
|
static BoxableTypeConstant |
BOXED_INT()
This creates and returns a new type for integers that may
be unboxed by the compiler as the situation dictates.
|
static BoxableTypeConstant |
BOXED_REAL()
This creates and returns a new type for real numbers that may
be unboxed by the compiler as the situation dictates.
|
byte |
boxSort()
This returns the runtime sort for this type unless this type
has been marked as boxed - in which case it returns OBJECT_SORT.
|
static BoxableTypeConstant |
CHAR()
This creates and returns a new type for characters that may
be boxed by the compiler as the situation dictates.
|
void |
checkOccurrence(TypeParameter parameter,
Type context,
TypeChecker typeChecker)
Throws a FailedUnificationException if the specified type parameter occurs
in this type.
|
Type |
copy()
Returns a copy of this type with an empty renaming.
|
Type |
copy(java.util.HashMap parameters)
Returns a copy of this type with a consistent renaming of all free type
parameters, and identyfing bound type parameters with their values.
|
void |
curry(int depth,
TypeChecker typeChecker)
If this this a function type, transforms the type by splitting the
domains at the specified depth, and records the old form in the
appropriate trail of the specified type-checker for undoing
purposes.
|
abstract int |
eqCode()
Returns a hash code for this type - the reason for using the name eqCode
(rather than overriding hashCode), is that it is important to preserve
the implementation of java.lang.Object.hashCode for type parameters (to
be compatible with ==).
|
boolean |
equals(java.lang.Object object) |
Type |
findValue()
This returns the type value this is bound to and side-effects the binding
chains by shortening them (i.e., like the FIND operation of
the UNION/FIND algorithm (returns itself by default - overridden
by TypeParameter).
|
Type |
flatten()
Returns a flattened form of this type by uncurrying all the domains of all
function types that occur in it.
|
java.util.HashSet |
getParameters()
Returns the set of unbound type parameters that occur in this type.
|
java.util.HashSet |
getParameters(java.util.HashSet set)
Returns the specified set augmented with all the unbound type parameters that
occur in this type.
|
Valuable |
getValue()
This is identical to the value method but returns a
Valuable as mandated as it implements this interface.
|
Type |
instantiate(java.util.HashMap substitution)
Returns a copy of this type with all free type parameters bound as per the
specified type substitution.
|
static BoxableTypeConstant |
INT()
This creates and returns a new type for integers that may
be boxed by the compiler as the situation dictates.
|
boolean |
is(Type type) |
boolean |
isBag() |
boolean |
isBoolean() |
boolean |
isBoxedType()
This returns true iff this type has been marked as boxed
(true by default - overridden by
TypeConstant).
|
boolean |
isChar() |
boolean |
isCollection() |
abstract boolean |
isEqualTo(Type type)
Returns true iff this type is structurally isomorphic to the specified type.
|
abstract boolean |
isEqualTo(Type type,
java.util.HashMap parameters)
Returns true iff this type is structurally isomorphic to the
specified type, under the renaming of type parameters specified
by the given HashMap.
|
boolean |
isGlobalUnsafe()
Returns true iff this type has a structure that may be modified internally at
a place that has a polymorphic type.
|
boolean |
isInt() |
boolean |
isList() |
boolean |
isPolymorphic() |
boolean |
isPrimitive() |
boolean |
isReal() |
boolean |
isSet() |
boolean |
isString() |
boolean |
isVoid() |
abstract byte |
kind()
This returns the value identifying what kind of type this is.
|
java.lang.String |
kindString()
This returns the string describing the identifying kind this type.
|
abstract int |
numberOfTypeComponents()
Returns the number of type components making up this type.
|
int |
rank()
Returns an integer measuring the collection rank of this type.
|
static BoxableTypeConstant |
REAL()
This creates and returns a new type for real numbers that may
be boxed by the compiler as the situation dictates.
|
static void |
resetNames()
Clears the names of parameters.
|
Type |
setBoxed(boolean flag)
With true (resp.
|
abstract void |
setTypeRefComponent(int n,
Type type)
Sets the n-th undereferenced type component of this type to the specified type;
throws a NoSuchTypeComponentException otherwise.
|
Type |
shadowType()
This is used in Homomorphism
for typing irregular monoid operations in the absence of a real mechanism for subtyping.
|
byte |
sort()
This returns the runtime sort for this type (OBJECT_SORT
by default - overridden by TypeConstant).
|
Type |
standardize()
Returns a standard form for this type by creating a flattened copy
where all free type parameters, if any, are renamed.
|
java.lang.String |
toFullString()
N.B.: The following definition specifies only the
default behavior for this method.
|
java.lang.String |
toQuantifiedString() |
java.lang.String |
toQuantifiedString(boolean full)
Returns a string for this type with an explicit header for universally
quantified type parameters if there are any in this type.
|
Type |
typeComponent(int n)
Returns the n-th derefenced type component in this type, if any; throws a
NoSuchTypeComponentException otherwise.
|
abstract Type |
typeRefComponent(int n)
Returns the n-th undereferenced type component in this type, if any; throws a
NoSuchTypeComponentException otherwise.
|
abstract boolean |
unify(Type type)
This unifies this type with the specified type with no possibility of undoing any
effects.
|
abstract void |
unify(Type type,
TypeChecker typeChecker)
This unifies this type with the specified type in the context
of the specified TypeChecker.
|
Expression |
unwrapper()
This returns the built-in function that is appropriate for
turning a boxed value with primitive type into that value.
|
Type |
value()
This returns the type value this is bound to (itself by default
- overridden by TypeParameter).
|
Expression |
wrapper()
This returns the built-in function that is appropriate for
turning a value with primitive type into an object.
|
public static final byte CONSTANT
public static final byte BOXABLE
public static final byte PARAMETER
public static final byte FUNCTION
public static final byte ARRAY
public static final byte TUPLE
public static final byte NAMED_TUPLE
public static final byte SET
public static final byte BAG
public static final byte LIST
public static final byte CLASS
public static final byte COLLECTION
public static final byte DEFINED
public static final byte VOID_SORT
public static final byte INT_SORT
public static final byte REAL_SORT
public static final byte OBJECT_SORT
public static final TypeConstant VOID
public static final TypeConstant INT
public static final TypeConstant REAL
public static final TypeConstant CHAR
public static final TypeConstant BOOLEAN
public static final TypeConstant STRING
public static final TypeConstant INT_RANGE
public static final TypeConstant REAL_RANGE
public abstract int numberOfTypeComponents()
public abstract Type typeRefComponent(int n) throws NoSuchTypeComponentException
NoSuchTypeComponentExceptionpublic abstract void setTypeRefComponent(int n,
Type type)
throws NoSuchTypeComponentException
NoSuchTypeComponentExceptionpublic final Type typeComponent(int n) throws NoSuchTypeComponentException
NoSuchTypeComponentExceptionpublic static final BoxableTypeConstant BOOLEAN()
public static final BoxableTypeConstant INT()
public static final BoxableTypeConstant REAL()
public static final BoxableTypeConstant CHAR()
public static final BoxableTypeConstant BOXED_BOOLEAN()
public static final BoxableTypeConstant BOXED_INT()
public static final BoxableTypeConstant BOXED_REAL()
public static final BoxableTypeConstant BOXED_CHAR()
public final boolean isCollection()
public final boolean isPrimitive()
public final boolean is(Type type)
public final boolean isVoid()
public final boolean isBoolean()
public final boolean isInt()
public final boolean isReal()
public final boolean isChar()
public final boolean isString()
public final boolean isSet()
public final boolean isBag()
public final boolean isList()
public Type baseTypeRef()
public Type baseType()
public Type actualType()
public Type shadowType()
public final int rank()
public final ArrayType array(Expression[] dimension)
public final ArrayType array(int dimension)
public final boolean isGlobalUnsafe()
A type will be unsafe for global definitions if it is:
public boolean isPolymorphic()
public Type value()
public Type findValue()
public final Valuable getValue()
public byte sort()
N.B.: The following definition specifies only the default behavior for this method. Specific subclasses are generally expected to override this method.
public final byte boxSort()
N.B.: The following definition specifies only the default behavior for this method. Specific subclasses are generally expected to override this method.
public final Expression wrapper()
public final Expression unwrapper()
public boolean isBoxedType()
N.B.: The following definition specifies only the default behavior for this method. Specific subclasses are generally expected to override this method.
public Type setBoxed(boolean flag)
N.B.: The following definition specifies only the default behavior for this method. Specific subclasses are generally expected to override this method.
public abstract byte kind()
public final java.lang.String kindString()
public abstract void unify(Type type, TypeChecker typeChecker) throws FailedUnificationException
FailedUnificationExceptionpublic abstract boolean unify(Type type)
public void checkOccurrence(TypeParameter parameter, Type context, TypeChecker typeChecker) throws FailedUnificationException
N.B.: The following definition specifies only the default behavior for this method. Specific subclasses are generally expected to override this method.
FailedUnificationExceptionpublic void curry(int depth,
TypeChecker typeChecker)
N.B.: The following definition specifies only the default behavior for this method. Specific subclasses are generally expected to override this method.
public Type flatten()
N.B.: The following definition specifies only the default behavior for this method. Specific subclasses are generally expected to override this method.
public Type copy(java.util.HashMap parameters)
N.B.: The following definition specifies only the default behavior for this method. Specific subclasses are generally expected to override this method.
public Type copy()
N.B.: The following definition specifies only the default behavior for this method. Specific subclasses are generally expected to override this method.
public Type instantiate(java.util.HashMap substitution)
N.B.: The following definition specifies only the default behavior for this method. Specific subclasses are generally expected to override this method.
public final Type standardize()
public java.util.HashSet getParameters(java.util.HashSet set)
public final java.util.HashSet getParameters()
public abstract int eqCode()
public boolean equals(java.lang.Object object)
equals in class java.lang.Objectpublic abstract boolean isEqualTo(Type type)
public abstract boolean isEqualTo(Type type, java.util.HashMap parameters)
public static final void resetNames()
public java.lang.String toFullString()
N.B.: The following definition specifies only the default behavior for this method. Specific subclasses are generally expected to override this method.
public final java.lang.String toQuantifiedString(boolean full)
public final java.lang.String toQuantifiedString()