From 49ac2a8935e1f6b672f23cc1882568885a77bfc1 Mon Sep 17 00:00:00 2001 From: haskal Date: Sat, 14 Aug 2021 19:40:19 -0400 Subject: [PATCH] fix --- Jocaml.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/Jocaml.java b/Jocaml.java index 9293415..243de57 100644 --- a/Jocaml.java +++ b/Jocaml.java @@ -57,7 +57,7 @@ public class Jocaml { RESTART(41, 0), GRAB(42, 1), CLOSURE(43, 2), - CLOSUREREC(44, 4), + CLOSUREREC(44, 2), OFFSETCLOSUREM2(45, 0), OFFSETCLOSURE0(46, 0), OFFSETCLOSURE2(47, 0), @@ -417,8 +417,8 @@ public class Jocaml { public void disassemble(List prim) throws Exception { this.data.order(ByteOrder.LITTLE_ENDIAN); this.data.position(0); - int offset = 0; while (this.data.position() < this.data.capacity()) { + int pc = this.data.position() / 4; int op = this.data.getInt(); String rep = null; try { @@ -433,6 +433,13 @@ public class Jocaml { int n = this.data.getInt(); rep += " " + n; } + } else if (inst == CamlInst.CLOSUREREC) { + int nfuncs = this.data.getInt(); + int nargs = this.data.getInt(); + rep += " " + nfuncs + " " + nargs; + for (int i = 0; i < nfuncs; i++) { + rep += " " + this.data.getInt(); + } } else { for (int i = 0; i < inst.numArgs; i++) { rep += " " + this.data.getInt(); @@ -441,9 +448,8 @@ public class Jocaml { } catch (ArrayIndexOutOfBoundsException e) { rep = ""; } - System.out.printf("%04d: ", offset); + System.out.printf("%05d: ", pc); System.out.println(rep); - offset += 1; } } }