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

View File

@@ -3,20 +3,15 @@ package com.dfsek.terra.addons.terrascript.codegen.asm;
import org.objectweb.asm.Opcodes;
public enum OpcodeAlias {
CMP_GREATER_THAN(Opcodes.IFGT),
CMP_GREATER_EQUALS(Opcodes.IFGE),
CMP_LESS_THAN(Opcodes.IFLT),
CMP_LESS_EQUALS(Opcodes.IFLE),
CMP_EQUALS(Opcodes.IFEQ),
CMP_NOT_EQUALS(Opcodes.IFNE),
BOOL_FALSE(Opcodes.IFEQ),
BOOL_TRUE(Opcodes.IFNE),
INTEGERS_EQUAL(Opcodes.IF_ICMPEQ),
INTEGERS_NOT_EQUAL(Opcodes.IF_ICMPNE),
;
public final int opcode;
OpcodeAlias(int opcode) { this.opcode = opcode; }
public class OpcodeAlias {
public static int CMP_GREATER_THAN = Opcodes.IFGT;
public static int CMP_GREATER_EQUALS = Opcodes.IFGE;
public static int CMP_LESS_THAN = Opcodes.IFLT;
public static int CMP_LESS_EQUALS = Opcodes.IFLE;
public static int CMP_EQUALS = Opcodes.IFEQ;
public static int CMP_NOT_EQUALS = Opcodes.IFNE;
public static int BOOL_FALSE = Opcodes.IFEQ;
public static int BOOL_TRUE = Opcodes.IFNE;
public static int INTEGERS_EQUAL = Opcodes.IF_ICMPEQ;
public static int INTEGERS_NOT_EQUAL = Opcodes.IF_ICMPNE;
}

View File

@@ -466,8 +466,8 @@ public class TerraScriptClassGenerator {
method.visitInsn(Opcodes.ICONST_0);
}
private void jumpIf(OpcodeAlias insn, Label label) {
method.visitJumpInsn(insn.opcode, label);
private void jumpIf(int opcode, Label label) {
method.visitJumpInsn(opcode, label);
}
private void jump(Label label) {