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
9 CicEnvironment.get_cooked_obj ~trust:false CicUniv.oblivion_ugraph ouri
11 (* FIX: add all objects to the environment and give back the last one *)
12 let l = OCic2NCic.convert_obj ouri o in
13 List.iter (fun (u,_,_,_,_ as o) ->
14 prerr_endline ("+"^NUri.string_of_uri u);
15 NUri.UriHash.add cache u (false,o)) l;
20 try NUri.UriHash.find cache u
22 (* in th final implementation should get it from disk *)
23 let ouri = NUri.ouri_of_nuri u in
25 CicEnvironment.get_cooked_obj ~trust:true CicUniv.oblivion_ugraph ouri
27 let l = OCic2NCic.convert_obj ouri o in
28 List.iter (fun (u,_,_,_,_ as o) ->
29 prerr_endline ("+"^NUri.string_of_uri u);
30 NUri.UriHash.add cache u (false,o)) l;
31 false, HExtlib.list_last l
34 let add_obj (u,_,_,_,_ as o) =
35 NUri.UriHash.replace cache u (true, o)
38 let get_checked_def = function
39 | NReference.Ref (_, uri, NReference.Def) ->
40 (match get_checked_obj uri with
41 | _,height,_,_, NCic.Constant (rlv,name,Some bo,ty,att) ->
42 rlv,name,bo,ty,att,height
43 | _,_,_,_, NCic.Constant (_,_,None,_,_) ->
44 prerr_endline "get_checked_def on an axiom"; assert false
45 | _ -> prerr_endline "get_checked_def on a non def 2"; assert false)
46 | _ -> prerr_endline "get_checked_def on a non def"; assert false
49 let get_checked_indtys = function
50 | NReference.Ref (_, uri, NReference.Ind n) ->
51 (match get_checked_obj uri with
52 | _,_,_,_, NCic.Inductive (inductive,leftno,tys,att) ->
53 inductive,leftno,tys,att,n
54 | _ -> prerr_endline "get_checked_indtys on a non ind 2"; assert false)
55 | _ -> prerr_endline "get_checked_indtys on a non ind"; assert false
58 let get_checked_fix_or_cofix b = function
59 | NReference.Ref (_, uri, NReference.Fix (fixno,_)) ->
60 (match get_checked_obj uri with
61 | _,height,_,_, NCic.Fixpoint (is_fix,funcs,att) when is_fix = b ->
62 let rlv, name, _, ty, bo = List.nth funcs fixno in
63 rlv, name, bo, ty, att, height
64 | _ ->prerr_endline "get_checked_(co)fix on a non (co)fix 2";assert false)
65 | _ -> prerr_endline "get_checked_(co)fix on a non (co)fix"; assert false
67 let get_checked_fix r = get_checked_fix_or_cofix true r;;
68 let get_checked_cofix r = get_checked_fix_or_cofix false r;;
70 let get_indty_leftno = function
71 | NReference.Ref (_, uri, NReference.Ind _)
72 | NReference.Ref (_, uri, NReference.Con _) ->
73 (match get_checked_obj uri with
74 | _,_,_,_, NCic.Inductive (_,left,_,_) -> left
75 | _ ->prerr_endline "get_indty_leftno called on a non ind 2";assert false)
76 | _ -> prerr_endline "get_indty_leftno called on a non indty";assert false