|
10 | 10 |
|
11 | 11 | open Names |
12 | 12 |
|
13 | | -let scheme_map = Summary.ref Indmap_env.empty ~name:"Schemes" |
| 13 | +let scheme_map = Summary.ref GlobRef.Map_env.empty ~name:"Schemes" |
14 | 14 |
|
15 | | -let cache_one_scheme kind (ind,const) = |
16 | | - scheme_map := Indmap_env.update ind (function |
| 15 | +let cache_one_scheme kind (gr,const) = |
| 16 | + scheme_map := GlobRef.Map_env.update gr (function |
17 | 17 | | None -> Some (CString.Map.singleton kind const) |
18 | 18 | | Some map -> Some (CString.Map.add kind const map)) |
19 | 19 | !scheme_map |
20 | 20 |
|
21 | 21 | let cache_scheme (kind,l) = |
22 | 22 | cache_one_scheme kind l |
23 | 23 |
|
24 | | -let subst_one_scheme subst (ind,const) = |
25 | | - (* Remark: const is a def: the result of substitution is a constant *) |
26 | | - (Mod_subst.subst_ind subst ind, Globnames.subst_global_reference subst const) |
| 24 | +let subst_one_scheme subst (gr,const) = |
| 25 | + (Globnames.subst_global_reference subst gr, Globnames.subst_global_reference subst const) |
27 | 26 |
|
28 | 27 | let subst_scheme (subst,(kind,l)) = |
29 | 28 | (kind, subst_one_scheme subst l) |
30 | 29 |
|
31 | | -let inScheme : Libobject.locality * (string * (inductive * GlobRef.t)) -> Libobject.obj = |
| 30 | +let inScheme : Libobject.locality * (string * (GlobRef.t * GlobRef.t)) -> Libobject.obj = |
32 | 31 | let open Libobject in |
33 | 32 | declare_object @@ object_with_locality "SCHEME" |
34 | 33 | ~cache:cache_scheme |
35 | 34 | ~subst:(Some subst_scheme) |
36 | 35 | ~discharge:(fun x -> x) |
37 | 36 |
|
38 | | -let declare_scheme local kind indcl = |
39 | | - Lib.add_leaf (inScheme (local,(kind,indcl))) |
40 | | - |
41 | | -let lookup_scheme kind ind = CString.Map.find kind (Indmap_env.find ind !scheme_map) |
42 | | - |
43 | | -let lookup_scheme_opt kind ind = |
44 | | - try Some (lookup_scheme kind ind) with Not_found -> None |
| 37 | +let declare_scheme local kind (gr, _ as grcl) = |
| 38 | + let () = match local, gr with |
| 39 | + | (Libobject.Export | Libobject.SuperGlobal), GlobRef.VarRef id -> |
| 40 | + if Global.is_in_section gr then |
| 41 | + CErrors.user_err |
| 42 | + Pp.(str "Cannot register a non-local scheme for section variable " |
| 43 | + ++ Names.Id.print id |
| 44 | + ++ str "; use the #[local] attribute.") |
| 45 | + | _, _ -> () |
| 46 | + in |
| 47 | + Lib.add_leaf (inScheme (local,(kind,grcl))) |
| 48 | + |
| 49 | +let lookup_scheme kind gr = CString.Map.find kind (GlobRef.Map_env.find gr !scheme_map) |
| 50 | + |
| 51 | +let lookup_scheme_opt kind gr = |
| 52 | + try Some (lookup_scheme kind gr) with Not_found -> None |
45 | 53 |
|
46 | 54 | let all_schemes () = !scheme_map |
0 commit comments