mirror of
https://github.com/revanced/revanced-patcher.git
synced 2025-05-03 22:24:25 +02:00
refactor: Use correct class structure
This commit is contained in:
parent
8c8a251626
commit
642c4ea97e
@ -37,4 +37,5 @@ class PatcherContext internal constructor(options: PatcherOptions) {
|
|||||||
* The [BytecodeContext] of this [PatcherContext].
|
* The [BytecodeContext] of this [PatcherContext].
|
||||||
* This holds the current state of the bytecode.
|
* This holds the current state of the bytecode.
|
||||||
*/
|
*/
|
||||||
internal val bytecodeContext = BytecodeContext(options) }
|
internal val bytecodeContext = BytecodeContext(options)
|
||||||
|
}
|
@ -90,6 +90,34 @@ class BytecodeContext internal constructor(private val options: PatcherOptions)
|
|||||||
*/
|
*/
|
||||||
fun toMethodWalker(startMethod: Method) = MethodWalker(this, startMethod)
|
fun toMethodWalker(startMethod: Method) = MethodWalker(this, startMethod)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Compile bytecode from the [BytecodeContext].
|
||||||
|
*
|
||||||
|
* @return The compiled bytecode.
|
||||||
|
*/
|
||||||
|
override fun get(): List<PatcherResult.PatchedDexFile> {
|
||||||
|
logger.info("Compiling patched dex files")
|
||||||
|
|
||||||
|
val patchedDexFileResults = options.resourceCachePath.resolve("dex").also {
|
||||||
|
it.deleteRecursively() // Make sure the directory is empty.
|
||||||
|
it.mkdirs()
|
||||||
|
}.apply {
|
||||||
|
MultiDexIO.writeDexFile(
|
||||||
|
true,
|
||||||
|
if (options.multithreadingDexFileWriter) -1 else 1,
|
||||||
|
this,
|
||||||
|
BasicDexFileNamer(),
|
||||||
|
object : DexFile {
|
||||||
|
override fun getClasses() = this@BytecodeContext.classes.also(ProxyClassList::replaceClasses)
|
||||||
|
override fun getOpcodes() = this@BytecodeContext.opcodes
|
||||||
|
},
|
||||||
|
DexIO.DEFAULT_MAX_DEX_POOL_SIZE
|
||||||
|
) { _, entryName, _ -> logger.info("Compiled $entryName") }
|
||||||
|
}.listFiles(FileFilter { it.isFile })!!.map { PatcherResult.PatchedDexFile(it.name, it.inputStream()) }
|
||||||
|
|
||||||
|
return patchedDexFileResults
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The integrations of a [PatcherContext].
|
* The integrations of a [PatcherContext].
|
||||||
*/
|
*/
|
||||||
@ -135,32 +163,4 @@ class BytecodeContext internal constructor(private val options: PatcherOptions)
|
|||||||
clear()
|
clear()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Compile bytecode from the [BytecodeContext].
|
|
||||||
*
|
|
||||||
* @return The compiled bytecode.
|
|
||||||
*/
|
|
||||||
override fun get(): List<PatcherResult.PatchedDexFile> {
|
|
||||||
logger.info("Compiling patched dex files")
|
|
||||||
|
|
||||||
val patchedDexFileResults = options.resourceCachePath.resolve("dex").also {
|
|
||||||
it.deleteRecursively() // Make sure the directory is empty.
|
|
||||||
it.mkdirs()
|
|
||||||
}.apply {
|
|
||||||
MultiDexIO.writeDexFile(
|
|
||||||
true,
|
|
||||||
if (options.multithreadingDexFileWriter) -1 else 1,
|
|
||||||
this,
|
|
||||||
BasicDexFileNamer(),
|
|
||||||
object : DexFile {
|
|
||||||
override fun getClasses() = this@BytecodeContext.classes.also(ProxyClassList::replaceClasses)
|
|
||||||
override fun getOpcodes() = this@BytecodeContext.opcodes
|
|
||||||
},
|
|
||||||
DexIO.DEFAULT_MAX_DEX_POOL_SIZE
|
|
||||||
) { _, entryName, _ -> logger.info("Compiled $entryName") }
|
|
||||||
}.listFiles(FileFilter { it.isFile })!!.map { PatcherResult.PatchedDexFile(it.name, it.inputStream()) }
|
|
||||||
|
|
||||||
return patchedDexFileResults
|
|
||||||
}
|
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user