1 let cache = NUri.UriHash.create 313;;
3 let get_checked_obj u =
4 try let b, o = NUri.UriHash.find cache u in
5 if not b then assert false else o
7 let ouri = NUri.ouri_of_nuri u in
10 CicEnvironment.get_obj CicUniv.oblivion_ugraph ouri
11 with exn -> prerr_endline (UriManager.string_of_uri ouri); raise exn
13 (* FIX: add all objects to the environment and give back the last one *)
14 let l = OCic2NCic.convert_obj ouri o in
15 List.iter (fun (u,_,_,_,_ as o) ->
16 (* prerr_endline ("+"^NUri.string_of_uri u); *)
17 NUri.UriHash.add cache u (false,o)) l;
22 try NUri.UriHash.find cache u
24 (* in th final implementation should get it from disk *)
25 let ouri = NUri.ouri_of_nuri u in
27 CicEnvironment.get_obj CicUniv.oblivion_ugraph ouri
29 let l = OCic2NCic.convert_obj ouri o in
30 List.iter (fun (u,_,_,_,_ as o) ->
31 (* prerr_endline ("+"^NUri.string_of_uri u); *)
32 NUri.UriHash.add cache u (false,o)) l;
33 false, HExtlib.list_last l
36 let add_obj (u,_,_,_,_ as o) =
37 NUri.UriHash.replace cache u (true, o)
40 let get_checked_def = function
41 | NReference.Ref (_, uri, NReference.Def) ->
42 (match get_checked_obj uri with
43 | _,height,_,_, NCic.Constant (rlv,name,Some bo,ty,att) ->
44 rlv,name,bo,ty,att,height
45 | _,_,_,_, NCic.Constant (_,_,None,_,_) ->
46 prerr_endline "get_checked_def on an axiom"; assert false
47 | _ -> prerr_endline "get_checked_def on a non def 2"; assert false)
48 | _ -> prerr_endline "get_checked_def on a non def"; assert false
51 let get_checked_indtys = function
52 | NReference.Ref (_, uri, NReference.Ind n) ->
53 (match get_checked_obj uri with
54 | _,_,_,_, NCic.Inductive (inductive,leftno,tys,att) ->
55 inductive,leftno,tys,att,n
56 | _ -> prerr_endline "get_checked_indtys on a non ind 2"; assert false)
57 | _ -> prerr_endline "get_checked_indtys on a non ind"; assert false
60 let get_checked_fix_or_cofix b = function
61 | NReference.Ref (_, uri, NReference.Fix (fixno,_)) ->
62 (match get_checked_obj uri with
63 | _,height,_,_, NCic.Fixpoint (is_fix,funcs,att) when is_fix = b ->
64 let rlv, name, _, ty, bo = List.nth funcs fixno in
65 rlv, name, bo, ty, att, height
66 | _ ->prerr_endline "get_checked_(co)fix on a non (co)fix 2";assert false)
67 | _ -> prerr_endline "get_checked_(co)fix on a non (co)fix"; assert false
69 let get_checked_fix r = get_checked_fix_or_cofix true r;;
70 let get_checked_cofix r = get_checked_fix_or_cofix false r;;
72 let get_indty_leftno = function
73 | NReference.Ref (_, uri, NReference.Ind _)
74 | NReference.Ref (_, uri, NReference.Con _) ->
75 (match get_checked_obj uri with
76 | _,_,_,_, NCic.Inductive (_,left,_,_) -> left
77 | _ ->prerr_endline "get_indty_leftno called on a non ind 2";assert false)
78 | _ -> prerr_endline "get_indty_leftno called on a non indty";assert false
84 NUri.UriHash.replace cache k (false,v))
85 (NUri.UriHash.fold (fun k v -> (@) [k,snd v]) cache [])