This commit is contained in:
xenia 2021-08-01 15:56:56 -04:00
parent 01bff40719
commit eba135ad2c
1 changed files with 14 additions and 8 deletions

View File

@ -170,6 +170,14 @@ public class Jocaml {
this.code = code; this.code = code;
this.numArgs = numArgs; this.numArgs = numArgs;
} }
static {
for (int i = 0; i < CamlInst.values().length; i++) {
if (CamlInst.values()[i].code != i) {
throw new RuntimeException("what");
}
}
}
} }
private static class CodeOffset { private static class CodeOffset {
@ -413,15 +421,13 @@ public class Jocaml {
while (this.data.position() < this.data.capacity()) { while (this.data.position() < this.data.capacity()) {
int op = this.data.getInt(); int op = this.data.getInt();
String rep = null; String rep = null;
for (CamlInst inst : CamlInst.values()) { try {
if (inst.code == op) { CamlInst inst = CamlInst.values()[op];
rep = inst.name(); rep = inst.name();
for (int i = 0; i < inst.numArgs; i++) { for (int i = 0; i < inst.numArgs; i++) {
rep += " " + this.data.getInt(); rep += " " + this.data.getInt();
}
} }
} } catch (ArrayIndexOutOfBoundsException e) {
if (rep == null) {
rep = "<UNKNOWN " + op + ">"; rep = "<UNKNOWN " + op + ">";
} }
System.out.println(rep); System.out.println(rep);