public class ExplicitCoercionOperator extends SubtypeOperator
The explicit coercion operator extends the implicit coercion operator to include coercions which must be specified with an explicit cast operation. This is necessary because such coercions correspond to a loss of precision and, hence, may fail at runtime. An example is the following
char f(int x):
return (char) x
The above will only compile if the explicit (char) cast is
provided. This is required because a char corresponds only to a
subset of the possible integers (i.e. those codepoints defined by the Unicode
standard). The semantics of the Whiley language dictate that, should the
integer lie outside the range of permissible code points, then a runtime
fault is raised.
from, to| Constructor and Description |
|---|
ExplicitCoercionOperator(Automaton fromAutomata,
Automaton toAutomata,
LifetimeRelation lr) |
| Modifier and Type | Method and Description |
|---|---|
protected boolean |
intersectRecords(int fromIndex,
boolean fromSign,
int toIndex,
boolean toSign)
Check for intersection between two states with kind K_RECORD.
|
boolean |
isIntersectionInner(int fromIndex,
boolean fromSign,
int toIndex,
boolean toSign) |
isIntersection, isSubtype, isSupertypepublic ExplicitCoercionOperator(Automaton fromAutomata, Automaton toAutomata, LifetimeRelation lr)
public boolean isIntersectionInner(int fromIndex,
boolean fromSign,
int toIndex,
boolean toSign)
isIntersectionInner in class SubtypeOperatorprotected boolean intersectRecords(int fromIndex,
boolean fromSign,
int toIndex,
boolean toSign)
Check for intersection between two states with kind K_RECORD. The distinction between open and closed records adds complexity here.
Intersection between closed records is the easiest case. The main examples are:
{T1 f, T2 g} & {T3 f, T4 g} = if T1&T3 and T2&T4.{T1 f, T2 g} & {T3 f, T4 h} = false.{T1 f, T2 g} & !{T3 f, T4 g} = if T1&!T3 or T2&!T4.{T1 f, T2 g} & !{T3 f} = false.!{T1 f} & !{T2 f} = true.Intersection between a closed and open record is similar. The main examples are:
{T1 f, T2 g, ...} & {T3 f, T4 g} = if T1&T3 and T2&T4.{T1 f, ...} & {T2 f, T3 g} = if T1&T2.{T1 f, T2 g, ...} & {T3 f, T4 h} = false.{T1 f, T2 g, ...} & !{T3 f, T4 g} = if T1&!T3 or T2&!T4.!{T1 f, T2 g, ...} & {T3 f, T4 g} = if T1&!T3 or T2&!T4.{T1 f, ...} & !{T2 f, T3 g} = true.{T1 f, T2 g, ...} & !{T3 f, T4 h} = false.!{T1 f,...} & !{T2 f} = true.intersectRecords in class SubtypeOperatorfromIndex - --- index of from statefromSign - --- sign of from state (true = normal, false = inverted).toIndex - --- index of to statetoSign - --- sign of from state (true = normal, false = inverted).Copyright © 2017. All rights reserved.