Debian Codegraph @

library/lib.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 open Util
12 open Names
13
14 type is_type = bool (* Module Type or just Module *)
15 type export_flag = Export | Import
16 type export = (export_flag * Libobject.open_filter) option (* None for a Module Type *)
17
18 let make_oname Libobject.{ obj_path; obj_mp } id =
19 Names.(Libnames.add_path_suffix obj_path id, KerName.make obj_mp id)
20
21 type 'summary node =
22 | CompilingLibrary of Libobject.object_prefix
23 | OpenedModule of is_type * export * Libobject.object_prefix * 'summary
24 | OpenedSection of Libobject.object_prefix * 'summary
25
26 let node_prefix = function
27 | CompilingLibrary prefix
28 | OpenedModule (_,_,prefix,_)
29 | OpenedSection (prefix,_) -> prefix
30
31 let prefix_id prefix = Libnames.basename prefix.Libobject.obj_path
32
33 type 'summary library_segment = ('summary node * Libobject.t list) list
34
35 let module_kind is_type =
36 if is_type then "module type" else "module"
37
38 type classified_objects = {
39 substobjs : Libobject.t list;
40 keepobjs : Libobject.keep_objects;
41 escapeobjs : Libobject.escape_objects;
42 anticipateobjs : Libobject.t list;
43 }
44
45 let empty_classified = {
46 substobjs = [];
47 keepobjs = { keep_objects = [] };
48 escapeobjs = { escape_objects = [] };
49 anticipateobjs = [];
50 }
51
52 let classify_object : Libobject.t -> Libobject.substitutivity = function
53 | ModuleObject _ | ModuleTypeObject _ | IncludeObject _ | ExportObject _ -> Substitute
54 | KeepObject _ -> Keep
55 | EscapeObject _ -> Escape
56 | AtomicObject o -> Libobject.classify_object o
57
58 let classify_segment seg =
59 let rec clean acc = function
60 | [] -> acc
61 | o :: stk ->
62 begin match classify_object o with
63 | Dispose -> clean acc stk
64 | Substitute ->
65 clean {acc with substobjs = o :: acc.substobjs} stk
66 | Keep ->
67 clean {acc with keepobjs = { keep_objects = o :: acc.keepobjs.keep_objects } } stk
68 | Escape ->
69 clean {acc with escapeobjs = { escape_objects = o :: acc.escapeobjs.escape_objects } } stk
70 | Anticipate ->
71 clean {acc with anticipateobjs = o :: acc.anticipateobjs} stk
72 end
73 in
74 clean empty_classified (List.rev seg)
75
76 let find_entries_p p stk =
77 let rec find = function
78 | [] -> []
79 | (ent,_)::l -> if p ent then ent::find l else find l
80 in
81 find stk
82
83 let split_lib_at_opening stk =
84 match stk with
85 | [] -> assert false
86 | (node,leaves) :: rest -> List.rev leaves, node, rest
87
88 let is_opening_node = function
89 | OpenedSection _ | OpenedModule _ -> true
90 | CompilingLibrary _ -> false
91
92 let open_blocks_message es =
93 let open Pp in
94 let open_block_name = function
95 | OpenedSection (prefix,_) ->
96 str "section " ++ Id.print (prefix_id prefix)
97 | OpenedModule (ty,_,prefix,_) ->
98 str (module_kind ty) ++ spc () ++ Id.print (prefix_id prefix)
99 | _ -> assert false
100 in
101 str "The " ++ pr_enum open_block_name es ++ spc () ++
102 str "need" ++ str (if List.length es == 1 then "s" else "") ++
103 str " to be closed."
104
105 (* We keep trace of operations in the stack [lib_stk].
106 [path_prefix] is the current path of sections, where sections are stored in
107 ``correct'' order, the oldest coming first in the list. It may seems
108 costly, but in practice there is not so many openings and closings of
109 sections, but on the contrary there are many constructions of section
110 paths based on the library path. *)
111
112 let dummy_prefix = Libobject.{
113 obj_path = Libnames.dummy_full_path;
114 obj_mp = ModPath.dummy;
115 }
116
117 type synterp_state = {
118 comp_name : DirPath.t option;
119 lib_stk : Summary.Synterp.frozen library_segment;
120 path_prefix : Libobject.object_prefix;
121 }
122
123 let dummy = {
124 comp_name = None;
125 lib_stk = [];
126 path_prefix = dummy_prefix;
127 }
128
129 (** The lib state is split in two components:
130 - The synterp stage state which manages a recording of syntax-related objects and naming-related data (compilation unit name, current prefix).
131 - The interp stage state which manages a recording of regular objects.
132 *)
133
134 let synterp_state = ref dummy
135 let interp_state = ref ([] : Summary.Interp.frozen library_segment)
136
137 let library_info = ref UserWarn.empty
138
139 let contents () = !interp_state
140
141 let start_compilation s mp =
142 if !synterp_state.comp_name != None then
143 CErrors.user_err Pp.(str "compilation unit is already started");
144 assert (List.is_empty !synterp_state.lib_stk);
145 assert (List.is_empty !interp_state);
146 let path = try
147 let prefix, id = Libnames.split_dirpath s in
148 Libnames.make_path prefix id
149 with Failure _ -> CErrors.anomaly Pp.(str "Cannot start compilation with empty dirpath")
150 in
151 let prefix = Libobject.{ obj_path = path; obj_mp = mp } in
152 let initial_stk = [ CompilingLibrary prefix, [] ] in
153 let st = {
154 comp_name = Some s;
155 path_prefix = prefix;
156 lib_stk = initial_stk;
157 }
158 in
159 synterp_state := st;
160 interp_state := initial_stk;
161 Nametab.OpenMods.push (Until 1) path (DirOpenModule mp)
162
163 let end_compilation_checks dir =
164 let () = match find_entries_p is_opening_node !interp_state with
165 | [] -> ()
166 | es -> CErrors.user_err (open_blocks_message es) in
167 let () =
168 match !synterp_state.comp_name with
169 | None -> CErrors.anomaly (Pp.str "There should be a module name...")
170 | Some m ->
171 if not (Names.DirPath.equal m dir) then
172 CErrors.anomaly Pp.(str "The current open module has name"
173 ++ spc () ++ DirPath.print m ++ spc () ++ str "and not"
174 ++ spc () ++ DirPath.print dir ++ str ".");
175 in
176 ()
177
178 let library_dp () =
179 match !synterp_state.comp_name with Some m -> m | None -> DirPath.dummy
180
181 (* [path_prefix] is a pair of absolute dirpath and a pair of current
182 module path and relative section path *)
183
184 let prefix () = !synterp_state.path_prefix
185 let cwd () = !synterp_state.path_prefix.Libobject.obj_path
186 let current_mp () = !synterp_state.path_prefix.Libobject.obj_mp
187
188 let sections_depth () =
189 !synterp_state.lib_stk |> List.count (function
190 | (OpenedSection _, _) -> true
191 | ((OpenedModule _ | CompilingLibrary _), _) -> false)
192
193 let sections_are_opened () =
194 match split_lib_at_opening !synterp_state.lib_stk with
195 | (_, OpenedSection _, _) -> true
196 | _ -> false
197
198 let cwd_except_section () =
199 Libnames.path_pop_n_suffixes (sections_depth ()) (cwd ())
200
201 let current_dirpath sec =
202 Libnames.drop_dirpath_prefix (library_dp ())
203 (Libnames.dirpath_of_path (if sec then cwd () else cwd_except_section ()))
204
205 let make_path id = Libnames.add_path_suffix (cwd ()) id
206
207 let make_path_except_section id =
208 Libnames.add_path_suffix (cwd_except_section ()) id
209
210 let make_kn id =
211 let mp = current_mp () in
212 Names.KerName.make mp id
213
214 let make_foname id = make_oname !synterp_state.path_prefix id
215
216 (* Adding operations. *)
217
218 let dummylib = CompilingLibrary dummy_prefix
219
220 let error_still_opened s oname =
221 CErrors.user_err Pp.(str "The " ++ str s ++ str " "
222 ++ Id.print (prefix_id oname) ++ str " is still opened.")
223
224 let recalc_path_prefix () =
225 let path_prefix = match pi2 (split_lib_at_opening !synterp_state.lib_stk) with
226 | CompilingLibrary dir
227 | OpenedModule (_, _, dir, _)
228 | OpenedSection (dir, _) -> dir
229 in
230 synterp_state := { !synterp_state with path_prefix }
231
232 let pop_path_prefix () =
233 let op = !synterp_state.path_prefix in
234 synterp_state := {
235 !synterp_state
236 with path_prefix = Libobject.{
237 op with obj_path = Libnames.path_pop_suffix op.obj_path;
238 } }
239
240 (* Modules. *)
241
242 (* Returns true if we are inside an opened module or module type *)
243 let is_module_or_modtype () =
244 let rec aux = function
245 | [] -> assert false
246 | (OpenedSection _, _) :: rest -> aux rest
247 | (OpenedModule _, _) :: _ -> true
248 | (CompilingLibrary _, _) :: _ -> false
249 in
250 aux (!synterp_state).lib_stk
251
252 let is_modtype () =
253 List.exists (function OpenedModule (istyp, _, _, _), _ -> istyp | _ -> false)
254 (!synterp_state).lib_stk
255
256 let is_modtype_strict () =
257 let rec aux = function
258 | [] -> assert false
259 | (OpenedSection _, _) :: rest -> aux rest
260 | (OpenedModule (istyp, _, _, _), _) :: _ -> istyp
261 | (CompilingLibrary _, _) :: _ -> false
262 in
263 aux (!synterp_state).lib_stk
264
265 let is_module () =
266 List.exists (function OpenedModule (istyp, _, _, _), _ -> not istyp | _ -> false)
267 (!synterp_state).lib_stk
268
269 (* Discharge tables *)
270
271 (* At each level of section, we remember
272 - the list of variables in this section
273 - the list of variables on which each constant depends in this section
274 - the list of variables on which each inductive depends in this section
275 - the list of substitution to do at section closing
276 *)
277
278 type discharged_item =
279 | DischargedExport of Libobject.ExportObj.t
280 | DischargedLeaf of Libobject.discharged_obj
281
282 let discharge_item = Libobject.(function
283 | ModuleObject _ | ModuleTypeObject _ | IncludeObject _ | KeepObject _ | EscapeObject _ ->
284 assert false
285 | ExportObject o -> Some (DischargedExport o)
286 | AtomicObject obj ->
287 let obj = discharge_object obj in
288 Option.map (fun o -> DischargedLeaf o) obj)
289
290 (* Misc *)
291
292 let mp_of_global = let open GlobRef in function
293 | VarRef id -> !synterp_state.path_prefix.Libobject.obj_mp
294 | ConstRef cst -> Names.Constant.modpath cst
295 | IndRef ind -> Names.Ind.modpath ind
296 | ConstructRef constr -> Names.Construct.modpath constr
297
298 let rec split_modpath = function
299 |Names.MPfile dp -> dp, []
300 |Names.MPbound mbid -> library_dp (), [Names.MBId.to_id mbid]
301 |Names.MPdot (mp,l) ->
302 let (dp,ids) = split_modpath mp in
303 (dp, l :: ids)
304
305 let library_part = function
306 | GlobRef.VarRef id -> library_dp ()
307 | ref -> ModPath.dp (mp_of_global ref)
308
309 let debug_object_name = function
310 | Libobject.ModuleObject _ -> "ModuleObject"
311 | ModuleTypeObject _-> "ModuleTypeObject"
312 | IncludeObject _ -> "IncludeObject"
313 | KeepObject _ -> "KeepObject"
314 | EscapeObject _ -> "EscapeObject"
315 | ExportObject _ -> "ExportObject"
316 | AtomicObject (Dyn (tag,_)) -> Libobject.Dyn.repr tag
317
318 let anomaly_unitialized_add_leaf stage o =
319 CErrors.anomaly
320 Pp.(str "cannot add object (" ++ str (debug_object_name o) ++ pr_comma() ++
321 str "in " ++ str stage ++ str "): not initialized")
322
323 (** The [LibActions] abstraction represent the set of operations on the Lib
324 structure that is specific to a given stage. Two instances are defined below,
325 for Synterp and Interp. *)
326 module type LibActions = sig
327
328 type summary
329 val stage : Summary.Stage.t
330 val open_section : Id.t -> unit
331
332 val close_section : summary -> unit
333
334 val add_entry : summary node -> unit
335 val add_leaf_entry : Libobject.t -> unit
336 val start_mod : is_type:is_type -> export -> Id.t -> ModPath.t -> summary -> Libobject.object_prefix
337
338 val get_lib_stk : unit -> summary library_segment
339 val set_lib_stk : summary library_segment -> unit
340
341 val pop_path_prefix : unit -> unit
342 val recalc_path_prefix : unit -> unit
343
344 type frozen
345 val freeze : unit -> frozen
346 val unfreeze : frozen -> unit
347 val init : unit -> unit
348
349 val drop_objects : frozen -> frozen
350
351 val declare_info : Library_info.t -> unit
352
353 end
354
355 module SynterpActions : LibActions with type summary = Summary.Synterp.frozen = struct
356
357 type summary = Summary.Synterp.frozen
358 let stage = Summary.Stage.Synterp
359
360 let check_section_fresh obj_path id =
361 if Nametab.exists_dir obj_path then
362 CErrors.user_err Pp.(Id.print id ++ str " already exists.")
363
364 let push_section_name obj_path =
365 Nametab.(push_dir (Until 1) obj_path (GlobDirRef.DirOpenSection obj_path))
366
367 let close_section fs = Summary.Synterp.unfreeze_summaries fs
368
369 let add_entry node =
370 synterp_state := { !synterp_state with lib_stk = (node,[]) :: !synterp_state.lib_stk }
371
372 let add_leaf_entry leaf =
373 let lib_stk = match !synterp_state.lib_stk with
374 | [] ->
375 (* top_printers does set_bool_option_value which adds a leaf *)
376 if !Flags.in_debugger then [dummylib, [leaf]] else anomaly_unitialized_add_leaf "synterp" leaf
377 | (node, leaves) :: rest -> (node, leaf :: leaves) :: rest
378 in
379 synterp_state := { !synterp_state with lib_stk }
380
381 (* Returns the opening node of a given name *)
382 let start_mod ~is_type export id mp fs =
383 let dir = Libnames.add_path_suffix !synterp_state.path_prefix.Libobject.obj_path id in
384 let prefix = Libobject.{ obj_path = dir; obj_mp = mp; } in
385 assert (not (sections_are_opened()));
386 add_entry (OpenedModule (is_type,export,prefix,fs));
387 synterp_state := { !synterp_state with path_prefix = prefix } ;
388 prefix
389
390 let get_lib_stk () =
391 !synterp_state.lib_stk
392
393 let set_lib_stk stk =
394 synterp_state := { !synterp_state with lib_stk = stk }
395
396 let open_section id =
397 let opp = !synterp_state.path_prefix in
398 let obj_path = Libnames.add_path_suffix opp.Libobject.obj_path id in
399 let prefix = Libobject.{ obj_path; obj_mp=opp.obj_mp; } in
400 check_section_fresh obj_path id;
401 let fs = Summary.Synterp.freeze_summaries () in
402 add_entry (OpenedSection (prefix, fs));
403 (*Pushed for the lifetime of the section: removed by unfreezing the summary*)
404 push_section_name obj_path;
405 synterp_state := { !synterp_state with path_prefix = prefix }
406
407 let pop_path_prefix () = pop_path_prefix ()
408 let recalc_path_prefix () = recalc_path_prefix ()
409
410 type frozen = synterp_state
411
412 let freeze () = !synterp_state
413
414 let unfreeze st =
415 synterp_state := st
416
417 let init () =
418 synterp_state := dummy
419
420 let drop_objects st =
421 let drop_node = function
422 | CompilingLibrary _ as x -> x
423 | OpenedModule (it,e,op,_) ->
424 OpenedModule(it,e,op,Summary.Synterp.empty_frozen)
425 | OpenedSection (op, _) ->
426 OpenedSection(op,Summary.Synterp.empty_frozen)
427 in
428 let lib_synterp_stk = List.map (fun (node,_) -> drop_node node, []) st.lib_stk in
429 { st with lib_stk = lib_synterp_stk }
430
431 let declare_info info =
432 let open UserWarn in
433 let depr = match !library_info.depr, info.depr with
434 | None, depr | depr, None -> depr
435 | Some _, Some _ ->
436 CErrors.user_err Pp.(str "Library file is already deprecated.") in
437 let warn = !library_info.warn @ info.warn in
438 library_info := { depr; warn }
439
440 end
441
442 module InterpActions : LibActions with type summary = Summary.Interp.frozen = struct
443
444 type summary = Summary.Interp.frozen
445
446 let stage = Summary.Stage.Interp
447
448 let close_section fs = Global.close_section fs
449
450 let add_entry node =
451 interp_state := (node,[]) :: !interp_state
452
453 let add_leaf_entry leaf =
454 let lib_stk = match !interp_state with
455 | [] ->
456 (* top_printers does set_bool_option_value which adds a leaf *)
457 if !Flags.in_debugger then [dummylib, [leaf]] else anomaly_unitialized_add_leaf "interp" leaf
458 | (node, leaves) :: rest -> (node, leaf :: leaves) :: rest
459 in
460 interp_state := lib_stk
461
462 (* Returns the opening node of a given name *)
463 let start_mod ~is_type export id mp fs =
464 let prefix = !synterp_state.path_prefix in
465 add_entry (OpenedModule (is_type,export,prefix,fs));
466 prefix
467
468 let get_lib_stk () =
469 !interp_state
470
471 let set_lib_stk stk =
472 interp_state := stk
473
474 let open_section id =
475 Global.open_section ();
476 let prefix = !synterp_state.path_prefix in
477 let fs = Summary.Interp.freeze_summaries () in
478 add_entry (OpenedSection (prefix, fs))
479
480 let pop_path_prefix () = ()
481 let recalc_path_prefix () = ()
482
483 type frozen = summary library_segment
484
485 let freeze () = !interp_state
486
487 let unfreeze st =
488 interp_state := st
489
490 let init () =
491 interp_state := []
492
493 let drop_objects interp_state =
494 let drop_node = function
495 | CompilingLibrary _ as x -> x
496 | OpenedModule (it,e,op,_) ->
497 OpenedModule(it,e,op,Summary.Interp.empty_frozen)
498 | OpenedSection (op, _) ->
499 OpenedSection(op,Summary.Interp.empty_frozen)
500 in
501 List.map (fun (node,_) -> drop_node node, []) interp_state
502
503 let declare_info _ = ()
504
505 end
506
507 let add_discharged_leaf obj =
508 let newobj = Libobject.rebuild_object obj in
509 Libobject.cache_object (prefix(),newobj);
510 match Libobject.object_stage newobj with
511 | Summary.Stage.Synterp ->
512 SynterpActions.add_leaf_entry (AtomicObject newobj)
513 | Summary.Stage.Interp ->
514 InterpActions.add_leaf_entry (AtomicObject newobj)
515
516 let add_leaf obj =
517 Libobject.cache_object (prefix(),obj);
518 let ostage = Libobject.object_stage obj in
519 let ok_stage = match !Flags.in_synterp_phase with
520 | None -> true
521 | Some false -> ostage == Interp
522 | Some true -> ostage == Synterp
523 in
524 let () = if not ok_stage then
525 let ppstage = match ostage with Interp -> "interp" | Synterp -> "synterp" in
526 CErrors.anomaly
527 Pp.(str "Adding object " ++
528 str (Libobject.object_name obj) ++
529 str " in incorrect stage (object_stage = " ++ str ppstage ++ str ").")
530 in
531 match ostage with
532 | Summary.Stage.Synterp ->
533 SynterpActions.add_leaf_entry (AtomicObject obj)
534 | Summary.Stage.Interp ->
535 InterpActions.add_leaf_entry (AtomicObject obj)
536
537 module type StagedLibS = sig
538
539 type summary
540
541 val find_opening_node : ?loc:Loc.t -> Id.t -> summary node
542
543 val add_entry : summary node -> unit
544 val add_leaf_entry : Libobject.t -> unit
545
546 (** {6 Sections } *)
547 val open_section : Id.t -> unit
548 val close_section : unit -> discharged_item list
549
550 (** {6 Modules and module types } *)
551 val start_module :
552 export -> Id.t -> ModPath.t ->
553 summary -> Libobject.object_prefix
554
555 val start_modtype :
556 Id.t -> ModPath.t ->
557 summary -> Libobject.object_prefix
558
559 val end_module :
560 unit ->
561 Libobject.object_prefix * summary * classified_objects
562
563 val end_modtype :
564 unit ->
565 Libobject.object_prefix * summary * classified_objects
566
567 type frozen
568
569 val freeze : unit -> frozen
570 val unfreeze : frozen -> unit
571 val init : unit -> unit
572
573 val drop_objects : frozen -> frozen
574
575 val declare_info : Library_info.t -> unit
576
577 end
578
579 (** The [StagedLib] abstraction factors out the code dealing with Lib structure
580 that is common to all stages. *)
581 module StagedLib(Actions : LibActions) : StagedLibS with type summary = Actions.summary = struct
582
583 type summary = Actions.summary
584
585 let add_entry node = Actions.add_entry node
586 let add_leaf_entry obj = Actions.add_leaf_entry obj
587
588 let open_section id = Actions.open_section id
589
590 exception WrongClosingBlockName of Id.t * Loc.t option
591
592 let () = CErrors.register_handler (function
593 | WrongClosingBlockName (id,_) ->
594 Some Pp.(str "Last block to end has name " ++ Id.print id ++ str ".")
595 | _ -> None)
596
597 let () = Quickfix.register (function
598 | WrongClosingBlockName (id, Some loc) -> [Quickfix.make ~loc (Id.print id)]
599 | _ -> [])
600
601 let find_opening_node ?loc id =
602 let entry = match Actions.get_lib_stk () with
603 | [] -> assert false
604 | (CompilingLibrary _, _) :: _ ->
605 CErrors.user_err Pp.(str "There is nothing to end.")
606 | (entry, _) :: _ -> entry
607 in
608 let id' = prefix_id (node_prefix entry) in
609 if not (Names.Id.equal id id') then
610 Loc.raise ?loc (WrongClosingBlockName(id',loc));
611 entry
612
613 let start_module = Actions.start_mod ~is_type:false
614 let start_modtype = Actions.start_mod ~is_type:true None
615
616 let end_mod ~is_type =
617 let (after,mark,before) = split_lib_at_opening (Actions.get_lib_stk ()) in
618 (* The errors here should not happen because we checked in the upper layers *)
619 let prefix, fs = match mark with
620 | OpenedModule (ty,_,prefix,fs) ->
621 if ty == is_type then prefix, fs
622 else error_still_opened (module_kind ty) prefix
623 | OpenedSection (prefix, _) -> error_still_opened "section" prefix
624 | CompilingLibrary _ -> CErrors.user_err (Pp.str "No opened modules.")
625 in
626 Actions.set_lib_stk before;
627 Actions.recalc_path_prefix ();
628 let after = classify_segment after in
629 (prefix, fs, after)
630
631 let end_module () = end_mod ~is_type:false
632 let end_modtype () = end_mod ~is_type:true
633
634 (* Restore lib_stk and summaries as before the section opening, and
635 add a ClosedSection object. *)
636 let close_section () =
637 let (secdecls,mark,before) = split_lib_at_opening (Actions.get_lib_stk ()) in
638 let fs = match mark with
639 | OpenedSection (_,fs) -> fs
640 | _ -> CErrors.user_err Pp.(str "No opened section.")
641 in
642 Actions.set_lib_stk before;
643 Actions.pop_path_prefix ();
644 let newdecls = List.filter_map discharge_item secdecls in
645 Actions.close_section fs;
646 newdecls
647
648 type frozen = Actions.frozen
649
650 let freeze () = Actions.freeze ()
651
652 let unfreeze st = Actions.unfreeze st
653
654 let init () = Actions.init ()
655
656 let drop_objects st = Actions.drop_objects st
657
658 let declare_info info = Actions.declare_info info
659
660 end
661
662 module Synterp : StagedLibS with type summary = Summary.Synterp.frozen = StagedLib(SynterpActions)
663 module Interp : StagedLibS with type summary = Summary.Interp.frozen = StagedLib(InterpActions)
664
665 type compilation_result = {
666 info : Library_info.t;
667 synterp_objects : classified_objects;
668 interp_objects : classified_objects;
669 }
670
671 let end_compilation dir =
672 end_compilation_checks dir;
673 let (syntax_after,_,syntax_before) = split_lib_at_opening !synterp_state.lib_stk in
674 let (after,_,before) = split_lib_at_opening !interp_state in
675 assert (List.is_empty syntax_before);
676 assert (List.is_empty before);
677 synterp_state := { !synterp_state with comp_name = None };
678 let syntax_after = classify_segment syntax_after in
679 let after = classify_segment after in
680 { info = !library_info; interp_objects = after; synterp_objects = syntax_after; }
681
682 (** Compatibility layer *)
683 let init () =
684 Synterp.init ();
685 Interp.init ();
686 Summary.Synterp.init_summaries ();
687 Summary.Interp.init_summaries ()