@@ -4,22 +4,16 @@ package typer
4
4
5
5
// Modelling the decision in IsFullyDefined
6
6
object InstantiateModel :
7
- enum LB { case NN ; case LL ; case L1 }; import LB .*
8
- enum UB { case AA ; case UU ; case U1 }; import UB .*
9
- enum Var { case V ; case NotV }; import Var .*
10
- enum MSe { case M ; case NotM }; import MSe .*
11
- enum Bot { case Fail ; case Ok ; case Flip }; import Bot .*
12
- enum Act { case Min ; case Max ; case ToMax ; case Skip ; case False }; import Act .*
7
+ enum LB { case NN ; case LL ; case L1 }; import LB .*
8
+ enum UB { case AA ; case UU ; case U1 }; import UB .*
9
+ enum Decision { case Min ; case Max ; case ToMax ; case Skip ; case Fail }; import Decision .*
13
10
14
11
// NN/AA = Nothing/Any
15
12
// LL/UU = the original bounds, on the type parameter
16
13
// L1/U1 = the constrained bounds, on the type variable
17
- // V = variance >= 0 ("non-contravariant")
18
- // MSe = minimisedSelected
19
- // Bot = IfBottom
20
14
// ToMax = delayed maximisation, via addition to toMaximize
21
15
// Skip = minimisedSelected "hold off instantiating"
22
- // False = return false
16
+ // Fail = IfBottom.fail's bail option
23
17
24
18
// there are 9 combinations:
25
19
// # | LB | UB | d | // d = direction
@@ -34,24 +28,27 @@ object InstantiateModel:
34
28
// 8 | NN | UU | 0 | T <: UU
35
29
// 9 | NN | AA | 0 | T
36
30
37
- def decide (lb : LB , ub : UB , v : Var , bot : Bot , m : MSe ) : Act = (lb, ub) match
31
+ def instDecision (lb : LB , ub : UB , v : Int , ifBottom : IfBottom , min : Boolean ) = (lb, ub) match
38
32
case (L1 , AA ) => Min
39
33
case (L1 , UU ) => Min
40
34
case (LL , U1 ) => Max
41
35
case (NN , U1 ) => Max
42
36
43
- case (L1 , U1 ) => if m== M || v== V then Min else ToMax
44
- case (LL , UU ) => if m== M || v== V then Min else ToMax
45
- case (LL , AA ) => if m== M || v== V then Min else ToMax
46
-
47
- case (NN , UU ) => bot match
48
- case _ if m== M => Max
49
- // case Ok if v==V => Min // removed, i14218 fix
50
- case Fail if v== V => False
51
- case _ => ToMax
52
-
53
- case (NN , AA ) => bot match
54
- case _ if m== M => Skip
55
- case Ok if v== V => Min
56
- case Fail if v== V => False
57
- case _ => ToMax
37
+ case (L1 , U1 ) => if min then Min else pickVar(v, Min , Min , ToMax )
38
+ case (LL , UU ) => if min then Min else pickVar(v, Min , Min , ToMax )
39
+ case (LL , AA ) => if min then Min else pickVar(v, Min , Min , ToMax )
40
+
41
+ case (NN , UU ) => ifBottom match
42
+ case _ if min => Max
43
+ case IfBottom .ok => pickVar(v, Min , ToMax , ToMax )
44
+ case IfBottom .fail => pickVar(v, Fail , Fail , ToMax )
45
+ case IfBottom .flip => ToMax
46
+
47
+ case (NN , AA ) => ifBottom match
48
+ case _ if min => Skip
49
+ case IfBottom .ok => pickVar(v, Min , Min , ToMax )
50
+ case IfBottom .fail => pickVar(v, Fail , Fail , ToMax )
51
+ case IfBottom .flip => ToMax
52
+
53
+ def pickVar [A ](v : Int , cov : A , inv : A , con : A ) =
54
+ if v > 0 then cov else if v == 0 then inv else con
0 commit comments