forked from openrs2/openrs2
parent
4788f8314e
commit
261cc87125
@ -0,0 +1,44 @@ |
|||||||
|
package dev.openrs2.bundler.transform; |
||||||
|
|
||||||
|
import dev.openrs2.asm.classpath.ClassPath; |
||||||
|
import dev.openrs2.asm.transform.Transformer; |
||||||
|
import org.objectweb.asm.Opcodes; |
||||||
|
import org.objectweb.asm.tree.ClassNode; |
||||||
|
import org.objectweb.asm.tree.LdcInsnNode; |
||||||
|
import org.objectweb.asm.tree.MethodNode; |
||||||
|
import org.slf4j.Logger; |
||||||
|
import org.slf4j.LoggerFactory; |
||||||
|
|
||||||
|
public final class CachePathTransformer extends Transformer { |
||||||
|
private static final Logger logger = LoggerFactory.getLogger(CachePathTransformer.class); |
||||||
|
|
||||||
|
private int paths; |
||||||
|
|
||||||
|
@Override |
||||||
|
protected void preTransform(ClassPath classPath) { |
||||||
|
paths = 0; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected boolean transformCode(ClassNode clazz, MethodNode method) { |
||||||
|
for (var it = method.instructions.iterator(); it.hasNext(); ) { |
||||||
|
var insn = it.next(); |
||||||
|
if (insn.getOpcode() != Opcodes.LDC) { |
||||||
|
continue; |
||||||
|
} |
||||||
|
|
||||||
|
var ldc = (LdcInsnNode) insn; |
||||||
|
if (ldc.cst.equals(".jagex_cache_") || ldc.cst.equals(".file_store_")) { |
||||||
|
ldc.cst = ".openrs2_cache_"; |
||||||
|
paths++; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
return false; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected void postTransform(ClassPath classPath) { |
||||||
|
logger.info("Updated {} cache paths", paths); |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue