Add seperate {Field,Method}Node::remap extension methods

Signed-off-by: Graham <gpe@openrs2.dev>
bzip2
Graham 5 years ago
parent a3ec4ec322
commit 325ce27a31
  1. 36
      asm/src/main/java/dev/openrs2/asm/ClassNodeRemapper.kt

@ -4,10 +4,12 @@ import dev.openrs2.asm.classpath.ExtendedRemapper
import org.objectweb.asm.tree.AbstractInsnNode import org.objectweb.asm.tree.AbstractInsnNode
import org.objectweb.asm.tree.ClassNode import org.objectweb.asm.tree.ClassNode
import org.objectweb.asm.tree.FieldInsnNode import org.objectweb.asm.tree.FieldInsnNode
import org.objectweb.asm.tree.FieldNode
import org.objectweb.asm.tree.FrameNode import org.objectweb.asm.tree.FrameNode
import org.objectweb.asm.tree.InvokeDynamicInsnNode import org.objectweb.asm.tree.InvokeDynamicInsnNode
import org.objectweb.asm.tree.LdcInsnNode import org.objectweb.asm.tree.LdcInsnNode
import org.objectweb.asm.tree.MethodInsnNode import org.objectweb.asm.tree.MethodInsnNode
import org.objectweb.asm.tree.MethodNode
import org.objectweb.asm.tree.MultiANewArrayInsnNode import org.objectweb.asm.tree.MultiANewArrayInsnNode
import org.objectweb.asm.tree.TypeInsnNode import org.objectweb.asm.tree.TypeInsnNode
@ -19,31 +21,39 @@ fun ClassNode.remap(remapper: ExtendedRemapper) {
interfaces = interfaces?.map(remapper::mapType) interfaces = interfaces?.map(remapper::mapType)
for (field in fields) { for (field in fields) {
field.name = remapper.mapFieldName(originalName, field.name, field.desc) field.remap(remapper, originalName)
field.desc = remapper.mapDesc(field.desc)
field.signature = remapper.mapSignature(field.signature, true)
field.value = remapper.mapValue(field.value)
} }
for (method in methods) { for (method in methods) {
method.name = remapper.mapMethodName(originalName, method.name, method.desc) method.remap(remapper, originalName)
method.desc = remapper.mapMethodDesc(method.desc) }
method.signature = remapper.mapSignature(method.signature, false) }
method.exceptions = method.exceptions.map(remapper::mapType)
fun FieldNode.remap(remapper: ExtendedRemapper, owner: String) {
name = remapper.mapFieldName(owner, name, desc)
desc = remapper.mapDesc(desc)
signature = remapper.mapSignature(signature, true)
value = remapper.mapValue(value)
}
fun MethodNode.remap(remapper: ExtendedRemapper, owner: String) {
name = remapper.mapMethodName(owner, name, desc)
desc = remapper.mapMethodDesc(desc)
signature = remapper.mapSignature(signature, false)
exceptions = exceptions.map(remapper::mapType)
if (method.hasCode) { if (hasCode) {
ClassForNameUtils.remap(remapper, method) ClassForNameUtils.remap(remapper, this)
for (insn in method.instructions) { for (insn in instructions) {
insn.remap(remapper) insn.remap(remapper)
} }
for (tryCatch in method.tryCatchBlocks) { for (tryCatch in tryCatchBlocks) {
tryCatch.type = remapper.mapType(tryCatch.type) tryCatch.type = remapper.mapType(tryCatch.type)
} }
} }
} }
}
private fun AbstractInsnNode.remap(remapper: ExtendedRemapper) { private fun AbstractInsnNode.remap(remapper: ExtendedRemapper) {
when (this) { when (this) {

Loading…
Cancel
Save