Open-source multiplayer game server compatible with the RuneScape client
https://www.openrs2.org/
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
110 lines
3.0 KiB
110 lines
3.0 KiB
package dev.openrs2.asm.transform
|
|
|
|
import dev.openrs2.asm.classpath.ClassPath
|
|
import dev.openrs2.asm.classpath.Library
|
|
import dev.openrs2.asm.hasCode
|
|
import org.objectweb.asm.tree.ClassNode
|
|
import org.objectweb.asm.tree.FieldNode
|
|
import org.objectweb.asm.tree.MethodNode
|
|
import org.objectweb.asm.tree.analysis.AnalyzerException
|
|
|
|
abstract class Transformer {
|
|
@Throws(AnalyzerException::class)
|
|
fun transform(classPath: ClassPath) {
|
|
preTransform(classPath)
|
|
|
|
var changed: Boolean
|
|
do {
|
|
changed = false
|
|
|
|
prePass(classPath)
|
|
for (library in classPath.libraries) {
|
|
for (clazz in library) {
|
|
changed = changed or transformClass(classPath, library, clazz)
|
|
|
|
for (field in clazz.fields) {
|
|
changed = changed or transformField(classPath, library, clazz, field)
|
|
}
|
|
|
|
for (method in clazz.methods) {
|
|
changed = changed or preTransformMethod(classPath, library, clazz, method)
|
|
|
|
if (method.hasCode()) {
|
|
changed = changed or transformCode(classPath, library, clazz, method)
|
|
}
|
|
|
|
changed = changed or postTransformMethod(classPath, library, clazz, method)
|
|
}
|
|
}
|
|
}
|
|
postPass(classPath)
|
|
} while (changed)
|
|
|
|
postTransform(classPath)
|
|
}
|
|
|
|
@Throws(AnalyzerException::class)
|
|
protected open fun preTransform(classPath: ClassPath) {
|
|
/* empty */
|
|
}
|
|
|
|
@Throws(AnalyzerException::class)
|
|
protected open fun prePass(classPath: ClassPath) {
|
|
/* empty */
|
|
}
|
|
|
|
@Throws(AnalyzerException::class)
|
|
protected open fun transformClass(classPath: ClassPath, library: Library, clazz: ClassNode): Boolean {
|
|
return false
|
|
}
|
|
|
|
@Throws(AnalyzerException::class)
|
|
protected open fun transformField(
|
|
classPath: ClassPath,
|
|
library: Library,
|
|
clazz: ClassNode,
|
|
field: FieldNode
|
|
): Boolean {
|
|
return false
|
|
}
|
|
|
|
@Throws(AnalyzerException::class)
|
|
protected open fun preTransformMethod(
|
|
classPath: ClassPath,
|
|
library: Library,
|
|
clazz: ClassNode,
|
|
method: MethodNode
|
|
): Boolean {
|
|
return false
|
|
}
|
|
|
|
@Throws(AnalyzerException::class)
|
|
protected open fun transformCode(
|
|
classPath: ClassPath,
|
|
library: Library,
|
|
clazz: ClassNode,
|
|
method: MethodNode
|
|
): Boolean {
|
|
return false
|
|
}
|
|
|
|
@Throws(AnalyzerException::class)
|
|
protected open fun postTransformMethod(
|
|
classPath: ClassPath,
|
|
library: Library,
|
|
clazz: ClassNode,
|
|
method: MethodNode
|
|
): Boolean {
|
|
return false
|
|
}
|
|
|
|
@Throws(AnalyzerException::class)
|
|
protected open fun postPass(classPath: ClassPath) {
|
|
/* empty */
|
|
}
|
|
|
|
@Throws(AnalyzerException::class)
|
|
protected open fun postTransform(classPath: ClassPath) {
|
|
/* empty */
|
|
}
|
|
}
|
|
|