Source file effectWConEq.ml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
(** ([effectWConEq]). *)
open Batteries
open Goblint_constraint.ConstrSys
module Make =
functor (S:EqConstrSys) ->
functor (HM:Hashtbl.S with type key = S.v) ->
struct
include Generic.SolverStats (S) (HM)
module VS = BatSet.Make (S.Var)
let solve st vs =
let infl = HM.create 10 in
let stable = HM.create 10 in
let rho = HM.create 10 in
let rec solve x =
if not (HM.mem rho x) then begin
HM.add rho x (S.Dom.bot ());
HM.replace infl x VS.empty
end;
HM.replace stable x ();
set x (eq x (eval x) set)
and eq x get set =
eval_rhs_event x;
match S.system x with
| None -> S.Dom.bot ()
| Some f -> f get set
and eval x y =
get_var_event y;
if not (HM.mem stable y) then solve y;
HM.replace infl y (VS.add x (try HM.find infl y with Not_found -> VS.empty));
HM.find rho y
and set x d =
if not (HM.mem rho x) then solve x;
let old = HM.find rho x in
let tmp = S.Dom.join old d in
update_var_event x old tmp;
if not (S.Dom.equal old tmp) then begin
HM.replace rho x tmp;
let w = try HM.find infl x with Not_found -> VS.empty in
HM.replace infl x VS.empty;
VS.iter (HM.remove stable) w;
VS.iter solve w
end
in
let set_start (x,d) =
HM.replace rho x d;
in
start_event ();
List.iter set_start st;
List.iter solve vs;
stop_event ();
HM.clear stable;
HM.clear infl ;
rho
end
let _ =
Selector.add_solver ("effectWConEq", (module PostSolver.DemandEqIncrSolverFromEqSolver (Make)));