Include last instruction in expression in getExpression output

Every call site except replaceExpression() appended the last instruction
to the end of the list.

Signed-off-by: Graham <gpe@openrs2.org>
master
Graham 6 months ago
parent 1083839720
commit 85b1d52a5c
  1. 5
      asm/src/main/kotlin/org/openrs2/asm/InsnListUtils.kt
  2. 3
      deob-bytecode/src/main/kotlin/org/openrs2/deob/bytecode/remap/StaticFieldUnscrambler.kt
  3. 7
      patcher/src/main/kotlin/org/openrs2/patcher/transform/HighDpiTransformer.kt

@ -16,8 +16,8 @@ public fun getExpression(
var insn: AbstractInsnNode? = last
do {
val (pops, pushes) = insn!!.stackMetadata
expr.add(insn)
if (insn !== last) {
expr.add(insn)
height -= pushes
}
height += pops
@ -38,7 +38,7 @@ public fun InsnList.replaceExpression(
filter: (AbstractInsnNode) -> Boolean = ANY_INSN
): Boolean {
val expr = getExpression(last, filter) ?: return false
expr.forEach(this::remove)
expr.filter { it !== last }.forEach(this::remove)
this[last] = replacement
return true
}
@ -49,7 +49,6 @@ public fun InsnList.deleteExpression(
): Boolean {
val expr = getExpression(last, filter) ?: return false
expr.forEach(this::remove)
remove(last)
return true
}

@ -105,8 +105,7 @@ public class StaticFieldUnscrambler(
}
// TODO(gpe): use a filter here (pure with no *LOADs?)
val expr = getExpression(putstatic) ?: continue
simpleInitializers[desc] = expr.plus(putstatic)
simpleInitializers[desc] = getExpression(putstatic) ?: continue
}
return Pair(simpleInitializers, complexInitializers)

@ -22,7 +22,6 @@ import org.openrs2.asm.classpath.ClassPath
import org.openrs2.asm.classpath.Library
import org.openrs2.asm.getExpression
import org.openrs2.asm.previousReal
import org.openrs2.asm.stackMetadata
import org.openrs2.asm.transform.Transformer
import kotlin.math.max
@ -272,11 +271,7 @@ public class HighDpiTransformer : Transformer() {
var head = invoke.previousReal ?: return false
while (exprs.size < 4) {
val expr = if (head.stackMetadata.pops == 0) {
listOf(head)
} else {
getExpression(head)?.plus(head) ?: return false
}
val expr = getExpression(head) ?: return false
if (invoke.name == "glViewport" && expr.any { it.opcode == Opcodes.IALOAD }) {
/*

Loading…
Cancel
Save