Commit 3f1ff11d authored by Pietro Abate's avatar Pietro Abate

Add Typed.Print.printf for debugging

parent 75058a68
......@@ -192,7 +192,7 @@ let debug ppf tenv cenv = function
(try
let t = Types.descr (Typer.typ tenv t) in
Format.fprintf ppf "%a@." print_sample (Sample.get t);
Format.fprintf ppf "witness: %a@." Types.Witness.print_witness (Types.witness t);
Format.fprintf ppf "witness: %a@." Types.Witness.pp (Types.witness t);
with Not_found ->
Format.fprintf ppf "Empty type : no sample !@.")
| `Filter (t,p) ->
......
......@@ -315,7 +315,7 @@ let test_witness =
let d = Types.diff t1 t2 in
let result = Types.witness d in
Format.printf "subtyping %s <: %s\n" s1 s2;
Format.printf "witness : %a\n" Types.Witness.print_witness result;
Format.printf "witness : %a\n" Types.Witness.pp result;
Format.printf "diff : %a\n" Types.Print.pp_type d;
(*
if result <> expected then
......
......@@ -776,7 +776,7 @@ module Witness = struct
Stats.register Stats.Summary
(fun ppf -> Format.fprintf ppf "Allocated witnesses:%i@\n" !wuid)
let rec print_witness ppf = function
let rec pp ppf = function
| WInt i ->
Format.fprintf ppf "%a" Intervals.V.print i
| WChar c ->
......@@ -788,24 +788,24 @@ module Witness = struct
| WAtom (Some (_,Some t)) ->
Format.fprintf ppf "`%a" Ns.Label.print_attr t
| WPair (w1,w2,_) ->
Format.fprintf ppf "(%a,%a)" print_witness w1 print_witness w2
Format.fprintf ppf "(%a,%a)" pp w1 pp w2
| WXml (w1,w2,_) ->
Format.fprintf ppf "XML(%a,%a)" print_witness w1 print_witness w2
Format.fprintf ppf "XML(%a,%a)" pp w1 pp w2
| WRecord (ws,o,_) ->
Format.fprintf ppf "{";
LabelMap.iteri
(fun l w -> Format.fprintf ppf " %a=%a"
Label.print_attr l print_witness w)
Label.print_attr l pp w)
ws;
if o then Format.fprintf ppf " ..";
Format.fprintf ppf " }"
| WFun (f,_) ->
Format.fprintf ppf "FUN{";
List.iter (fun (x,y) ->
Format.fprintf ppf " %a->" print_witness x;
Format.fprintf ppf " %a->" pp x;
match y with
| None -> Format.fprintf ppf "#"
| Some y -> print_witness ppf y) f;
| Some y -> pp ppf y) f;
Format.fprintf ppf " }"
| WAbstract None ->
Format.fprintf ppf "Abstract(..)"
......@@ -814,13 +814,15 @@ module Witness = struct
| WAbsent ->
Format.fprintf ppf "Absent"
let printf = pp Format.std_formatter
let wmk w = (* incr wuid; w *) (* hash-consing disabled *)
try WHash.find wmemo w
with Not_found ->
incr wuid;
WHash.add wmemo w w;
(* Format.fprintf Format.std_formatter "W:%a@."
print_witness w; *)
pp w; *)
w
let wpair p1 p2 = wmk (WPair (p1,p2, wslot()))
......@@ -1126,7 +1128,7 @@ module Cache = struct
| Empty -> Format.fprintf ppf "Empty"
| Type (_,s) -> Format.fprintf ppf "*%a" f s
| Split (w,c1,c2) -> Format.fprintf ppf "?(%a,%a)"
(*Witness.print_witness w *)(dump_cache f) c1 (dump_cache f) c2
(*Witness.pp w *)(dump_cache f) c1 (dump_cache f) c2
let memo f =
let c = ref emp in
......@@ -2140,6 +2142,7 @@ struct
let string_of_type t = Utils.string_of_formatter pp_type t
let string_of_node t = Utils.string_of_formatter pp_node t
let printf = pp_type Format.std_formatter
end
......
......@@ -335,6 +335,7 @@ sig
val string_of_type: t -> string
val string_of_node: Node.t -> string
val printf : t -> unit
end
module Service :
......@@ -345,7 +346,8 @@ end
module Witness : sig
type witness
val print_witness: Format.formatter -> witness -> unit
val pp: Format.formatter -> witness -> unit
val printf : witness -> unit
end
val witness: t -> Witness.witness
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment