@@ -17,6 +17,14 @@ let eq_cunit x y =
1717 | Signature s1 , Signature s2 -> Hashtbl. hash s1 == Hashtbl. hash s2 (* BUG *)
1818 | _ -> false
1919
20+ [%% if coq = " 8.20" || coq = " 9.0" ]
21+ let my_filtered_open = Libobject. simple_open
22+ let my_simple_open ?cat f = my_filtered_open ?cat (fun i v -> if Int. equal i 1 then f v)
23+ [%% else ]
24+ let my_filtered_open = Libobject. filtered_open
25+ let my_simple_open = Libobject. simple_open
26+ [%% endif]
27+
2028
2129module SLMap = Map. Make (struct type t = qualified_name let compare = compare_qualified_name end )
2230module SLSet = Set. Make (struct type t = qualified_name let compare = compare_qualified_name end )
@@ -356,7 +364,7 @@ let in_source : Names.Id.t -> string option * EC.compilation_unit * EC.flags ->
356364 subst_function = (fun _ -> CErrors. user_err Pp. (str" elpi: No functors" ));
357365 load_function = import;
358366 cache_function = cache;
359- open_function = simple_open import;
367+ open_function = my_filtered_open import;
360368 discharge_function = (fun o -> Some o);
361369 classify_function = (fun _ -> Keep );
362370 }
@@ -550,8 +558,6 @@ let get ?(fail_if_not_exists=false) p =
550558 if Int. equal i 1 ||
551559 (s.scope = Rocq_elpi_utils. Global && is_inside_current_library kn) ||
552560 s.scope = Rocq_elpi_utils. SuperGlobal then cache o in
553- let import i (_ ,s as o ) =
554- if Int. equal i 1 then cache o in
555561 declare_named_object @@ { (default_object " ELPI-DB" ) with
556562 classify_function = (fun { scope; program; _ } ->
557563 match scope with
@@ -562,7 +568,7 @@ let get ?(fail_if_not_exists=false) p =
562568 load_function = load;
563569 cache_function = cache;
564570 subst_function = (fun (_ ,o ) -> o);
565- open_function = simple_open import ;
571+ open_function = my_simple_open cache ;
566572 discharge_function = (fun (({ scope; program; vars; } as o )) ->
567573 if scope = Rocq_elpi_utils. Local || (List. exists (fun x -> Lib. is_in_section (Names.GlobRef. VarRef x)) vars) then None
568574 else Some o);
@@ -573,14 +579,12 @@ let get ?(fail_if_not_exists=false) p =
573579 let cache ((_ ,kn ),((_ ,name ),p )) =
574580 file_name_src := SLMap. add name p ! file_name_src in
575581 let load i ((_ ,kn ),_ as o ) = cache o in
576- let import i (_ ,s as o ) =
577- if Int. equal i 1 then cache o in
578582 declare_named_object @@ { (default_object " ELPI-FILE" ) with
579583 classify_function = (fun _ -> Keep );
580584 load_function = load;
581585 cache_function = cache;
582586 subst_function = (fun (_ ,o ) -> o);
583- open_function = simple_open import ;
587+ open_function = my_simple_open cache ;
584588 discharge_function = (fun o -> Some o);
585589 }
586590
0 commit comments