forked from openrs2/openrs2
Signed-off-by: Graham <gpe@openrs2.dev>bzip2
parent
64dc49e15b
commit
113820a9a2
@ -0,0 +1,13 @@ |
||||
package dev.openrs2.asm.classpath |
||||
|
||||
import org.objectweb.asm.commons.Remapper |
||||
|
||||
abstract class ExtendedRemapper : Remapper() { |
||||
open fun mapFieldOwner(owner: String, name: String, desc: String): String { |
||||
return mapType(owner) |
||||
} |
||||
|
||||
open fun mapMethodOwner(owner: String, name: String, desc: String): String { |
||||
return mapType(owner) |
||||
} |
||||
} |
@ -1,22 +1,29 @@ |
||||
package dev.openrs2.deob.remap |
||||
|
||||
import dev.openrs2.asm.classpath.ExtendedRemapper |
||||
import dev.openrs2.asm.classpath.Library |
||||
import dev.openrs2.asm.filter.ClassFilter |
||||
import org.objectweb.asm.commons.Remapper |
||||
import org.objectweb.asm.commons.SimpleRemapper |
||||
|
||||
object PrefixRemapper { |
||||
fun create(library: Library, prefix: String, excluded: ClassFilter): Remapper { |
||||
val mapping = mutableMapOf<String, String>() |
||||
class PrefixRemapper(private val prefix: String, private val classes: Set<String>) : ExtendedRemapper() { |
||||
override fun map(internalName: String): String { |
||||
return if (classes.contains(internalName)) { |
||||
prefix + internalName |
||||
} else { |
||||
internalName |
||||
} |
||||
} |
||||
|
||||
companion object { |
||||
fun create(library: Library, prefix: String, excluded: ClassFilter): ExtendedRemapper { |
||||
val classes = mutableSetOf<String>() |
||||
|
||||
for (clazz in library) { |
||||
if (excluded.matches(clazz.name)) { |
||||
mapping[clazz.name] = clazz.name |
||||
} else { |
||||
mapping[clazz.name] = prefix + clazz.name |
||||
if (!excluded.matches(clazz.name)) { |
||||
classes += clazz.name |
||||
} |
||||
} |
||||
|
||||
return SimpleRemapper(mapping) |
||||
return PrefixRemapper(prefix, classes) |
||||
} |
||||
} |
||||
} |
||||
|
Loading…
Reference in new issue