From 95f5523261c3cbc246be62c715d37cfac14beea7 Mon Sep 17 00:00:00 2001 From: Cyril SIX Date: Fri, 2 Oct 2020 17:53:54 +0200 Subject: Rewriting some print to use a oc argument --- backend/Duplicateaux.ml | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) (limited to 'backend') diff --git a/backend/Duplicateaux.ml b/backend/Duplicateaux.ml index 33b033c9..fc16d5ce 100644 --- a/backend/Duplicateaux.ml +++ b/backend/Duplicateaux.ml @@ -78,15 +78,13 @@ end module PSet = Set.Make(PInt) -let print_intlist l = - let rec f = function +let print_intlist oc l = + let rec f oc = function | [] -> () - | n::ln -> (Printf.printf "%d " (P.to_int n); f ln) + | n::ln -> (Printf.fprintf oc "%d %a" (P.to_int n) f ln) in begin if !debug_flag then begin - Printf.printf "["; - f l; - Printf.printf "]" + Printf.fprintf oc "[%a]" f l end end @@ -387,18 +385,15 @@ let best_predecessor_of node predecessors code order is_visited = ) order) with Not_found -> None -let print_trace t = print_intlist t +let print_trace = print_intlist -let print_traces traces = - let rec f = function +let print_traces oc traces = + let rec f oc = function | [] -> () - | t::lt -> Printf.printf "\n\t"; print_trace t; Printf.printf ",\n"; f lt + | t::lt -> Printf.fprintf oc "\n\t%a,\n%a" print_trace t f lt in begin - if !debug_flag then begin - Printf.printf "Traces: {"; - f traces; - Printf.printf "}\n"; - end + if !debug_flag then + Printf.fprintf oc "Traces: {%a}\n" f traces end (* Dumb (but linear) trace selection *) @@ -473,7 +468,7 @@ let select_traces_chang code entrypoint = begin end done; (* debug "DFS: \t"; print_intlist order; debug "\n"; *) - debug "Traces: "; print_traces !traces; + debug "Traces: %a" print_traces !traces; !traces end end -- cgit