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