From: Enrico Tassi Date: Mon, 15 Jun 2009 16:41:47 +0000 (+0000) Subject: EXPERIMENTAL COMMIT (part B, by CSC :-): X-Git-Tag: make_still_working~3867 X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=commitdiff_plain;h=62a12215bbf8686fab44e8db25babd3095983c8f;p=helm.git EXPERIMENTAL COMMIT (part B, by CSC :-): - objects are now individually serialized too (but never decompiled) CRITICAL OBSERVATION: - closures in ocaml are pointers in the binary, hence the library must be decompiled at every single change in matita's code --- diff --git a/helm/software/components/ng_kernel/nCicLibrary.ml b/helm/software/components/ng_kernel/nCicLibrary.ml index 8c988de2f..cff822316 100644 --- a/helm/software/components/ng_kernel/nCicLibrary.ml +++ b/helm/software/components/ng_kernel/nCicLibrary.ml @@ -26,6 +26,52 @@ let cache = ref NUri.UriMap.empty;; let time_travel (sto,ali,cac) = storage := sto; aliases := ali; cache := cac;; +let magic = 0;; + +let path_of_baseuri baseuri = + let uri = NUri.string_of_uri baseuri in + let path = String.sub uri 4 (String.length uri - 4) in + let path = Helm_registry.get "matita.basedir" ^ path in + let dirname = Filename.dirname path in + HExtlib.mkdir dirname; + path ^ ".ng" +;; + +let serialize ~baseuri dump = + let ch = open_out (path_of_baseuri baseuri) in + Marshal.to_channel ch (magic,dump) [Marshal.Closures]; + close_out ch; + List.iter + (fun (uri,obj) -> + let ch = open_out (path_of_baseuri uri) in + Marshal.to_channel ch (magic,obj) []; + close_out ch + ) !storage; + time_travel time0; +;; + +let require ~baseuri = + let ch = open_in (path_of_baseuri baseuri) in + let mmagic,dump = Marshal.from_channel ch in + close_in ch; + if mmagic <> magic then + raise (LibraryOutOfSync (lazy "The library is out of sync with the implementation. Please recompile the library.")) + else + dump +;; + +let decompile ~baseuri = + Unix.unlink (path_of_baseuri baseuri) + (* WE ARE NOT REMOVING ALL THE OBJECTS YET! *) +;; + +(* the miracles of Marshal... *) +let fetch_obj uri = + let obj = require ~baseuri:uri in + (* here we need to refresh the URIs! *) + obj +;; + let resolve name = try HExtlib.filter_map @@ -79,9 +125,10 @@ let add_obj u obj = let get_obj u = try List.assq u !storage with Not_found -> - try NUri.UriMap.find u !cache - with Not_found -> - (* in the final implementation should get it from disk *) + try fetch_obj u + with Sys_error _ -> + try NUri.UriMap.find u !cache + with Not_found -> let ouri = NCic2OCic.ouri_of_nuri u in try let o,_ = CicEnvironment.get_obj CicUniv.oblivion_ugraph ouri in @@ -95,33 +142,3 @@ let get_obj u = let clear_cache () = cache := NUri.UriMap.empty;; -let magic = 0;; - -let path_of_baseuri baseuri = - let uri = NUri.string_of_uri baseuri in - let path = String.sub uri 4 (String.length uri - 4) in - let path = Helm_registry.get "matita.basedir" ^ path in - let dirname = Filename.dirname path in - HExtlib.mkdir dirname; - path ^ ".ng" -;; - -let serialize ~baseuri dump = - let ch = open_out (path_of_baseuri baseuri) in - Marshal.to_channel ch (magic,dump) [Marshal.Closures]; - close_out ch -;; - -let require ~baseuri = - let ch = open_in (path_of_baseuri baseuri) in - let mmagic,dump = Marshal.from_channel ch in - close_in ch; - if mmagic <> magic then - raise (LibraryOutOfSync (lazy "The library is out of sync with the implementation. Please recompile the library.")) - else - dump -;; - -let decompile ~baseuri = - Unix.unlink (path_of_baseuri baseuri) -;; diff --git a/helm/software/matita/tests/ng_include.ma b/helm/software/matita/tests/ng_include.ma index 4584afddc..2582da4b4 100644 --- a/helm/software/matita/tests/ng_include.ma +++ b/helm/software/matita/tests/ng_include.ma @@ -24,4 +24,8 @@ axiom P: nat → Prop. unification hint 0 (∀n. P (0 + n) = P n) . -ntheorem foo: ∀n. ∀H:(P (? + n) → Prop). ∀p:P n. H p. \ No newline at end of file +ntheorem foo: ∀n. ∀H:(P (? + n) → Prop). ∀p:P n. H p → True. + #n; #H; #p; #_; napply I; +nqed. + +naxiom nnn: nat. \ No newline at end of file diff --git a/helm/software/matita/tests/ng_includeB.ma b/helm/software/matita/tests/ng_includeB.ma index f7e1e293e..1fccbcb94 100644 --- a/helm/software/matita/tests/ng_includeB.ma +++ b/helm/software/matita/tests/ng_includeB.ma @@ -14,4 +14,6 @@ include "ng_include.ma". -ntheorem foo: ∀n. ∀H:(P (? + n) → Prop). ∀p:P n. H p. +ntheorem goo: ∀n. ∀H:(P (? + n) → Prop). ∀p:P n. H p → True. + napply foo; +nqed.