public class FunctionType extends ConstructedType
| Constructor and Description |
|---|
FunctionType() |
FunctionType(java.util.AbstractList domains,
Type range) |
FunctionType(int arity) |
FunctionType(int arity,
Type range) |
FunctionType(Type[] domains,
Type range) |
FunctionType(Type[] domains,
Type range,
hlt.language.design.types.BoxingMask mask) |
FunctionType(Type[] domains,
Type range,
FunctionType copy) |
FunctionType(Type domain,
Type range) |
FunctionType(Type domain1,
Type domain2,
Type range) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
argumentSortsDisagree(FunctionType actualType,
int i) |
int |
arity() |
void |
checkOccurrence(TypeParameter parameter,
Type context,
TypeChecker typeChecker)
Throws a FailedUnificationException if the specified type parameter occurs
in this type.
|
Type |
copy(java.util.HashMap parameters)
Returns a copy of this FunctionType as per the renaming given by the
specified HashMap.
|
void |
curry(int depth)
Does the same as the version above, except that it is a one-time destructive
procedure (similar to the two versions of the unify method).
|
void |
curry(int depth,
TypeChecker typeChecker)
Transforms this function type by splitting its domains at the
specified depth, and records the old form in the appropriate trail of
the specified type-checker for undoing purposes.
|
Type |
curryedRange()
If this function type is of the form D1,...,Dn -> R, this
method returns D2,...,Dn -> R if n > 0, or
R if n = 0.
|
Type |
domain(int i)
Returns the dereferenced value of the i-th domain type.
|
boolean |
domainIsBoxed(int i) |
Type |
domainRef(int i)
Returns the undereferenced i-th domain type.
|
Type[] |
domains()
Returns list of domain types.
|
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 ==).
|
Type |
flatten()
Flattens this function type and all function types that occur
in it by uncurrying all the domains.
|
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 an instantiated copy of this function type as per the specified
substitution.
|
boolean |
isEqualTo(Type type)
Returns true iff this type is structurally isomorphic to the
specified type.
|
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 |
isPolymorphic() |
byte |
kind()
Returns the constant that identifies this as a function type.
|
hlt.language.design.types.BoxingMask |
mask()
Returns the dereferenced boxing mask.
|
hlt.language.design.types.BoxingMask |
maskRef()
Returns the undereferenced boxing mask.
|
java.lang.String |
maskString() |
boolean |
mustUnwrapArgument(FunctionType actualType,
int i) |
boolean |
mustUnwrapResult(FunctionType actualType) |
boolean |
mustWrapArgument(FunctionType actualType,
int i) |
boolean |
mustWrapResult(FunctionType actualType) |
boolean |
noCurrying() |
int |
numberOfTypeComponents()
Returns the number of type components making up this type.
|
Type |
range()
Returns the dereferenced value of the range type.
|
boolean |
rangeIsBoxed() |
Type |
rangeRef()
Returns the undereferenced range type.
|
boolean |
resultSortsDisagree(FunctionType actualType) |
void |
setDomainBox(int i) |
void |
setDomains(Type[] domains)
Sets the list of domain types to the specified list of types.
|
FunctionType |
setNoCurrying() |
FunctionType |
setNoCurrying(boolean flag) |
void |
setRange(Type range)
Sets the range type to the specified type.
|
void |
setRangeBox() |
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()
Returns a string form for a function type.
|
boolean |
trueDomainIsBoxed(int i) |
boolean |
trueRangeIsBoxed() |
Type |
typeRefComponent(int n)
Returns the n-th undereferenced type component in this type, if any; throws a
NoSuchTypeComponentException otherwise.
|
FunctionType |
uncurry()
When this function type is of the form A[1],...,A[n] ->
(B[1],...,B[m] -> R), this returns the function type
A[1],...,A[n],B[1],...,B[m] -> R, making sure to preserves
boxing masks appropriately.
|
boolean |
unify(Type type)
This unifies this type with the specified type with no possibility of undoing any
effects.
|
void |
unify(Type type,
TypeChecker typeChecker)
Unifies this function type with the given type in the context of the
given type-checker.
|
void |
unsetDomainBox(int i) |
void |
unsetRangeBox() |
actualType, array, array, baseType, baseTypeRef, BOOLEAN, BOXED_BOOLEAN, BOXED_CHAR, BOXED_INT, BOXED_REAL, boxSort, CHAR, copy, equals, findValue, 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, value, wrapperpublic FunctionType()
public FunctionType(int arity)
public FunctionType(int arity,
Type range)
public FunctionType(Type[] domains, Type range, hlt.language.design.types.BoxingMask mask)
public FunctionType(Type[] domains, Type range, FunctionType copy)
public FunctionType(java.util.AbstractList domains,
Type range)
public final int numberOfTypeComponents()
TypenumberOfTypeComponents in class Typepublic final Type typeRefComponent(int n)
TypetypeRefComponent in class Typepublic final void setTypeRefComponent(int n,
Type type)
TypesetTypeRefComponent in class Typepublic final boolean noCurrying()
public final FunctionType setNoCurrying()
public final FunctionType setNoCurrying(boolean flag)
public final byte kind()
public final Type[] domains()
public final hlt.language.design.types.BoxingMask maskRef()
public final hlt.language.design.types.BoxingMask mask()
public final void setDomains(Type[] domains)
public final void setRange(Type range)
public final Type domain(int i)
public final Type domainRef(int i)
public final Type rangeRef()
public final Type range()
public final boolean isPolymorphic()
isPolymorphic in class Typepublic final Type curryedRange()
public final int arity()
public final boolean trueDomainIsBoxed(int i)
public final boolean domainIsBoxed(int i)
public final void setDomainBox(int i)
public final void unsetDomainBox(int i)
public final boolean trueRangeIsBoxed()
public final boolean rangeIsBoxed()
public final void setRangeBox()
public final void unsetRangeBox()
public final boolean mustWrapArgument(FunctionType actualType, int i)
public final boolean mustUnwrapArgument(FunctionType actualType, int i)
public final boolean mustWrapResult(FunctionType actualType)
public final boolean mustUnwrapResult(FunctionType actualType)
public final boolean argumentSortsDisagree(FunctionType actualType, int i)
public final boolean resultSortsDisagree(FunctionType actualType)
public final Type flatten()
public final void curry(int depth,
TypeChecker typeChecker)
public final void curry(int depth)
public final FunctionType uncurry()
public final Type copy(java.util.HashMap parameters)
public final Type instantiate(java.util.HashMap substitution)
instantiate in class Typepublic final void unify(Type type, TypeChecker typeChecker) throws FailedUnificationException
All bindings and currying transformations are appropriately trailed in the contextual type-checker for undoing purposes. If unification fails, a FailedUnificationException is thrown.
unify in class TypeFailedUnificationExceptionpublic final boolean unify(Type type)
Typepublic 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 java.util.HashSet getParameters(java.util.HashSet set)
TypegetParameters in class Typepublic final int eqCode()
Typepublic final boolean isEqualTo(Type type)
public final boolean isEqualTo(Type type, java.util.HashMap parameters)
public final java.lang.String maskString()
public final java.lang.String toString()
toString in class java.lang.Object