From 3cf07f5ce20a777eb130ddabd6f42c3390271678 Mon Sep 17 00:00:00 2001 From: Lucaskyy Date: Thu, 14 Apr 2022 12:00:50 +0200 Subject: [PATCH] refactor: replace asInstructions with toInstruction to follow proper naming scheme --- .../app/revanced/patcher/smali/InlineSmaliCompiler.kt | 4 ++-- .../kotlin/app/revanced/patcher/usage/ExamplePatch.kt | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/kotlin/app/revanced/patcher/smali/InlineSmaliCompiler.kt b/src/main/kotlin/app/revanced/patcher/smali/InlineSmaliCompiler.kt index e12ae20..ed3fe18 100644 --- a/src/main/kotlin/app/revanced/patcher/smali/InlineSmaliCompiler.kt +++ b/src/main/kotlin/app/revanced/patcher/smali/InlineSmaliCompiler.kt @@ -53,5 +53,5 @@ class InlineSmaliCompiler { } } -fun String.asInstructions() = InlineSmaliCompiler.compileMethodInstructions(this) -fun String.asInstruction() = this.asInstructions().first() +fun String.toInstructions() = InlineSmaliCompiler.compileMethodInstructions(this) +fun String.toInstruction() = this.toInstructions().first() diff --git a/src/test/kotlin/app/revanced/patcher/usage/ExamplePatch.kt b/src/test/kotlin/app/revanced/patcher/usage/ExamplePatch.kt index 29db4cd..3b04f91 100644 --- a/src/test/kotlin/app/revanced/patcher/usage/ExamplePatch.kt +++ b/src/test/kotlin/app/revanced/patcher/usage/ExamplePatch.kt @@ -13,8 +13,8 @@ import app.revanced.patcher.signature.MethodMetadata import app.revanced.patcher.signature.MethodSignature import app.revanced.patcher.signature.MethodSignatureMetadata import app.revanced.patcher.signature.PatternScanMethod -import app.revanced.patcher.smali.asInstruction -import app.revanced.patcher.smali.asInstructions +import app.revanced.patcher.smali.toInstruction +import app.revanced.patcher.smali.toInstructions import com.google.common.collect.ImmutableList import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.Format @@ -135,7 +135,7 @@ class ExamplePatch : Patch( // store the fields initial value into the first virtual register implementation.replaceInstruction( 0, - "sget-object v0, LTestClass;->dummyField:Ljava/io/PrintStream;".asInstruction() + "sget-object v0, LTestClass;->dummyField:Ljava/io/PrintStream;".toInstruction() ) // Now let's create a new call to our method and print the return value! @@ -147,7 +147,7 @@ class ExamplePatch : Patch( invoke-static { }, LTestClass;->returnHello()Ljava/lang/String; move-result-object v1 invoke-virtual { v0, v1 }, Ljava/io/PrintStream;->println(Ljava/lang/String;)V - """.trimIndent().asInstructions() + """.trimIndent().toInstructions() implementation.addInstructions(startIndex + 2, instructions) // Finally, tell the patcher that this patch was a success.