mirror of
https://github.com/revanced/revanced-patcher.git
synced 2025-05-01 13:44:25 +02:00
feat: optional forStaticMethod
parameter for InlineSmaliCompiler.compileMethodInstructions
This commit is contained in:
parent
893d4c699b
commit
41e88605c3
@ -13,9 +13,9 @@ import org.jf.smali.smaliTreeWalker
|
|||||||
import java.io.InputStreamReader
|
import java.io.InputStreamReader
|
||||||
|
|
||||||
private const val METHOD_TEMPLATE = """
|
private const val METHOD_TEMPLATE = """
|
||||||
.class public Linlinecompiler;
|
.class LInlineCompiler;
|
||||||
.super Ljava/lang/Object;
|
.super Ljava/lang/Object;
|
||||||
.method public static compiler(%s)V
|
.method %s dummyMethod(%s)V
|
||||||
.registers %d
|
.registers %d
|
||||||
%s
|
%s
|
||||||
.end method
|
.end method
|
||||||
@ -35,9 +35,10 @@ class InlineSmaliCompiler {
|
|||||||
fun compileMethodInstructions(
|
fun compileMethodInstructions(
|
||||||
instructions: String,
|
instructions: String,
|
||||||
parameters: String,
|
parameters: String,
|
||||||
registers: Int
|
registers: Int,
|
||||||
|
forStaticMethod: Boolean
|
||||||
): List<BuilderInstruction> {
|
): List<BuilderInstruction> {
|
||||||
val input = METHOD_TEMPLATE.format(parameters, registers, instructions)
|
val input = METHOD_TEMPLATE.format(if (forStaticMethod) "static" else "", parameters, registers, instructions)
|
||||||
val reader = InputStreamReader(input.byteInputStream())
|
val reader = InputStreamReader(input.byteInputStream())
|
||||||
val lexer: LexerErrorInterface = smaliFlexLexer(reader, 15)
|
val lexer: LexerErrorInterface = smaliFlexLexer(reader, 15)
|
||||||
val tokens = CommonTokenStream(lexer as TokenSource)
|
val tokens = CommonTokenStream(lexer as TokenSource)
|
||||||
@ -58,8 +59,8 @@ class InlineSmaliCompiler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun String.toInstructions(parameters: String = "", registers: Int = 1) =
|
fun String.toInstructions(parameters: String = "", registers: Int = 1, forStaticMethod: Boolean = true) =
|
||||||
InlineSmaliCompiler.compileMethodInstructions(this, parameters, registers)
|
InlineSmaliCompiler.compileMethodInstructions(this, parameters, registers, forStaticMethod)
|
||||||
|
|
||||||
fun String.toInstruction(parameters: String = "", registers: Int = 1) =
|
fun String.toInstruction(parameters: String = "", registers: Int = 1, forStaticMethod: Boolean = true) =
|
||||||
this.toInstructions(parameters, registers).first()
|
this.toInstructions(parameters, registers, forStaticMethod).first()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user