public class CoerciveSubtypeOperator extends Object implements SubtypeOperator
| Modifier and Type | Class and Description |
|---|---|
protected static class |
CoerciveSubtypeOperator.Atom<T extends WyalFile.Type.Atom> |
protected static class |
CoerciveSubtypeOperator.Term<T extends WyalFile.Type> |
SubtypeOperator.Result| Modifier and Type | Field and Description |
|---|---|
protected wybs.lang.NameResolver |
resolver |
| Constructor and Description |
|---|
CoerciveSubtypeOperator(wybs.lang.NameResolver resolver) |
| Modifier and Type | Method and Description |
|---|---|
protected wybs.util.AbstractCompilationUnit.Name[] |
append(wybs.util.AbstractCompilationUnit.Name[] lhs,
wybs.util.AbstractCompilationUnit.Name rhs) |
SubtypeOperator.Result |
isSubtype(WyalFile.Type parent,
WyalFile.Type child)
Determine whether the
rhs type is a subtype of the
lhs (denoted lhs :> rhs). |
protected boolean |
isVoid(ArrayList<CoerciveSubtypeOperator.Atom<?>> truths,
wytp.types.subtyping.CoerciveSubtypeOperator.Worklist worklist,
wytp.types.subtyping.CoerciveSubtypeOperator.Assumptions assumptions)
Determine whether or not the intersection of a given list of types (the
worklist) reduces to void or not.
|
protected boolean |
isVoidArray(CoerciveSubtypeOperator.Atom<WyalFile.Type.Array> lhs,
CoerciveSubtypeOperator.Atom<WyalFile.Type.Array> rhs,
wytp.types.subtyping.CoerciveSubtypeOperator.Assumptions assumptions)
Determine whether the intersection of two array types is void or not.
|
protected boolean |
isVoidAtom(CoerciveSubtypeOperator.Atom<?> a,
CoerciveSubtypeOperator.Atom<?> b,
wytp.types.subtyping.CoerciveSubtypeOperator.Assumptions assumptions)
Determine whether the intersection of two arbitrary atoms results in void
or not.
|
boolean |
isVoidFunction(CoerciveSubtypeOperator.Atom<WyalFile.Type.Function> lhs,
CoerciveSubtypeOperator.Atom<WyalFile.Type.Function> rhs,
wytp.types.subtyping.CoerciveSubtypeOperator.Assumptions assumptions)
Determine whether the intersection of two function types is void or not.
|
boolean |
isVoidParameters(boolean lhsSign,
boolean lhsMax,
wybs.util.AbstractCompilationUnit.Tuple<WyalFile.Type> lhs,
boolean rhsSign,
boolean rhsMax,
wybs.util.AbstractCompilationUnit.Tuple<WyalFile.Type> rhs,
wytp.types.subtyping.CoerciveSubtypeOperator.Assumptions assumptions) |
protected boolean |
isVoidRecord(CoerciveSubtypeOperator.Atom<WyalFile.Type.Record> lhs,
CoerciveSubtypeOperator.Atom<WyalFile.Type.Record> rhs,
wytp.types.subtyping.CoerciveSubtypeOperator.Assumptions assumptions)
Determine whether the intersection of two record types is void or not.
|
protected boolean |
isVoidReference(CoerciveSubtypeOperator.Atom<WyalFile.Type.Reference> lhs,
CoerciveSubtypeOperator.Atom<WyalFile.Type.Reference> rhs,
wytp.types.subtyping.CoerciveSubtypeOperator.Assumptions assumptions)
Determine whether the intersection of two reference types is void or not.
|
protected boolean |
isVoidTerm(CoerciveSubtypeOperator.Term<?> lhs,
CoerciveSubtypeOperator.Term<?> rhs,
wytp.types.subtyping.CoerciveSubtypeOperator.Assumptions assumptions) |
public CoerciveSubtypeOperator(wybs.lang.NameResolver resolver)
public SubtypeOperator.Result isSubtype(WyalFile.Type parent, WyalFile.Type child) throws wybs.lang.NameResolver.ResolutionError
SubtypeOperator
Determine whether the rhs type is a subtype of the
lhs (denoted lhs :> rhs). In the presence of
type invariants, this operation is undecidable. Therefore, a
three-valued logic is employed. Either it was concluded that the
subtype relation definitely holds, or that it definitely does
not hold that it is unknown whether it holds or not.
For example, int|null :> int definitely holds. Likewise,
int :> int|null definitely does not hold. However, whether
or not nat :> pos holds depends on the type invariants given
for nat and pos which this operator cannot
reason about. Observe that, in some cases, we do get effective reasoning
about types with invariants. For example, null|nat :> nat
will be determined to definitely hold, despite the fact that
nat has a type invariant.
Depending on the exact language of types involved, this can be a surprisingly complex operation. For example, in the presence of union, intersection and negation types, the subtype algorithm is surprisingly intricate.
isSubtype in interface SubtypeOperatorparent - The candidate "supertype". That is, lhs's raw type may be a
supertype of rhs's raw type.child - The candidate "subtype". That is, rhs's raw type may be a
subtype of lhs's raw type.wybs.lang.NameResolver.ResolutionError - Occurs when a nominal type is encountered whose name cannot
be resolved properly. For example, it resolves to more than
one possible matching declaration, or it cannot be resolved
to a corresponding type declaration.protected boolean isVoidTerm(CoerciveSubtypeOperator.Term<?> lhs, CoerciveSubtypeOperator.Term<?> rhs, wytp.types.subtyping.CoerciveSubtypeOperator.Assumptions assumptions) throws wybs.lang.NameResolver.ResolutionError
wybs.lang.NameResolver.ResolutionErrorprotected boolean isVoid(ArrayList<CoerciveSubtypeOperator.Atom<?>> truths, wytp.types.subtyping.CoerciveSubtypeOperator.Worklist worklist, wytp.types.subtyping.CoerciveSubtypeOperator.Assumptions assumptions) throws wybs.lang.NameResolver.ResolutionError
truths - The set of truths which have been established.worklist - The set of types currently being expandedassumptions - The set of assumed subtype relationshipswybs.lang.NameResolver.ResolutionErrorprotected wybs.util.AbstractCompilationUnit.Name[] append(wybs.util.AbstractCompilationUnit.Name[] lhs,
wybs.util.AbstractCompilationUnit.Name rhs)
protected boolean isVoidAtom(CoerciveSubtypeOperator.Atom<?> a, CoerciveSubtypeOperator.Atom<?> b, wytp.types.subtyping.CoerciveSubtypeOperator.Assumptions assumptions) throws wybs.lang.NameResolver.ResolutionError
a - b - assumptions - The set of assumed subtype relationshipswybs.lang.NameResolver.ResolutionErrorprotected boolean isVoidArray(CoerciveSubtypeOperator.Atom<WyalFile.Type.Array> lhs, CoerciveSubtypeOperator.Atom<WyalFile.Type.Array> rhs, wytp.types.subtyping.CoerciveSubtypeOperator.Assumptions assumptions) throws wybs.lang.NameResolver.ResolutionError
Determine whether the intersection of two array types is void or not. For
example, int[] intersecting with bool[] gives
void. In contrast, intersecting (int|null)[] with
int[] does not give void. Likewise, int[]
intersecting with !(int[]) gives void, whilst intersecting
int[] with !(bool[]) does not give void.
lhsSign - The sign of the first type being intersected. If true, we have
a positive atom. Otherwise, we have a negative atom.lhs. - The first type being intersected, referred to as the
"left-hand side".rhsSign - The sign of the second type being intersected. If true, we
have a positive atom. Otherwise, we have a negative atom.rhs - The second type being intersected, referred to as the
"right-hand side".assumptions - The set of assumed subtype relationshipswybs.lang.NameResolver.ResolutionErrorprotected boolean isVoidRecord(CoerciveSubtypeOperator.Atom<WyalFile.Type.Record> lhs, CoerciveSubtypeOperator.Atom<WyalFile.Type.Record> rhs, wytp.types.subtyping.CoerciveSubtypeOperator.Assumptions assumptions) throws wybs.lang.NameResolver.ResolutionError
Determine whether the intersection of two record types is void or not.
For example, {int f} intersecting with {int g}
gives void. In contrast, intersecting {int|null f} with
{int f} does not give void. Likewise, {int f}
intersecting with !{int f} gives void, whilst intersecting
{int f} with !{int g} does not give void.
lhsSign - The sign of the first type being intersected. If true, we have
a positive atom. Otherwise, we have a negative atom.lhs. - The first type being intersected, referred to as the
"left-hand side".rhsSign - The sign of the second type being intersected. If true, we
have a positive atom. Otherwise, we have a negative atom.rhs - The second type being intersected, referred to as the
"right-hand side".assumptions - The set of assumed subtype relationshipswybs.lang.NameResolver.ResolutionErrorprotected boolean isVoidReference(CoerciveSubtypeOperator.Atom<WyalFile.Type.Reference> lhs, CoerciveSubtypeOperator.Atom<WyalFile.Type.Reference> rhs, wytp.types.subtyping.CoerciveSubtypeOperator.Assumptions assumptions) throws wybs.lang.NameResolver.ResolutionError
Determine whether the intersection of two reference types is void or not.
Reference types are "invariant", meaning that element types must match
exactly for an intersection to arise. For example, &int
intersecting with &bool gives void. In contrast,
intersecting &int with &int does not give void.
Hoever, &int intersecting with &(int|bool)
gives void.
lhsSign - The sign of the first type being intersected. If true, we have
a positive atom. Otherwise, we have a negative atom.lhs. - The first type being intersected, referred to as the
"left-hand side".rhsSign - The sign of the second type being intersected. If true, we
have a positive atom. Otherwise, we have a negative atom.rhs - The second type being intersected, referred to as the
"right-hand side".assumptions - The set of assumed subtype relationshipswybs.lang.NameResolver.ResolutionErrorpublic boolean isVoidFunction(CoerciveSubtypeOperator.Atom<WyalFile.Type.Function> lhs, CoerciveSubtypeOperator.Atom<WyalFile.Type.Function> rhs, wytp.types.subtyping.CoerciveSubtypeOperator.Assumptions assumptions) throws wybs.lang.NameResolver.ResolutionError
Determine whether the intersection of two function types is void or not.
For example, function(int)->(int) intersecting with
function(bool)->(int) gives void. In contrast, intersecting
function(int|null)->(int) with
function(int)->(int) does not give void. Likewise,
function(int)->(int) intersecting with
!function(int)->(int) gives void, whilst intersecting
function(int)->(int) with
!function(bool)->(int) does not give void.
lhsSign - The sign of the first type being intersected. If true, we have
a positive atom. Otherwise, we have a negative atom.lhs. - The first type being intersected, referred to as the
"left-hand side".rhsSign - The sign of the second type being intersected. If true, we
have a positive atom. Otherwise, we have a negative atom.rhs - The second type being intersected, referred to as the
"right-hand side".assumptions - The set of assumed subtype relationships private booleanwybs.lang.NameResolver.ResolutionErrorpublic boolean isVoidParameters(boolean lhsSign,
boolean lhsMax,
wybs.util.AbstractCompilationUnit.Tuple<WyalFile.Type> lhs,
boolean rhsSign,
boolean rhsMax,
wybs.util.AbstractCompilationUnit.Tuple<WyalFile.Type> rhs,
wytp.types.subtyping.CoerciveSubtypeOperator.Assumptions assumptions)
throws wybs.lang.NameResolver.ResolutionError
wybs.lang.NameResolver.ResolutionErrorCopyright © 2017. All rights reserved.