|
|
|
@ -129,10 +129,17 @@ type 'a data = {
|
|
|
|
|
mutable mark: mark;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
(* [adjust_rank data k] is equivalent to [data.rank <- min k data.rank]. *)
|
|
|
|
|
exception VariableEscapeScope of rank * rank
|
|
|
|
|
|
|
|
|
|
(* [adjust_rank data k] is equivalent to [data.rank <- min k data.rank].
|
|
|
|
|
Only flexible variables can decrease their ranks. *)
|
|
|
|
|
|
|
|
|
|
let adjust_rank (data : 'a data) (k : rank) =
|
|
|
|
|
if k < data.rank then data.rank <- k
|
|
|
|
|
if k < data.rank then
|
|
|
|
|
if data.status = Flexible then
|
|
|
|
|
data.rank <- k
|
|
|
|
|
else
|
|
|
|
|
raise (VariableEscapeScope (k, data.rank))
|
|
|
|
|
|
|
|
|
|
(* The module [Data] satisfies the signature [USTRUCTURE] required by the
|
|
|
|
|
functor [Unifier.Make]. *)
|
|
|
|
@ -445,7 +452,7 @@ let discover_young_generation () =
|
|
|
|
|
discovering a variable [v] cannot improve the value of [k] that we are
|
|
|
|
|
pushing down).
|
|
|
|
|
|
|
|
|
|
In the presence of cycles, the upward propation phase is incomplete, in the
|
|
|
|
|
In the presence of cycles, the upward propagation phase is incomplete, in the
|
|
|
|
|
sense that it may compute ranks that are higher than necessary. For
|
|
|
|
|
instance, imagine a cycle at rank 2, such that every leaf that is reachable
|
|
|
|
|
from this cycle is at rank 1. Then, in principle, this cycle can be demoted
|
|
|
|
@ -668,7 +675,7 @@ let schemify (root : variable) : scheme =
|
|
|
|
|
let exit ~rectypes roots =
|
|
|
|
|
|
|
|
|
|
(* Because calls to [enter] and [exit] must be balanced, we must have: *)
|
|
|
|
|
assert (state.young >= 0);
|
|
|
|
|
assert (state.young >= base_rank);
|
|
|
|
|
|
|
|
|
|
(* Discover the young variables. *)
|
|
|
|
|
let generation = discover_young_generation() in
|
|
|
|
|