public final class TypeAlgorithms extends Object
Type Intersection. Here, the intersection of two types is calculated. This is necessary for determining the updated type after a runtime type test. Essentially, we intersect the original type with the tested type to produce something new.
Type Simplification. Here, a number of simplification rules are
provided which reduce non-sensical forms into something sensible. For
example, int|int is a non-sensical form, and should be
simplified to just int.
| Modifier and Type | Field and Description |
|---|---|
static Comparator<Automaton.State> |
DATA_COMPARATOR
The data comparator is used in the type canonicalisation process.
|
| Constructor and Description |
|---|
TypeAlgorithms() |
| Modifier and Type | Method and Description |
|---|---|
static boolean |
isContractive(Automaton automaton)
Contractive types are types which cannot accept value because they have
an unterminated cycle.
|
static void |
simplify(Automaton automaton)
Analyse an automaton and try to produce a version that is simpler but
still equivalent.
|
public static final Comparator<Automaton.State> DATA_COMPARATOR
public static boolean isContractive(Automaton automaton)
Contractive types are types which cannot accept value because they have
an unterminated cycle. An unterminated cycle has no leaf nodes
terminating it. For example, X<{X field}> is contractive,
where as X<{null|X field}> is not.
This method returns true if the type is contractive, or contains a
contractive subcomponent. For example, null|X<{X field}> is
considered contracted.
type - --- type to test for contractivity.public static void simplify(Automaton automaton)
automaton - --- automaton to simplify.Copyright © 2017. All rights reserved.