public class TypeParameter extends StaticType implements Bindable
| Constructor and Description |
|---|
TypeParameter() |
| Modifier and Type | Method and Description |
|---|---|
boolean |
addResiduation(ResiduatedGoal residuation,
int refCount)
Installs the specified residuation to be triggered by this type parameter,
saving the specified reference count to reinstate for the residuation upon
unbinding this type parameter.
|
boolean |
bind(Valuable value)
Binds this bindable to the given valuable.
|
boolean |
bind(Valuable valuable,
GoalProver prover)
Binds this type parameter to the given valuable in the context of
the given prover.
|
void |
checkOccurrence(TypeParameter parameter,
Type context,
TypeChecker typeChecker)
Throws a FailedUnificationException if the specified type parameter occurs
in this type.
|
Type |
copy()
This returns this type parameter unchanged.
|
Type |
copy(java.util.HashMap parameters)
Returns a copy of this TypeParameter as per the renaming given by
the specified HashMap.
|
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.
|
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)
Returns true iff this type parameter is the given 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.
|
Type |
flatten()
Flattens this type parameter's value by uncurrying all the domains
of all function types that occur in it.
|
java.util.HashSet |
getParameters(java.util.HashSet set)
Returns the specified set augmented with all the unbound type parameters that
occur in this type.
|
Type |
instantiate(java.util.HashMap substitution)
Returns the instance value given for this TypeParameter by the specified
substitution, or this if none is given.
|
boolean |
isBound()
Returns true iff this bindable is bound.
|
boolean |
isEqualTo(Type type)
Returns true iff this type parameter is the given one.
|
boolean |
isEqualTo(Type type,
java.util.HashMap parameters)
Returns true iff this type is parameter is equal to the given one
under the renaming of type parameters specified by the given HashMap.
|
boolean |
isPolymorphic() |
boolean |
isUnbound()
Returns true iff this bindable is unbound.
|
byte |
kind()
This returns the value identifying what kind of type this is.
|
int |
numberOfTypeComponents()
Returns the number of type components making up this type.
|
int |
parameterIndex()
This returns this parameter's index in the header array of a type's
quantifies string where this appears.
|
ObjectToIntMap |
residuations() |
void |
setTypeRefComponent(int n,
Type type)
Sets the n-th undereferenced type component of this type to the specified type;
throws a NoSuchTypeComponentException otherwise.
|
java.lang.String |
toString() |
Type |
typeRefComponent(int n)
Returns the n-th undereferenced type component in this type, if any; throws a
NoSuchTypeComponentException otherwise.
|
void |
unbind()
This unbinds this type parameter and resets the reference counts for all residuations
this has a trigger link with, if any.
|
boolean |
unify(Type type)
NB: does not perform the "occurs-check" test.
|
void |
unify(Type type,
TypeChecker typeChecker)
Unifies this type parameter with the given type in the context of
the given type-checker.
|
Type |
value()
This method acts as a type parameter dereferencing for possibly
bound type parameters.
|
actualType, array, array, baseType, baseTypeRef, BOOLEAN, BOXED_BOOLEAN, BOXED_CHAR, BOXED_INT, BOXED_REAL, boxSort, CHAR, getParameters, getValue, INT, is, isBag, isBoolean, isBoxedType, isChar, isCollection, isGlobalUnsafe, isInt, isList, isPrimitive, isReal, isSet, isString, isVoid, kindString, rank, REAL, resetNames, setBoxed, shadowType, sort, standardize, toFullString, toQuantifiedString, toQuantifiedString, typeComponent, unwrapper, wrapperpublic final ObjectToIntMap residuations()
public final int numberOfTypeComponents()
TypenumberOfTypeComponents in class Typepublic final Type typeRefComponent(int n) throws NoSuchTypeComponentException
TypetypeRefComponent in class TypeNoSuchTypeComponentExceptionpublic final void setTypeRefComponent(int n,
Type type)
throws NoSuchTypeComponentException
TypesetTypeRefComponent in class TypeNoSuchTypeComponentExceptionpublic final byte kind()
Typepublic final Type value()
public final Type findValue()
public final boolean isBound()
Bindablepublic final boolean isUnbound()
Bindablepublic final boolean bind(Valuable valuable, GoalProver prover)
public final boolean bind(Valuable value)
Bindablepublic final void unbind()
public final boolean addResiduation(ResiduatedGoal residuation, int refCount)
public final java.util.HashSet getParameters(java.util.HashSet set)
TypegetParameters in class Typepublic final boolean isPolymorphic()
isPolymorphic in class Typepublic final void curry(int depth,
TypeChecker typeChecker)
TypeN.B.: The following definition specifies only the default behavior for this method. Specific subclasses are generally expected to override this method.
public final Type flatten()
public final int parameterIndex()
public final Type copy(java.util.HashMap parameters)
public final Type instantiate(java.util.HashMap substitution)
instantiate in class Typepublic final Type copy()
public final void unify(Type type, TypeChecker typeChecker) throws FailedUnificationException
unify in class TypeFailedUnificationExceptionpublic final boolean unify(Type type)
public final void checkOccurrence(TypeParameter parameter, Type context, TypeChecker typeChecker) throws FailedUnificationException
TypeN.B.: The following definition specifies only the default behavior for this method. Specific subclasses are generally expected to override this method.
checkOccurrence in class TypeFailedUnificationExceptionpublic final int eqCode()
Typepublic final boolean equals(java.lang.Object object)
public final boolean isEqualTo(Type type)
public final boolean isEqualTo(Type type, java.util.HashMap parameters)
public final java.lang.String toString()
toString in class java.lang.Object