This commit is contained in:
xenia 2021-08-14 19:40:19 -04:00
parent 1a975a65dc
commit 49ac2a8935
1 changed files with 10 additions and 4 deletions

View File

@ -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<String> 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 = "<UNKNOWN " + op + ">";
}
System.out.printf("%04d: ", offset);
System.out.printf("%05d: ", pc);
System.out.println(rep);
offset += 1;
}
}
}