diff options
author | polwex <polwex@sortug.com> | 2025-10-07 01:40:54 +0700 |
---|---|---|
committer | polwex <polwex@sortug.com> | 2025-10-07 01:40:54 +0700 |
commit | a12407b3f152a3dbd716d640202b9613c61d6105 (patch) | |
tree | 411c630824b992d3a7f5e3d17c83a8546577bad7 /ocaml/lib | |
parent | d0064c2f577c56a9e5b3fc00b45f71a73f3574c9 (diff) |
lmao turned down the bytecode interpreter in Vere and it started giving the same results as us smh
Diffstat (limited to 'ocaml/lib')
-rw-r--r-- | ocaml/lib/boot.ml | 6 | ||||
-rw-r--r-- | ocaml/lib/nock.ml | 110 |
2 files changed, 57 insertions, 59 deletions
diff --git a/ocaml/lib/boot.ml b/ocaml/lib/boot.ml index 1aeafaf..26f2177 100644 --- a/ocaml/lib/boot.ml +++ b/ocaml/lib/boot.ml @@ -208,6 +208,7 @@ let life eve = let result = Nock.nock_on eve lifecycle_formula in Printf.printf "[Boot] ✓ Nock.nock_on returned successfully\n%!"; + Printf.printf "[Boot] Gate mug: 0x%08lx\n%!" (Noun.mug result); result with e -> Printf.printf "[Boot] ✗ Nock failed during lifecycle: %s\n%!" @@ -216,11 +217,14 @@ let life eve = in Printf.printf "[Boot] ✓ Lifecycle formula completed\n%!"; + Printf.printf "[Boot] (gate structure for comparison)\n%!"; (* Extract slot 7 (the kernel) from resulting gate *) let cor = try - Noun.slot (Z.of_int 7) gat + let result_slot7 = Noun.slot (Z.of_int 7) gat in + Printf.printf "[Boot] Slot 7 mug: 0x%08lx\n%!" (Noun.mug result_slot7); + result_slot7 with e -> Printf.printf "[Boot] ✗ Failed to extract slot 7: %s\n%!" (Printexc.to_string e); diff --git a/ocaml/lib/nock.ml b/ocaml/lib/nock.ml index 5658ed7..64daa91 100644 --- a/ocaml/lib/nock.ml +++ b/ocaml/lib/nock.ml @@ -41,40 +41,41 @@ let opcode_name op = let rec nock_on init_bus init_fol = let bus = ref init_bus in let fol = ref init_fol in + let my_call = !call_count in - let rec loop () = - let my_call = !call_count in - - (* Check if this is opcode 0 (slot lookup) - C doesn't log these *) - let is_slot = match !fol with - | Cell { h = Atom { z = op; _ }; _ } when Z.fits_int op && Z.to_int op = 0 -> true - | _ -> false - in + (* Check if this is opcode 0 (slot lookup) - C doesn't log these *) + let is_slot = match init_fol with + | Cell { h = Atom { z = op; _ }; _ } when Z.fits_int op && Z.to_int op = 0 -> true + | _ -> false + in - let should_log = my_call < max_calls && not is_slot in + let should_log = my_call < max_calls && not is_slot in - (* Log entry *) - if should_log then begin - let opcode_str = match !fol with - | Cell { h = Atom { z = op; _ }; _ } when Z.fits_int op -> opcode_name (Z.to_int op) - | Cell { h = Cell _; _ } -> "CELL(dist)" - | _ -> "?" - in - 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 - (if is_cell !bus then "cell" else "atom") - bus_mug - end else begin - Printf.eprintf "%s>>> ENTER call #%d depth=%d opcode=%s bus=%s\n%!" - (indent ()) my_call !depth opcode_str - (if is_cell !bus then "cell" else "atom") - end; - incr call_count + (* Log entry ONCE at function entry *) + if should_log then begin + let opcode_str = match init_fol with + | Cell { h = Atom { z = op; _ }; _ } when Z.fits_int op -> opcode_name (Z.to_int op) + | Cell { h = Cell _; _ } -> "CELL(dist)" + | _ -> "?" + in + if !show_mugs || !depth <= !max_mug_depth then begin + let bus_mug = mug init_bus in + Printf.eprintf "%s>>> ENTER call #%d depth=%d opcode=%s bus=%s[mug=0x%lx]\n%!" + (indent ()) my_call !depth opcode_str + (if is_cell init_bus then "cell" else "atom") + bus_mug + end else begin + Printf.eprintf "%s>>> ENTER call #%d depth=%d opcode=%s bus=%s\n%!" + (indent ()) my_call !depth opcode_str + (if is_cell init_bus then "cell" else "atom") end; + incr call_count + end; + + (* Increment depth ONCE at function entry *) + incr depth; - incr depth; + let rec loop () = try let result = match !fol with @@ -101,18 +102,29 @@ let rec nock_on init_bus init_fol = if not (is_cell gal) then raise Exit; let c_gal = tail gal in let b_gal = head gal in + + (* Debug first call *) + if my_call = 0 then begin + Printf.eprintf "[Op2 Debug] Computing formula (tail gal):\n%!"; + Printf.eprintf " c_gal mug: 0x%lx\n%!" (mug c_gal); + end; + let nex = nock_on !bus c_gal in + + if my_call = 0 then begin + Printf.eprintf " nex mug: 0x%lx\n%!" (mug nex); + Printf.eprintf "[Op2 Debug] Computing subject (head gal):\n%!"; + Printf.eprintf " b_gal mug: 0x%lx\n%!" (mug b_gal); + end; + let seb = nock_on !bus b_gal in + + if my_call = 0 then begin + Printf.eprintf " seb mug: 0x%lx\n%!" (mug seb); + end; + bus := seb; fol := nex; - decr depth; - if should_log then begin - if !show_mugs || !depth <= !max_mug_depth then begin - let result_mug = mug !bus in - Printf.eprintf "%s<<< CONTINUE call #%d depth=%d with bus[mug=0x%lx]\n%!" - (indent ()) my_call !depth result_mug - end - end; loop () | 3 -> @@ -145,11 +157,7 @@ let rec nock_on init_bus init_fol = | _ -> raise Exit in fol := nex; - decr depth; - if should_log then begin - Printf.eprintf "%s<<< CONTINUE call #%d depth=%d (if-branch)\n%!" - (indent ()) my_call !depth - end; + (* Don't decr depth for tail calls *) loop () | 7 -> @@ -160,14 +168,7 @@ let rec nock_on init_bus init_fol = let bod = nock_on !bus b_gal in bus := bod; fol := c_gal; - decr depth; - if should_log then begin - if !show_mugs || !depth <= !max_mug_depth then begin - let result_mug = mug !bus in - Printf.eprintf "%s<<< CONTINUE call #%d depth=%d with bus[mug=0x%lx]\n%!" - (indent ()) my_call !depth result_mug - end - end; + (* Don't decr depth for tail calls *) loop () | 8 -> @@ -179,14 +180,7 @@ let rec nock_on init_bus init_fol = let bod = cell heb !bus in bus := bod; fol := c_gal; - decr depth; - if should_log then begin - if !show_mugs || !depth <= !max_mug_depth then begin - let result_mug = mug !bus in - Printf.eprintf "%s<<< CONTINUE call #%d depth=%d with bus[mug=0x%lx]\n%!" - (indent ()) my_call !depth result_mug - end - end; + (* Don't decr depth for tail calls *) loop () | 9 -> |