exception Corrupt_moo of string
exception Version_mismatch of string
-type ast_command = (CicNotationPt.term, CicNotationPt.obj) GrafiteAst.command
-type moo = ast_command list * GrafiteAst.metadata list (** <moo, metadata> *)
+type ast_command = Cic.obj GrafiteAst.command
+type moo = ast_command list
let marshal_flags = []
+let rehash_cmd_uris =
+ let rehash_uri uri = UriManager.uri_of_string (UriManager.string_of_uri uri) in
+ function
+ | GrafiteAst.Default (loc, name, uris) ->
+ let uris = List.map rehash_uri uris in
+ GrafiteAst.Default (loc, name, uris)
+ | GrafiteAst.Coercion (loc, uri, close) ->
+ GrafiteAst.Coercion (loc, rehash_uri uri, close)
+ | cmd ->
+ prerr_endline "Found a command not expected in a .moo:";
+ let obj_pp _ = assert false in
+ prerr_endline (GrafiteAstPp.pp_command ~obj_pp cmd);
+ assert false
+
(** .moo file format
* - an integer -- magic number -- denoting the version of the dumped data
* structure. Different magic numbers stand for incompatible data structures
* - an integer -- checksum -- denoting the hash value (computed with
* Hashtbl.hash) of the string representation of the dumped data structur
- * - marshalled pair: first component is a list of GrafiteAst.command (real moo
- * content), second component is a list of GrafiteAst.metadata
+ * - marshalled data: list of GrafiteAst.command
*)
-let save_moo ~fname (moo, metadata) =
- let oc = open_out fname in
- let marshalled =
- Marshal.to_string (List.rev moo, List.rev metadata) marshal_flags
+let save_moo ~fname moo =
+ let ensure_path_exists path =
+ let dir = Filename.dirname path in
+ HExtlib.mkdir dir
in
+ ensure_path_exists fname;
+ let oc = open_out fname in
+ let marshalled = Marshal.to_string (List.rev moo) marshal_flags in
let checksum = Hashtbl.hash marshalled in
output_binary_int oc GrafiteAst.magic;
output_binary_int oc checksum;
let (moo:moo) =
Marshal.from_string marshalled 0
in
- moo
+ List.map rehash_cmd_uris moo
with End_of_file -> raise (Corrupt_moo fname))
()