From b84c600e49642829c08abc8f02d25cb5cbbb76d7 Mon Sep 17 00:00:00 2001 From: Jean-Christophe Filliatre Date: Mon, 17 Oct 2011 11:20:25 +0000 Subject: [PATCH] release 1.81 --- CHANGES | 5 +++++ Makefile.in | 2 +- src/gmap.ml | 34 +++++++++++++++++++++++++++------- src/gmap.mli | 2 +- 4 files changed, 34 insertions(+), 9 deletions(-) diff --git a/CHANGES b/CHANGES index 49c03731..75525268 100644 --- a/CHANGES +++ b/CHANGES @@ -1,4 +1,9 @@ +version 1.81, October 17, 2011 +------------------------------ + o module Gmap now has a signature for edges (E_SRC) compatible with + Sig, so that it is easier to apply functor Gmap.Edge + (contributed by Markus W. Weissmann ) o new module Fixpoint to compute fixpoints using the work-list algorithm, e.g. for data flow analysis (contributed by Markus W. Weissmann ) diff --git a/Makefile.in b/Makefile.in index d3160bac..b208560c 100644 --- a/Makefile.in +++ b/Makefile.in @@ -105,7 +105,7 @@ graph.cmo: $(CMI) $(CMO) graph.cmx: $(CMI) $(CMX) $(OCAMLOPT) $(INCLUDES) -pack -o $@ $^ -VERSION=1.8 +VERSION=1.81 src/version.ml: Makefile rm -f $@ diff --git a/src/gmap.ml b/src/gmap.ml index a3649a67..8048266f 100644 --- a/src/gmap.ml +++ b/src/gmap.ml @@ -33,12 +33,12 @@ module type V_DST = sig end module Vertex(G_Src : V_SRC)(G_Dst : V_DST ) = struct - + module H = Hashtbl.Make(G_Src.V) let vertices = H.create 97 let convert_vertex f x = - try + try H.find vertices x with Not_found -> let x' = f x in @@ -48,7 +48,7 @@ module Vertex(G_Src : V_SRC)(G_Dst : V_DST ) = struct let map f g = H.clear vertices; G_Src.fold_vertex - (fun x g -> G_Dst.add_vertex g (convert_vertex f x)) + (fun x g -> G_Dst.add_vertex g (convert_vertex f x)) g (G_Dst.empty ()) end @@ -57,7 +57,7 @@ end module type E_SRC = sig type t - module E : Sig.HASHABLE + module E : Sig.ORDERED_TYPE val fold_edges_e : (E.t -> 'a -> 'a) -> t -> 'a -> 'a end @@ -68,7 +68,27 @@ module type E_DST = sig val add_edge_e : t -> edge -> t end -module Edge(G_Src: E_SRC)(G_Dst: E_DST) = +module Edge(G_Src: E_SRC)(G_Dst: E_DST) = struct + module M = Map.Make(G_Src.E) + let edges = ref M.empty + + let convert_edge f x = + try + M.find x !edges + with Not_found -> + let x' = f x in + edges := M.add x x' !edges; + x' + + let map f g = + edges := M.empty; + G_Src.fold_edges_e + (fun x g -> G_Dst.add_edge_e g (convert_edge f x)) + g (G_Dst.empty ()) +end + +(* Vertex - (struct include G_Src module V = E let fold_vertex = fold_edges_e end) - (struct include G_Dst type vertex = edge let add_vertex = add_edge_e end) + (struct include G_Src module V = E let fold_vertex = fold_edges_e end) + (struct include G_Dst type vertex = edge let add_vertex = add_edge_e end) +*) diff --git a/src/gmap.mli b/src/gmap.mli index 71d399c2..9f9f6018 100644 --- a/src/gmap.mli +++ b/src/gmap.mli @@ -50,7 +50,7 @@ end (** Signature for the source graph. *) module type E_SRC = sig type t - module E : Sig.HASHABLE + module E : Sig.ORDERED_TYPE val fold_edges_e : (E.t -> 'a -> 'a) -> t -> 'a -> 'a end