diff --git a/experimental/frisch/test_trace.ml b/experimental/frisch/test_trace.ml index 3d785e142..fc4f1ec2a 100644 --- a/experimental/frisch/test_trace.ml +++ b/experimental/frisch/test_trace.ml @@ -13,3 +13,12 @@ module B = struct end end + + +let () = + let o = object + method x = 1 + method y = 2 + end + in + ignore (o # x + o # y) diff --git a/experimental/frisch/tracer.ml b/experimental/frisch/tracer.ml index f19776f70..095dd2e73 100644 --- a/experimental/frisch/tracer.ml +++ b/experimental/frisch/tracer.ml @@ -9,7 +9,7 @@ open Parsetree the compilation unit. *) let trace s = - SI.eval E.(apply (lid "Pervasives.print_endline") [strconst s]) + E.(apply (lid "Pervasives.print_endline") [strconst s]) let tracer = object(this) @@ -27,9 +27,17 @@ let tracer = [ SI.map this si ] method! structure l = - trace (Printf.sprintf "Entering module %s" path) :: + SI.eval (trace (Printf.sprintf "Entering module %s" path)) :: (super # structure l) @ - [ trace (Printf.sprintf "Leaving module %s" path) ] + [ SI.eval (trace (Printf.sprintf "Leaving module %s" path)) ] + + method! expr e = + match e.pexp_desc with + | Pexp_send (_, s) -> + E.sequence (trace (Printf.sprintf "calling method %s" s)) (super # expr e) + | _ -> + super # expr e + end let () = tracer # main