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.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 {
@ -413,15 +421,13 @@ public class Jocaml {
while (this.data.position() < this.data.capacity()) {
int op = this.data.getInt();
String rep = null;
for (CamlInst inst : CamlInst.values()) {
if (inst.code == op) {
rep = inst.name();
for (int i = 0; i < inst.numArgs; i++) {
rep += " " + this.data.getInt();
}
try {
CamlInst inst = CamlInst.values()[op];
rep = inst.name();
for (int i = 0; i < inst.numArgs; i++) {
rep += " " + this.data.getInt();
}
}
if (rep == null) {
} catch (ArrayIndexOutOfBoundsException e) {
rep = "<UNKNOWN " + op + ">";
}
System.out.println(rep);