Skip to content

Commit

Permalink
refactor: replace asInstructions with toInstruction to follow proper …
Browse files Browse the repository at this point in the history
…naming scheme
  • Loading branch information
Sculas authored and oSumAtrIX committed Jun 5, 2022
1 parent 0bfb92a commit 3cf07f5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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()
8 changes: 4 additions & 4 deletions src/test/kotlin/app/revanced/patcher/usage/ExamplePatch.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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!
Expand All @@ -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.
Expand Down

0 comments on commit 3cf07f5

Please sign in to comment.