From 05074a8ee576e155596cf0c8bb3c8372a4dfa086 Mon Sep 17 00:00:00 2001 From: filliatr Date: Fri, 3 Sep 1999 09:53:11 +0000 Subject: modules Libobject et Summary (partiel) git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/coq/trunk@36 85f007b7-540e-0410-9357-904b9bb8a0f7 --- library/summary.ml | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 library/summary.ml (limited to 'library/summary.ml') diff --git a/library/summary.ml b/library/summary.ml new file mode 100644 index 000000000..f58917202 --- /dev/null +++ b/library/summary.ml @@ -0,0 +1,48 @@ + +(* $Id$ *) + +open Pp +open Util +open Names + +type 'a summary_declaration = { + freeze_function : unit -> 'a; + unfreeze_function : 'a -> unit; + init_function : unit -> unit } + +let summaries = + (Hashtbl.create 17 : (string, Dyn.t summary_declaration) Hashtbl.t) + +let declare_summary sumname sdecl = + let (infun,outfun) = Dyn.create (sumname^"-SUMMARY") in + let dyn_freeze () = infun (sdecl.freeze_function()) + and dyn_unfreeze sum = sdecl.unfreeze_function (outfun sum) + and dyn_init = sdecl.init_function in + let ddecl = { + freeze_function = dyn_freeze; + unfreeze_function = dyn_unfreeze; + init_function = dyn_init} + in + if Hashtbl.mem summaries sumname then + anomalylabstrm "Summary.declare_summary" + [< 'sTR "Cannot declare a summary twice: " ; 'sTR sumname >]; + Hashtbl.add summaries sumname ddecl + +type frozen_summaries = Dyn.t Stringmap.t + +let freeze_summaries () = + let m = ref Stringmap.empty in + Hashtbl.iter + (fun id decl -> m := Stringmap.add id (decl.freeze_function()) !m) + summaries; + !m + +let unfreeze_summaries fs = + Hashtbl.iter + (fun id decl -> + try decl.unfreeze_function (Stringmap.find id fs) + with Not_found -> decl.init_function()) + summaries + +let init_summaries () = + Hashtbl.iter (fun _ decl -> decl.init_function()) summaries -- cgit v1.2.3