refact: remove obsolete SignatureParser

Signed-off-by: oSumAtrIX <johan.melkonyan1@web.de>
This commit is contained in:
oSumAtrIX 2022-04-14 10:59:04 +02:00
parent 555b38f386
commit d14fd901c0
No known key found for this signature in database
GPG Key ID: A9B3094ACDB604B4

View File

@ -1,44 +0,0 @@
package app.revanced.cli.utils
import app.revanced.patcher.signature.MethodSignature
import com.google.gson.JsonParser
import me.tongfei.progressbar.ProgressBar
import org.jf.dexlib2.AccessFlags
import org.jf.dexlib2.Opcodes
class SignatureParser {
companion object {
fun parse(json: String, bar: ProgressBar): List<MethodSignature> {
val tmp = JsonParser.parseString(json).asJsonObject.get("signatures").asJsonArray
bar.reset().maxHint(tmp.size().toLong())
.extraMessage = "Parsing signatures"
val signatures = tmp.map { sig ->
val signature = sig.asJsonObject
val returnType = signature.get("returns").asString
var accessFlags = 0
signature
.get("accessors").asJsonArray
.forEach { accessFlags = accessFlags or AccessFlags.getAccessFlag(it.asString).value }
val parameters = signature.get("parameters").asJsonArray
.map { it.asString }
val opcodes = signature.get("opcodes").asJsonArray
.map { Opcodes.getDefault().getOpcodeByName(it.asString)!! }
val name = signature.get("name").asString
bar.step()
.extraMessage = "Parsing $name"
MethodSignature(
name,
returnType,
accessFlags,
parameters,
opcodes
)
}
return signatures
}
}
}