Debian Codegraph @

library/locality.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 (** * Managing locality *)
12
13 type import_status = ImportDefaultBehavior | ImportNeedQualified
14 type definition_scope = Discharge | Global of import_status
15
16 let default_scope = Global ImportDefaultBehavior
17
18 (** Positioning locality for commands supporting discharging and export
19 outside of modules *)
20
21 (* For commands whose default is to discharge and export:
22 Global is the default and is neutral;
23 Local in a section deactivates discharge,
24 Local not in a section deactivates export *)
25 let make_non_locality = function Some false -> false | _ -> true
26
27 let make_locality = function Some true -> true | _ -> false
28
29 let enforce_locality locality_flag =
30 make_locality locality_flag
31
32 (* For commands whose default is to not discharge but to export:
33 Global in sections forces discharge, Global not in section is the default;
34 Local in sections is the default, Local not in section forces non-export *)
35
36 let make_section_locality =
37 function Some b -> b | None -> Lib.sections_are_opened ()
38
39 let enforce_section_locality locality_flag =
40 make_section_locality locality_flag
41
42 (** Positioning locality for commands supporting export but not discharge *)
43
44 (* For commands whose default is to export (if not in section):
45 Global in sections is forbidden, Global not in section is neutral;
46 Local in sections is the default, Local not in section forces non-export *)
47
48 let make_module_locality = function
49 | Some false ->
50 if Lib.sections_are_opened () then
51 CErrors.user_err Pp.(str
52 "This command does not support the Global option in sections.");
53 false
54 | Some true -> true
55 | None -> false
56
57 let enforce_module_locality locality_flag =
58 make_module_locality locality_flag
59
60 let check_locality_nodischarge : Libobject.locality -> unit = function
61 | Local -> ()
62 | Export ->
63 if Lib.sections_are_opened () then
64 CErrors.user_err Pp.(str "This command does not support the export attribute in sections.")
65 | SuperGlobal ->
66 if Lib.sections_are_opened () then
67 CErrors.user_err Pp.(str "This command does not support the global attribute in sections.")