Add InsnList.clone() extension function

Signed-off-by: Graham <gpe@openrs2.org>
Graham 4 years ago
parent d5d76f9301
commit 80957aeca0
  1. 9
      asm/src/main/kotlin/org/openrs2/asm/InsnListUtils.kt

@ -2,6 +2,7 @@ package org.openrs2.asm
import org.objectweb.asm.tree.AbstractInsnNode
import org.objectweb.asm.tree.InsnList
import org.objectweb.asm.tree.LabelNode
private val ANY_INSN = { _: AbstractInsnNode -> true }
@ -51,3 +52,11 @@ public fun InsnList.deleteExpression(
remove(last)
return true
}
public fun InsnList.clone(labels: Map<LabelNode, LabelNode>): InsnList {
val copy = InsnList()
for (insn in this) {
copy.add(insn.clone(labels))
}
return copy
}

Loading…
Cancel
Save