* 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 list of GrafiteAst.command
+ * - marshalled pair: first component is a list of GrafiteAst.command (real moo
+ * content), second component is a list of GrafiteAst.metadata
*)
-let save_moo ~fname moo =
+let save_moo ~fname (moo, metadata) =
let oc = open_out fname in
- let marshalled_moo = Marshal.to_string (List.rev moo) marshal_flags in
- let checksum = Hashtbl.hash marshalled_moo in
+ let marshalled =
+ Marshal.to_string (List.rev moo, List.rev metadata) marshal_flags
+ in
+ let checksum = Hashtbl.hash marshalled in
output_binary_int oc GrafiteAst.magic;
output_binary_int oc checksum;
- output_string oc marshalled_moo;
+ output_string oc marshalled;
close_out oc
let load_moo ~fname =
let moo_magic = input_binary_int ic in
if moo_magic <> GrafiteAst.magic then raise (Version_mismatch fname);
let moo_checksum = input_binary_int ic in
- let marshalled_moo = HExtlib.input_all ic in
- let checksum = Hashtbl.hash marshalled_moo in
+ let marshalled = HExtlib.input_all ic in
+ let checksum = Hashtbl.hash marshalled in
if checksum <> moo_checksum then raise (Checksum_failure fname);
- let (moo: MatitaTypes.ast_command list) =
- Marshal.from_string marshalled_moo 0
+ let (moo: MatitaTypes.moo) =
+ Marshal.from_string marshalled 0
in
moo
with End_of_file -> raise (Corrupt_moo fname))