summaryrefslogtreecommitdiff
path: root/ocaml/lib/nock.ml
diff options
context:
space:
mode:
Diffstat (limited to 'ocaml/lib/nock.ml')
-rw-r--r--ocaml/lib/nock.ml13
1 files changed, 7 insertions, 6 deletions
diff --git a/ocaml/lib/nock.ml b/ocaml/lib/nock.ml
index 2d106b6..73e5407 100644
--- a/ocaml/lib/nock.ml
+++ b/ocaml/lib/nock.ml
@@ -24,12 +24,13 @@ open Noun
- depth: current recursion depth
- max_calls: how many calls to log (like C's limit)
- max_mug_depth: only compute mugs at shallow depths (expensive!)
+ - show_mugs: global flag to enable/disable mug logging
*)
let call_count = ref 0
let depth = ref 0
let max_calls = 100
-let max_mug_depth = -1 (* Disabled: even cached, initial mug of huge ivory pill is slow *)
-(* TODO: Enable selectively after verifying structural correctness *)
+let max_mug_depth = ref (-1) (* Can be set from outside *)
+let show_mugs = ref false (* Enable from test code to show mugs at every step *)
(* Helper to generate indentation based on depth *)
let indent () =
@@ -77,8 +78,8 @@ let rec nock_on bus fol =
| Cell { h = Cell _; _ } -> "CELL(dist)"
| _ -> "?"
in
- (* Only compute mugs at shallow depths to avoid performance penalty *)
- if !depth <= max_mug_depth then begin
+ (* Only compute mugs at shallow depths to avoid performance penalty, or if show_mugs is enabled *)
+ if !show_mugs || !depth <= !max_mug_depth then begin
let bus_mug = mug bus in
Printf.eprintf "%s>>> ENTER call #%d depth=%d opcode=%s bus=%s[mug=0x%lx]\n%!"
(indent ()) my_call !depth opcode_str
@@ -239,8 +240,8 @@ let rec nock_on bus fol =
(* Restore depth and log exit before returning *)
decr depth;
if should_log then begin
- (* Only compute mugs at shallow depths to avoid performance penalty *)
- if !depth <= max_mug_depth then begin
+ (* Only compute mugs at shallow depths to avoid performance penalty, or if show_mugs is enabled *)
+ if !show_mugs || !depth <= !max_mug_depth then begin
let result_mug = mug result in
Printf.eprintf "%s<<< EXIT call #%d depth=%d returns=%s[mug=0x%lx]\n%!"
(indent ()) my_call !depth