Debian Codegraph @

lib/flags.ml

raw symbols SCIP
1 (************************************************************************)
2 (* * The Rocq Prover / The Rocq Development Team *)
3 (* v * Copyright INRIA, CNRS and contributors *)
4 (* <O___,, * (see version control and CREDITS file for authors & dates) *)
5 (* \VV/ **************************************************************)
6 (* // * This file is distributed under the terms of the *)
7 (* * GNU Lesser General Public License Version 2.1 *)
8 (* * (see LICENSE file for the text of the license) *)
9 (************************************************************************)
10
11 (* If [restore] is false, whenever [f] modifies the ref, we will
12 preserve the modification. *)
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 (* If r was modified don't restore its old value *)
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 (* hide the [restore] option as internal *)
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 (* Translate *)
49 let beautify = ref false
50 let beautify_file = ref false
51
52 (* Silent / Verbose *)
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