From eba135ad2c3b861df9b4bdd383a03cb5ee11bbe4 Mon Sep 17 00:00:00 2001 From: haskal Date: Sun, 1 Aug 2021 15:56:56 -0400 Subject: [PATCH] flopppp --- Jocaml.java | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/Jocaml.java b/Jocaml.java index ef219c4..ffacb56 100644 --- a/Jocaml.java +++ b/Jocaml.java @@ -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 = ""; } System.out.println(rep);