X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2Focaml%2Fcic_proof_checking%2FcicEnvironment.ml;h=5c1daa1373be26c35df429e23e6789847db69f5d;hb=57ad518c58e0b9684c5ea696a359037bed18dbc9;hp=7845818b716777b6109287569541439240c04d40;hpb=9c960d672031bc9ffabb6467bcb13a9e1c55495c;p=helm.git diff --git a/helm/ocaml/cic_proof_checking/cicEnvironment.ml b/helm/ocaml/cic_proof_checking/cicEnvironment.ml index 7845818b7..5c1daa137 100644 --- a/helm/ocaml/cic_proof_checking/cicEnvironment.ml +++ b/helm/ocaml/cic_proof_checking/cicEnvironment.ml @@ -59,7 +59,7 @@ exception AlreadyCooked of string;; exception CircularDependency of string;; exception CouldNotFreeze of string;; exception CouldNotUnfreeze of string;; -exception Term_not_found of UriManager.uri;; +exception Object_not_found of UriManager.uri;; (* ************************************************************************** * @@ -99,6 +99,7 @@ module Cache : val is_in_frozen: UriManager.uri -> bool val is_in_unchecked: UriManager.uri -> bool val is_in_cooked: UriManager.uri -> bool + val list_all_cooked_uris: unit -> UriManager.uri list end = struct @@ -458,6 +459,10 @@ module Cache : HT.remove cacheOfCookedObjects uri ;; + let list_all_cooked_uris () = + HT.fold (fun u _ l -> u::l) cacheOfCookedObjects [] + ;; + end ;; @@ -508,7 +513,10 @@ let get_object_to_add uri = CicParser.obj_of_xml filename bodyfilename with exn -> cleanup (); - raise exn + (match exn with + | CicParser.Getter_failure ("key_not_found", uri) -> + raise (Object_not_found (UriManager.uri_of_string uri)) + | _ -> raise exn) in let ugraph,filename_univ = (* FIXME: decomment this when the universes will be part of the library @@ -653,18 +661,8 @@ let put_inductive_definition uri (obj,ugraph) = | _ -> raise OnlyPutOfInductiveDefinitionsIsAllowed ;; -let in_cache uri = - if Cache.is_in_cooked uri then - (prerr_endline "TROVATO NELLA CHECKED";true) - else - if Cache.is_in_frozen uri then - (prerr_endline "TROVATO NELLA FROZEN";true) - else - if Cache.is_in_unchecked uri then - (prerr_endline "TROVATO NELLA UNCHECKED";true) - else - (prerr_endline ("NON TROVATO:" ^ (UriManager.string_of_uri uri) );false) -;; +let in_cache uri = + Cache.is_in_cooked uri || Cache.is_in_frozen uri || Cache.is_in_unchecked uri let add_type_checked_term uri (obj,ugraph) = match obj with @@ -674,5 +672,27 @@ let add_type_checked_term uri (obj,ugraph) = assert false ;; +let in_library uri = + in_cache uri || + (try + ignore (Http_getter.resolve' uri); + true + with Http_getter_types.Key_not_found _ -> false) + let remove_term = Cache.remove + +let list_uri () = + Cache.list_all_cooked_uris () +;; +let list_obj () = + try + List.map (fun u -> + let o,ug = get_obj CicUniv.empty_ugraph u in + (u,o,ug)) + (list_uri ()) + with + Not_found -> + prerr_endline "Who has removed the uri in the meanwhile?"; + raise Not_found +;;