T - public abstract class AbstractTypeExtractor<T extends WyalFile.Type> extends Object implements TypeExtractor<T,Object>
A generic foundation for "convential" type extractors. That is, those which extract type information from types (rather than, for example, information about type invariants, etc). The approach consists of two phases:
int&(null|bool)" is converted into
"(int&null)|(int&bool)".!null & (null|{int f})". This expands to the conjuncts
"!null & null" and "(!null)&{int f}". Since the
former reduces to "void", we are left with
"(!null)&{int f}" which generates the extraction
"{int f}".During construction the concrete subclass is called to try and construct an instance of the target type from a given atom. This gives the subclass the ability to determine what the target type is. Furthermore, the subclass must provide appropriate methods for combining instances of the target type though union , intersection and subtraction operators.
For further reading on the operation of this algorithm, the following is suggested:
| Modifier and Type | Class and Description |
|---|---|
protected static class |
AbstractTypeExtractor.Conjunct |
protected static class |
AbstractTypeExtractor.Disjunct |
protected static class |
AbstractTypeExtractor.Signed
A signed type is simply a type which is either positive or negatively
signed.
|
| Modifier and Type | Field and Description |
|---|---|
protected wybs.lang.NameResolver |
resolver |
protected TypeSystem |
typeSystem |
| Constructor and Description |
|---|
AbstractTypeExtractor(wybs.lang.NameResolver resolver,
TypeSystem typeSystem) |
protected final wybs.lang.NameResolver resolver
protected final TypeSystem typeSystem
public AbstractTypeExtractor(wybs.lang.NameResolver resolver,
TypeSystem typeSystem)
public T extract(WyalFile.Type type, Object supplementary) throws wybs.lang.NameResolver.ResolutionError
TypeExtractor{int x}|{int x} we can extract the type
{int x}.extract in interface TypeExtractor<T extends WyalFile.Type,Object>type - The type for which information is to be extractedsupplementary - Supplementary information which may be used by the extractor.wybs.lang.NameResolver.ResolutionErrorprotected AbstractTypeExtractor.Disjunct toDisjunctiveNormalForm(WyalFile.Type type) throws wybs.lang.NameResolver.ResolutionError
int&(null|bool) is
converted into (int&null)|(int&bool).type - atoms - wybs.lang.NameResolver.ResolutionErrorprotected AbstractTypeExtractor.Disjunct toDisjunctiveNormalForm(WyalFile.Type.Primitive type) throws wybs.lang.NameResolver.ResolutionError
wybs.lang.NameResolver.ResolutionErrorprotected AbstractTypeExtractor.Disjunct toDisjunctiveNormalForm(WyalFile.Type.Record type) throws wybs.lang.NameResolver.ResolutionError
wybs.lang.NameResolver.ResolutionErrorprotected AbstractTypeExtractor.Disjunct toDisjunctiveNormalForm(WyalFile.Type.Reference type) throws wybs.lang.NameResolver.ResolutionError
wybs.lang.NameResolver.ResolutionErrorprotected AbstractTypeExtractor.Disjunct toDisjunctiveNormalForm(WyalFile.Type.Array type) throws wybs.lang.NameResolver.ResolutionError
wybs.lang.NameResolver.ResolutionErrorprotected AbstractTypeExtractor.Disjunct toDisjunctiveNormalForm(WyalFile.Type.FunctionOrMethodOrProperty type) throws wybs.lang.NameResolver.ResolutionError
wybs.lang.NameResolver.ResolutionErrorprotected AbstractTypeExtractor.Disjunct toDisjunctiveNormalForm(WyalFile.Type.Negation type) throws wybs.lang.NameResolver.ResolutionError
wybs.lang.NameResolver.ResolutionErrorprotected AbstractTypeExtractor.Disjunct toDisjunctiveNormalForm(WyalFile.Type.Union type) throws wybs.lang.NameResolver.ResolutionError
wybs.lang.NameResolver.ResolutionErrorprotected AbstractTypeExtractor.Disjunct toDisjunctiveNormalForm(WyalFile.Type.Intersection type) throws wybs.lang.NameResolver.ResolutionError
wybs.lang.NameResolver.ResolutionErrorprotected AbstractTypeExtractor.Disjunct toDisjunctiveNormalForm(WyalFile.Type.Nominal nominal) throws wybs.lang.NameResolver.ResolutionError
wybs.lang.NameResolver.ResolutionErrorprotected T construct(AbstractTypeExtractor.Disjunct type) throws wybs.lang.NameResolver.ResolutionError
type - wybs.lang.NameResolver.ResolutionErrorprotected boolean isVoid(AbstractTypeExtractor.Conjunct type) throws wybs.lang.NameResolver.ResolutionError
void or
not. For example, int & !int is equivalent to
void. Likewise, {int f} & !{any f} is
equivalent to void.type - wybs.lang.NameResolver.ResolutionErrorprotected T construct(AbstractTypeExtractor.Conjunct type)
protected abstract T construct(WyalFile.Type.Atom type)
protected WyalFile.Type unionHelper(WyalFile.Type lhs, WyalFile.Type rhs)
int with int will return int
rather than int|int.lhs - rhs - protected WyalFile.Type intersectionHelper(WyalFile.Type lhs, WyalFile.Type rhs)
int with int will return
int rather than int&int.lhs - rhs - Copyright © 2017. All rights reserved.