Rename hasSideEffects() to isPure()

Its output has been inverted, as this wouldn't make sense otherwise.
master
Graham 5 years ago
parent bfdfc2f211
commit fdcc5a217f
  1. 2
      asm/src/main/java/dev/openrs2/asm/InsnListUtils.java
  2. 28
      asm/src/main/java/dev/openrs2/asm/InsnNodeUtils.java
  3. 2
      deob/src/main/java/dev/openrs2/deob/transform/DummyArgTransformer.java

@ -32,7 +32,7 @@ public final class InsnListUtils {
} }
insn = insn.getPrevious(); insn = insn.getPrevious();
} while (insn != null && insn.getType() != AbstractInsnNode.LABEL && !InsnNodeUtils.hasSideEffects(insn)); } while (insn != null && insn.getType() != AbstractInsnNode.LABEL && InsnNodeUtils.isPure(insn));
return false; return false;
} }

@ -119,7 +119,7 @@ public final class InsnNodeUtils {
} }
} }
public static boolean hasSideEffects(AbstractInsnNode insn) { public static boolean isPure(AbstractInsnNode insn) {
var opcode = insn.getOpcode(); var opcode = insn.getOpcode();
switch (opcode) { switch (opcode) {
case -1: case -1:
@ -147,7 +147,7 @@ public final class InsnNodeUtils {
case Opcodes.FLOAD: case Opcodes.FLOAD:
case Opcodes.DLOAD: case Opcodes.DLOAD:
case Opcodes.ALOAD: case Opcodes.ALOAD:
return false; return true;
case Opcodes.IALOAD: case Opcodes.IALOAD:
case Opcodes.LALOAD: case Opcodes.LALOAD:
case Opcodes.FALOAD: case Opcodes.FALOAD:
@ -170,7 +170,7 @@ public final class InsnNodeUtils {
case Opcodes.BASTORE: case Opcodes.BASTORE:
case Opcodes.CASTORE: case Opcodes.CASTORE:
case Opcodes.SASTORE: case Opcodes.SASTORE:
return true; return false;
case Opcodes.POP: case Opcodes.POP:
case Opcodes.POP2: case Opcodes.POP2:
case Opcodes.DUP: case Opcodes.DUP:
@ -226,9 +226,9 @@ public final class InsnNodeUtils {
case Opcodes.LOR: case Opcodes.LOR:
case Opcodes.IXOR: case Opcodes.IXOR:
case Opcodes.LXOR: case Opcodes.LXOR:
return false;
case Opcodes.IINC:
return true; return true;
case Opcodes.IINC:
return false;
case Opcodes.I2L: case Opcodes.I2L:
case Opcodes.I2F: case Opcodes.I2F:
case Opcodes.I2D: case Opcodes.I2D:
@ -249,7 +249,7 @@ public final class InsnNodeUtils {
case Opcodes.FCMPG: case Opcodes.FCMPG:
case Opcodes.DCMPL: case Opcodes.DCMPL:
case Opcodes.DCMPG: case Opcodes.DCMPG:
return false; return true;
case Opcodes.IFEQ: case Opcodes.IFEQ:
case Opcodes.IFNE: case Opcodes.IFNE:
case Opcodes.IFLT: case Opcodes.IFLT:
@ -275,22 +275,22 @@ public final class InsnNodeUtils {
case Opcodes.DRETURN: case Opcodes.DRETURN:
case Opcodes.ARETURN: case Opcodes.ARETURN:
case Opcodes.RETURN: case Opcodes.RETURN:
return true;
case Opcodes.GETSTATIC:
return false; return false;
case Opcodes.GETSTATIC:
return true;
case Opcodes.PUTSTATIC: case Opcodes.PUTSTATIC:
case Opcodes.GETFIELD: case Opcodes.GETFIELD:
/* might throw NPE */ /* might throw NPE */
case Opcodes.PUTFIELD: case Opcodes.PUTFIELD:
return true; return false;
case Opcodes.INVOKEVIRTUAL: case Opcodes.INVOKEVIRTUAL:
case Opcodes.INVOKESPECIAL: case Opcodes.INVOKESPECIAL:
case Opcodes.INVOKESTATIC: case Opcodes.INVOKESTATIC:
case Opcodes.INVOKEINTERFACE: case Opcodes.INVOKEINTERFACE:
case Opcodes.INVOKEDYNAMIC: case Opcodes.INVOKEDYNAMIC:
return true;
case Opcodes.NEW:
return false; return false;
case Opcodes.NEW:
return true;
case Opcodes.NEWARRAY: case Opcodes.NEWARRAY:
case Opcodes.ANEWARRAY: case Opcodes.ANEWARRAY:
/* arrays might be created with negative size */ /* arrays might be created with negative size */
@ -298,15 +298,15 @@ public final class InsnNodeUtils {
/* might throw NPE */ /* might throw NPE */
case Opcodes.ATHROW: case Opcodes.ATHROW:
case Opcodes.CHECKCAST: case Opcodes.CHECKCAST:
return true;
case Opcodes.INSTANCEOF:
return false; return false;
case Opcodes.INSTANCEOF:
return true;
case Opcodes.MONITORENTER: case Opcodes.MONITORENTER:
case Opcodes.MONITOREXIT: case Opcodes.MONITOREXIT:
case Opcodes.MULTIANEWARRAY: case Opcodes.MULTIANEWARRAY:
case Opcodes.IFNULL: case Opcodes.IFNULL:
case Opcodes.IFNONNULL: case Opcodes.IFNONNULL:
return true; return false;
} }
throw new IllegalArgumentException(); throw new IllegalArgumentException();

@ -387,7 +387,7 @@ public final class DummyArgTransformer extends Transformer {
} }
break; break;
default: default:
if (InsnNodeUtils.hasSideEffects(insn) || InsnNodeUtils.isIntConstant(insn)) { if (!InsnNodeUtils.isPure(insn) || InsnNodeUtils.isIntConstant(insn)) {
continue; continue;
} }

Loading…
Cancel
Save