]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/ocaml/cic_cache/cicCache.ml
Bug fixed: when an axiom was asked, an exception was raised (since the
[helm.git] / helm / ocaml / cic_cache / cicCache.ml
index adfeb0575dcbe909d75895eb6e957ee3d7221726..29d6a9a2fb445fd3a34164c7645a854773e8ac56 100644 (file)
@@ -39,12 +39,52 @@ let get_annobj uri =
  let module G = Getter in
  let module U = UriManager in
   let cicfilename = G.getxml (U.cicuri_of_uri uri) in
-   CicParser.annobj_of_xml cicfilename uri
+   match (U.bodyuri_of_uri uri) with
+      None ->
+        let annobj = CicParser.annobj_of_xml cicfilename None in
+         Unix.unlink cicfilename ;
+         annobj
+    | Some bodyuri ->
+       let cicbodyfilename =
+        try
+         ignore (Getter.resolve bodyuri) ;
+         (* The body exists ==> it is not an axiom *)
+         Some (Getter.getxml bodyuri)
+        with
+         Getter.Unresolved ->
+          (* The body does not exist ==> we consider it an axiom *)
+          None
+       in
+        let annobj =
+         CicParser.annobj_of_xml cicfilename cicbodyfilename
+        in
+         Unix.unlink cicfilename ;
+         (match cicbodyfilename with None -> () | Some f -> Unix.unlink f) ;
+         annobj
 ;;
 
 let get_obj uri =
  let module G = Getter in
  let module U = UriManager in
   let cicfilename = G.getxml (U.cicuri_of_uri uri) in
-   CicParser.obj_of_xml cicfilename uri
+   match (U.bodyuri_of_uri uri) with
+      None ->
+        let obj = CicParser.obj_of_xml cicfilename None in
+         Unix.unlink cicfilename ;
+         obj
+    | Some bodyuri ->
+       let cicbodyfilename =
+        try
+         ignore (Getter.resolve bodyuri) ;
+         (* The body exists ==> it is not an axiom *)
+         Some (Getter.getxml bodyuri)
+        with
+         Getter.Unresolved ->
+          (* The body does not exist ==> we consider it an axiom *)
+          None
+       in
+       let obj = CicParser.obj_of_xml cicfilename cicbodyfilename in
+        Unix.unlink cicfilename ;
+        (match cicbodyfilename with None -> () | Some f -> Unix.unlink f) ;
+        obj
 ;;