| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
let with_modified_ref ?(restore=true) r nf f x = |
| 14 |
let acquire x = let old_ref = !r in r := nf !r; (old_ref, !r, x) in |
| 15 |
let release (old_ref, pre, _) = |
| 16 |
|
| 17 |
if restore || pre == !r then r := old_ref; |
| 18 |
r := old_ref |
| 19 |
in |
| 20 |
let scope (old_ref, pre, x) = f x in |
| 21 |
Memprof_coq.Masking.with_resource ~acquire x ~scope ~release |
| 22 |
|
| 23 |
let with_option o f x = with_modified_ref ~restore:false o (fun _ -> true) f x |
| 24 |
let without_option o f x = with_modified_ref ~restore:false o (fun _ -> false) f x |
| 25 |
|
| 26 |
|
| 27 |
let with_modified_ref r nf f x = with_modified_ref r nf f x |
| 28 |
|
| 29 |
let with_options ol f x = |
| 30 |
let vl = List.map (!) ol in |
| 31 |
let () = List.iter (fun r -> r := true) ol in |
| 32 |
try |
| 33 |
let r = f x in |
| 34 |
let () = List.iter2 (:=) ol vl in r |
| 35 |
with reraise -> |
| 36 |
let reraise = Exninfo.capture reraise in |
| 37 |
let () = List.iter2 (:=) ol vl in |
| 38 |
Exninfo.iraise reraise |
| 39 |
|
| 40 |
let async_proofs_worker_id = ref "master" |
| 41 |
let async_proofs_is_worker () = !async_proofs_worker_id <> "master" |
| 42 |
|
| 43 |
let in_debugger = ref false |
| 44 |
let in_ml_toplevel = ref false |
| 45 |
|
| 46 |
let in_synterp_phase = ref None |
| 47 |
|
| 48 |
|
| 49 |
let beautify = ref false |
| 50 |
let beautify_file = ref false |
| 51 |
|
| 52 |
|
| 53 |
let quiet = ref false |
| 54 |
let silently f x = with_option quiet f x |
| 55 |
let verbosely f x = without_option quiet f x |
| 56 |
|
| 57 |
let if_silent f x = if !quiet then f x |
| 58 |
let if_verbose f x = if not !quiet then f x |
| 59 |
|
| 60 |
let test_mode = ref false |