Use static ints instead of enum

This commit is contained in:
Astrash
2023-09-12 13:42:23 +10:00
parent defb31e309
commit 37b5a2ec92
2 changed files with 13 additions and 18 deletions
@@ -3,20 +3,15 @@ package com.dfsek.terra.addons.terrascript.codegen.asm;
import org.objectweb.asm.Opcodes; import org.objectweb.asm.Opcodes;
public enum OpcodeAlias { public class OpcodeAlias {
CMP_GREATER_THAN(Opcodes.IFGT), public static int CMP_GREATER_THAN = Opcodes.IFGT;
CMP_GREATER_EQUALS(Opcodes.IFGE), public static int CMP_GREATER_EQUALS = Opcodes.IFGE;
CMP_LESS_THAN(Opcodes.IFLT), public static int CMP_LESS_THAN = Opcodes.IFLT;
CMP_LESS_EQUALS(Opcodes.IFLE), public static int CMP_LESS_EQUALS = Opcodes.IFLE;
CMP_EQUALS(Opcodes.IFEQ), public static int CMP_EQUALS = Opcodes.IFEQ;
CMP_NOT_EQUALS(Opcodes.IFNE), public static int CMP_NOT_EQUALS = Opcodes.IFNE;
BOOL_FALSE(Opcodes.IFEQ), public static int BOOL_FALSE = Opcodes.IFEQ;
BOOL_TRUE(Opcodes.IFNE), public static int BOOL_TRUE = Opcodes.IFNE;
INTEGERS_EQUAL(Opcodes.IF_ICMPEQ), public static int INTEGERS_EQUAL = Opcodes.IF_ICMPEQ;
INTEGERS_NOT_EQUAL(Opcodes.IF_ICMPNE), public static int INTEGERS_NOT_EQUAL = Opcodes.IF_ICMPNE;
;
public final int opcode;
OpcodeAlias(int opcode) { this.opcode = opcode; }
} }
@@ -466,8 +466,8 @@ public class TerraScriptClassGenerator {
method.visitInsn(Opcodes.ICONST_0); method.visitInsn(Opcodes.ICONST_0);
} }
private void jumpIf(OpcodeAlias insn, Label label) { private void jumpIf(int opcode, Label label) {
method.visitJumpInsn(insn.opcode, label); method.visitJumpInsn(opcode, label);
} }
private void jump(Label label) { private void jump(Label label) {