@@ -7,9 +7,7 @@ import app.revanced.patcher.cache.PatternScanData
7
7
import app.revanced.patcher.signature.Signature
8
8
import app.revanced.patcher.util.ExtraTypes
9
9
import org.objectweb.asm.Type
10
- import org.objectweb.asm.tree.ClassNode
11
- import org.objectweb.asm.tree.InsnList
12
- import org.objectweb.asm.tree.MethodNode
10
+ import org.objectweb.asm.tree.*
13
11
14
12
private val logger = KotlinLogging .logger(" MethodResolver" )
15
13
@@ -110,7 +108,7 @@ internal class MethodResolver(private val classList: List<ClassNode>, private va
110
108
}
111
109
112
110
signature.opcodes?.let { _ ->
113
- val result = method.instructions.scanFor(signature.opcodes)
111
+ val result = method.instructions.stripLabels(). scanFor(signature.opcodes)
114
112
if (! result.found) {
115
113
logger.debug { " Comparing sig ${signature.name} : invalid opcode pattern" }
116
114
return @cmp false to null
@@ -123,13 +121,8 @@ internal class MethodResolver(private val classList: List<ClassNode>, private va
123
121
}
124
122
}
125
123
126
- private operator fun ClassNode.component1 (): ClassNode {
127
- return this
128
- }
129
-
130
- private operator fun ClassNode.component2 (): List <MethodNode > {
131
- return this .methods
132
- }
124
+ private operator fun ClassNode.component1 () = this
125
+ private operator fun ClassNode.component2 () = this .methods
133
126
134
127
private fun InsnList.scanFor (pattern : IntArray ): ScanResult {
135
128
for (i in 0 until this .size()) {
@@ -157,3 +150,8 @@ private fun Type.convertObject(): Type {
157
150
private fun Array<Type>.convertObjects (): Array <Type > {
158
151
return this .map { it.convertObject() }.toTypedArray()
159
152
}
153
+
154
+ private fun InsnList.stripLabels (): InsnList {
155
+ this .removeAll { it is LabelNode || it is LineNumberNode }
156
+ return this
157
+ }
0 commit comments