let time0 = [],[],NUri.UriMap.empty;;
let storage = ref [];;
-let aliases = ref [];;
+let local_aliases = ref [];;
+let global_aliases = ref [];;
let cache = ref NUri.UriMap.empty;;
class status =
let time_travel status =
let sto,ali,cac = status#timestamp in
- storage := sto; aliases := ali; cache := cac
+ storage := sto; local_aliases := ali; cache := cac
;;
let path_of_baseuri ?(no_suffix=false) baseuri =
let magic = 0;;
-let require0 ~baseuri =
- let ch = open_in (path_of_baseuri baseuri) in
+let require_path path =
+ let ch = open_in path in
let mmagic,dump = Marshal.from_channel ch in
close_in ch;
if mmagic <> magic then
dump
;;
+let require0 ~baseuri = require_path (path_of_baseuri baseuri);;
+
+let db_path () = Helm_registry.get "matita.basedir" ^ "/ng_db.ng";;
+
+let init () =
+ try
+ global_aliases := require_path (db_path ())
+ with
+ Sys_error _ -> ()
+;;
+
let serialize ~baseuri dump =
let ch = open_out (path_of_baseuri baseuri) in
- Marshal.to_channel ch (magic,dump) [Marshal.Closures];
+ Marshal.to_channel ch (magic,dump) [];
close_out ch;
List.iter
(fun (uri,obj) ->
Marshal.to_channel ch (magic,obj) [];
close_out ch
) !storage;
+ global_aliases := !local_aliases @ !global_aliases;
+ let ch = open_out (db_path ()) in
+ Marshal.to_channel ch (magic,!global_aliases) [];
+ close_out ch;
time_travel (new status)
;;
let resolve name =
try
HExtlib.filter_map
- (fun (_,name',nref) -> if name'=name then Some nref else None) !aliases
+ (fun (_,name',nref) -> if name'=name then Some nref else None)
+ (!local_aliases @ !global_aliases)
with
Not_found -> raise (NCicEnvironment.ObjectNotFound (lazy name))
;;
let aliases_of uri =
try
HExtlib.filter_map
- (fun (uri',_,nref) -> if NUri.eq uri' uri then Some nref else None) !aliases
+ (fun (uri',_,nref) ->
+ if NUri.eq uri' uri then Some nref else None) !local_aliases
with
Not_found -> raise (NCicEnvironment.ObjectNotFound (lazy (NUri.string_of_uri uri)))
;;
(NReference.Ind (inductive,i,leftno))]
) il)
in
- aliases := references @ !aliases;
- status#set_timestamp (!storage,!aliases,!cache)
+ local_aliases := references @ !local_aliases;
+ status#set_timestamp (!storage,!local_aliases,!cache)
;;
let get_obj u =
(* $Id$ *)
-type thingsToInitilaize =
+type thingsToInitialize =
ConfigurationFile | Db | Environment | Getter | CmdLine | Registry
-exception FailedToInitialize of thingsToInitilaize
+exception FailedToInitialize of thingsToInitialize
let wants s l =
List.iter (
let initialize_all () =
status :=
List.fold_left (fun s f -> f s) !status
- (conf_components @ other_components)
+ (conf_components @ other_components);
+ NCicLibrary.init ()
let parse_cmdline_and_configuration_file () =
status := List.fold_left (fun s f -> f s) !status conf_components