From 75b7ceab5a486716af06b603ecbb4408cb47bd22 Mon Sep 17 00:00:00 2001 From: Leonard Gerard Date: Tue, 10 May 2011 20:29:01 +0200 Subject: [PATCH] Allows easy debugging printing of Envs. --- compiler/global/idents.ml | 14 ++++++++++---- compiler/global/idents.mli | 3 ++- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/compiler/global/idents.ml b/compiler/global/idents.ml index 2f2686d..318ef35 100644 --- a/compiler/global/idents.ml +++ b/compiler/global/idents.ml @@ -35,12 +35,12 @@ let name id = id.source (* used only for debuging *) -let fprint_t ff id = Format.fprintf ff "%s" (name id) +let print_ident ff id = Format.fprintf ff "%s" (name id) module M = struct type t = ident let compare = ident_compare - let fprint = fprint_t + let print_t = print_ident end module Env = @@ -67,14 +67,20 @@ struct else (env1,(add key elt env2))) env (empty, empty) + + (* Print Env *) + let print_t print_value ff m = + Format.fprintf ff "@[{@ "; + iter (fun k v -> Format.fprintf ff "%a => %a,@ " M.print_t k print_value v) m; + Format.fprintf ff "}@]"; end module IdentSet = struct include (Set.Make(M)) - let fprint_t ff s = + let print_t ff s = Format.fprintf ff "@[{@ "; - iter (fun e -> Format.fprintf ff "%a@ " M.fprint e) s; + iter (fun e -> Format.fprintf ff "%a,@ " M.print_t e) s; Format.fprintf ff "}@]"; end diff --git a/compiler/global/idents.mli b/compiler/global/idents.mli index a8c6282..571c665 100644 --- a/compiler/global/idents.mli +++ b/compiler/global/idents.mli @@ -43,11 +43,12 @@ sig val union : 'a t -> 'a t -> 'a t val diff : 'a t -> 'b t -> 'a t val partition : (key -> bool) -> 'a t -> 'a t * 'a t + val print_t : (Format.formatter -> 'a -> unit) -> Format.formatter -> 'a t -> unit end (** A set of identifiers. *) module IdentSet : sig include (Set.S with type elt = ident) - val fprint_t : Format.formatter -> t -> unit + val print_t : Format.formatter -> t -> unit end