Convert stackMetadata to an extension property

It feels much more like a property than a function.

Signed-off-by: Graham <gpe@openrs2.dev>
Graham 4 years ago
parent b6f7576864
commit 47d1bc0bd2
  1. 2
      asm/src/main/java/dev/openrs2/asm/InsnListUtils.kt
  2. 3
      asm/src/main/java/dev/openrs2/asm/StackMetadata.kt
  3. 2
      deob/src/main/java/dev/openrs2/deob/transform/ConstantArgTransformer.kt

@ -14,7 +14,7 @@ fun getExpression(
var height = 0 var height = 0
var insn: AbstractInsnNode? = last var insn: AbstractInsnNode? = last
do { do {
val (pops, pushes) = insn!!.stackMetadata() val (pops, pushes) = insn!!.stackMetadata
if (insn !== last) { if (insn !== last) {
expr.add(insn) expr.add(insn)
height -= pushes height -= pushes

@ -181,7 +181,8 @@ private val SIMPLE_OPCODES = mapOf(
Opcodes.IFNONNULL to POP1 Opcodes.IFNONNULL to POP1
) )
fun AbstractInsnNode.stackMetadata(): StackMetadata = when (this) { val AbstractInsnNode.stackMetadata
get() = when (this) {
is LdcInsnNode -> if (cst is Double || cst is Long) { is LdcInsnNode -> if (cst is Double || cst is Long) {
PUSH2 PUSH2
} else { } else {

@ -262,7 +262,7 @@ class ConstantArgTransformer : Transformer() {
} else if (!insn.pure) { } else if (!insn.pure) {
// can't replace instructions with a side effect // can't replace instructions with a side effect
continue continue
} else if (insn.stackMetadata().pushes != 1) { } else if (insn.stackMetadata.pushes != 1) {
// can't replace instructions pushing more than one result // can't replace instructions pushing more than one result
continue continue
} }

Loading…
Cancel
Save