blob: b84eda23a0babd3ff07b3a2debd9170a1ea1e5e9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
(* $Id$ *)
open Names
let cci_tab = ref Idmap.empty
let fw_tab = ref Idmap.empty
let fw_sp_of_id id =
Idmap.find id !fw_tab
let sp_of_id kind id =
match kind with
| FW -> Idmap.find id !fw_tab
| CCI -> Idmap.find id !cci_tab
| OBJ -> invalid_arg "Nametab.sp_of_id"
let push id sp =
match kind_of_path sp with
| FW -> fw_tab := Idmap.add id sp !fw_tab
| CCI -> cci_tab := Idmap.add id sp !cci_tab
| OBJ -> invalid_arg "Nametab.push"
(* Registration as a global table and roolback. *)
let init () =
cci_tab := Idmap.empty;
cci_tab := Idmap.empty
type frozen = section_path Idmap.t * section_path Idmap.t
let freeze () = (!cci_tab, !fw_tab)
let unfreeze (cci,fw) = cci_tab := cci; fw_tab := fw
let _ =
Summary.declare_summary "names"
{ Summary.freeze_function = freeze;
Summary.unfreeze_function = unfreeze;
Summary.init_function = init }
let rollback f x =
let fs = freeze () in
try f x with e -> begin unfreeze fs; raise e end
|