| Appl of term * term (* argument, function *)
| Bind of id * bind * term * term (* name, binder, content, scope *)
-type obj = bind * term (* binder, contents *)
+type obj = int * uri * bind * term (* age, uri, binder, contents *)
-type item = (obj * uri) option (* uri, object *)
+type item = obj option
let hsize = 7000
let env = H.create hsize
+let entry = ref 0
(* Internal functions *******************************************************)
(* Interface functions ******************************************************)
-let set_obj f obj uri =
- H.add env uri obj; f obj uri
-
+let set_obj f obj =
+ let _, uri, b, t = obj in
+ let obj = !entry, uri, b, t in
+ incr entry; H.add env uri obj; f obj
+
let get_obj f uri =
- try f (H.find env uri) uri
+ try f (H.find env uri)
with Not_found -> raise (ObjectNotFound (lazy (U.string_of_uri uri)))
exception ObjectNotFound of string Lazy.t
-val set_obj: (Brg.obj -> NUri.uri -> 'a) -> Brg.obj -> NUri.uri -> 'a
+val set_obj: (Brg.obj -> 'a) -> Brg.obj -> 'a
-val get_obj: (Brg.obj -> NUri.uri -> 'a) -> NUri.uri -> 'a
+val get_obj: (Brg.obj -> 'a) -> NUri.uri -> 'a
| B.Abst -> f {c with eabsts = succ c.eabsts}
| B.Abbr -> f {c with eabbrs = succ c.eabbrs}
-let count_obj f c (b, t) =
+let count_obj f c (_, _, b, t) =
let f c = count_obj_binder f c b in
count_term f c t
let count_item f c = function
- | Some (obj, _) -> count_obj f c obj
- | None -> f c
+ | Some obj -> count_obj f c obj
+ | None -> f c
let print_counters f c =
let terms =
xlate_term f w
let xlate_entry f = function
- | _, pars, uri, u, None ->
- let f u = f ((B.Abst, u), uri) in
+ | e, pars, uri, u, None ->
+ let f u = f (e, uri, B.Abst, u) in
let f pars = map_fold_left f xlate_term map_pars u pars in
Cps.list_rev_map f xlate_pars pars
- | _, pars, uri, u, Some (_, t) ->
- let f u t = f ((B.Abbr, (B.Cast (u, t))), uri) in
+ | e, pars, uri, u, Some (_, t) ->
+ let f u t = f (e, uri, B.Abbr, (B.Cast (u, t))) in
let f pars u = map_fold_left (f u) xlate_term map_pars t pars in
let f pars = map_fold_left (f pars) xlate_term map_pars u pars in
Cps.list_rev_map f xlate_pars pars