aboutsummaryrefslogtreecommitdiffhomepage
path: root/library/summary.ml
diff options
context:
space:
mode:
authorGravatar filliatr <filliatr@85f007b7-540e-0410-9357-904b9bb8a0f7>1999-09-03 09:53:11 +0000
committerGravatar filliatr <filliatr@85f007b7-540e-0410-9357-904b9bb8a0f7>1999-09-03 09:53:11 +0000
commit05074a8ee576e155596cf0c8bb3c8372a4dfa086 (patch)
tree0a63aa5ab3f6c50dcb9b76a8611dc517320628f8 /library/summary.ml
parent010a1652d7f0072b057235507c0efd5b7284574f (diff)
modules Libobject et Summary (partiel)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/coq/trunk@36 85f007b7-540e-0410-9357-904b9bb8a0f7
Diffstat (limited to 'library/summary.ml')
-rw-r--r--library/summary.ml48
1 files changed, 48 insertions, 0 deletions
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