Debian Codegraph @

library/lib.mli

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 open Names
12
13 (** Lib: record of operations, backtrack, low-level sections *)
14
15 (** This module provides a general mechanism to keep a trace of all operations
16 and to backtrack (undo) those operations. It provides also the section
17 mechanism (at a low level; discharge is not known at this step). *)
18
19 type is_type = bool (* Module Type or just Module *)
20 type export_flag = Export | Import
21 type export = (export_flag * Libobject.open_filter) option (* None for a Module Type *)
22
23 val make_oname : Libobject.object_prefix -> Names.Id.t -> Libobject.object_name
24 val make_foname : Names.Id.t -> Libobject.object_name
25
26 type 'summary node =
27 | CompilingLibrary of Libobject.object_prefix
28 | OpenedModule of is_type * export * Libobject.object_prefix * 'summary
29 | OpenedSection of Libobject.object_prefix * 'summary
30
31 (** Extract the [object_prefix] component. Note that it is the prefix
32 of the objects *inside* this node, eg in [Module M.] we have
33 [OpenedModule] with prefix containing [M]. *)
34 val node_prefix : 'summary node -> Libobject.object_prefix
35
36 type 'summary library_segment = ('summary node * Libobject.t list) list
37
38 (** {6 ... } *)
39 (** Adding operations (which call the [cache] method, and getting the
40 current list of operations (most recent ones coming first). *)
41
42 val add_leaf : Libobject.obj -> unit
43
44 val add_discharged_leaf : Libobject.discharged_obj -> unit
45
46 (** {6 ... } *)
47
48 (** The function [contents] gives access to the current entire segment *)
49
50 val contents : unit -> Summary.Interp.frozen library_segment
51
52 (** {6 Functions relative to current path } *)
53
54 (** User-side names
55
56 [cwd()] is [(prefix()).obj_dir]
57 [current_mp()] is [(prefix()).obj_mp]
58
59 Inside a library A.B module M section S, we have
60 - library_dp = A.B
61 - cwd = A.B.M.S
62 - cwd_except_section = A.B.M
63 - current_dirpath true = M.S
64 - current_dirpath false = M
65 - current_mp = MPdot(MPfile A.B, M)
66
67 make_path (resp make_path_except_section) uses cwd (resp cwd_except_section)
68 make_kn uses current_mp
69 *)
70 val prefix : unit -> Libobject.object_prefix
71 val cwd : unit -> Libnames.full_path
72 val cwd_except_section : unit -> Libnames.full_path
73 val current_dirpath : bool -> DirPath.t (* false = except sections *)
74 val make_path : Id.t -> Libnames.full_path
75 val make_path_except_section : Id.t -> Libnames.full_path
76
77 (** Kernel-side names *)
78 val current_mp : unit -> ModPath.t
79 val make_kn : Id.t -> KerName.t
80
81 (** Are we inside an opened section *)
82 val sections_are_opened : unit -> bool
83 val sections_depth : unit -> int
84
85 (** Are we inside an opened module type *)
86 val is_module_or_modtype : unit -> bool
87 val is_modtype : unit -> bool
88 (* [is_modtype_strict] checks not only if we are in a module type, but
89 if the latest module started is a module type. *)
90 val is_modtype_strict : unit -> bool
91 val is_module : unit -> bool
92
93 type discharged_item =
94 | DischargedExport of Libobject.ExportObj.t
95 | DischargedLeaf of Libobject.discharged_obj
96
97 type classified_objects = {
98 substobjs : Libobject.t list;
99 keepobjs : Libobject.keep_objects;
100 escapeobjs : Libobject.escape_objects;
101 anticipateobjs : Libobject.t list;
102 }
103
104 (** The [StagedLibS] abstraction describes operations and traversal for Lib at a
105 given stage. *)
106 module type StagedLibS = sig
107
108 type summary
109
110 (** Returns the opening node of a given name *)
111 val find_opening_node : ?loc:Loc.t -> Id.t -> summary node
112
113 val add_entry : summary node -> unit
114 val add_leaf_entry : Libobject.t -> unit
115
116 (** {6 Sections } *)
117 val open_section : Id.t -> unit
118
119 (** [close_section] needs to redo Export, so the complete
120 implementation needs to involve [Declaremods]. *)
121 val close_section : unit -> discharged_item list
122
123 (** {6 Modules and module types } *)
124
125 val start_module :
126 export -> Id.t -> ModPath.t ->
127 summary -> Libobject.object_prefix
128
129 val start_modtype :
130 Id.t -> ModPath.t ->
131 summary -> Libobject.object_prefix
132
133 val end_module :
134 unit ->
135 Libobject.object_prefix * summary * classified_objects
136
137 val end_modtype :
138 unit ->
139 Libobject.object_prefix * summary * classified_objects
140
141 type frozen
142
143 val freeze : unit -> frozen
144 val unfreeze : frozen -> unit
145 val init : unit -> unit
146
147 (** Keep only the libobject structure, not the objects themselves *)
148 val drop_objects : frozen -> frozen
149
150 val declare_info : Library_info.t -> unit
151
152 end
153
154 (** We provide two instances of [StagedLibS], corresponding to the Synterp and
155 Interp stages. *)
156
157 module Synterp : StagedLibS with type summary = Summary.Synterp.frozen
158 module Interp : StagedLibS with type summary = Summary.Interp.frozen
159
160 (** {6 Compilation units } *)
161
162 val start_compilation : DirPath.t -> ModPath.t -> unit
163
164 type compilation_result = {
165 info : Library_info.t;
166 synterp_objects : classified_objects;
167 interp_objects : classified_objects;
168 }
169
170 (** Finalize the compilation of a library. *)
171 val end_compilation : DirPath.t -> compilation_result
172
173 (** The function [library_dp] returns the [DirPath.t] of the current
174 compiling library (or [default_library]) *)
175 val library_dp : unit -> DirPath.t
176
177 (** Extract the library part of a name even if in a section *)
178 val split_modpath : ModPath.t -> DirPath.t * Id.t list
179 val library_part : GlobRef.t -> DirPath.t
180
181 (** Compatibility layer *)
182
183 (** This also does init_summaries *)
184 val init : unit -> unit