summaryrefslogtreecommitdiff
path: root/AAC_helper.ml
blob: 15372f2ade105ddb1c375acffd7bffcbc333dd5e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
(***************************************************************************)
(*  This is part of aac_tactics, it is distributed under the terms of the  *)
(*         GNU Lesser General Public License version 3                     *)
(*              (see file LICENSE for more details)                        *)
(*                                                                         *)
(*       Copyright 2009-2010: Thomas Braibant, Damien Pous.                *)
(***************************************************************************)

module type CONTROL = sig
  val debug : bool
  val time : bool
  val printing : bool
end

module Debug (X : CONTROL) = struct
  open X
  let debug x = 
    if debug then 
      Printf.printf "%s\n%!" x


  let time f x fmt =
    if time then 
      let t = Sys.time () in
      let r = f x in
	Printf.printf fmt  (Sys.time () -. t);
	r
    else f x 

  let pr_constr msg constr = 
    if printing then 
      (  Pp.msgnl (Pp.str (Printf.sprintf "=====%s====" msg));
	 Pp.msgnl (Printer.pr_constr constr);
      )


  let debug_exception msg e = 
    debug (msg ^ (Printexc.to_string e))
      

end