use of net.runelite.asm.ClassFile in project runelite by runelite.
the class OpcodesTransformer method transform.
@Override
public void transform(ClassGroup group) {
ClassFile runeliteOpcodes = group.findClass(RUNELITE_OPCODES);
if (runeliteOpcodes == null) {
runeliteOpcodes = new ClassFile(group);
runeliteOpcodes.setName(RUNELITE_OPCODES);
runeliteOpcodes.setSuperName(Type.OBJECT.getInternalName());
runeliteOpcodes.setAccess(Opcodes.ACC_PUBLIC);
group.addClass(runeliteOpcodes);
} else {
runeliteOpcodes.getFields().clear();
}
Method clinit = runeliteOpcodes.findMethod("<clinit>");
if (clinit == null) {
clinit = new Method(runeliteOpcodes, "<clinit>", new Signature("()V"));
clinit.setStatic();
Code code = new Code(clinit);
code.setMaxStack(1);
clinit.setCode(code);
runeliteOpcodes.addMethod(clinit);
Instructions instructions = code.getInstructions();
instructions.addInstruction(new VReturn(instructions));
}
}
use of net.runelite.asm.ClassFile in project runelite by runelite.
the class RuneliteBufferTransformer method injectRunelitePacket.
/**
* inject RUNELITE_PACKET field
*
* @param group
*/
private void injectRunelitePacket(ClassGroup group) {
ClassFile client = findClient(group);
assert client != null : "no client class";
if (client.findField(RUNELITE_PACKET) != null) {
return;
}
Field field = new Field(client, RUNELITE_PACKET, Type.BOOLEAN);
field.setAccessFlags(Opcodes.ACC_PUBLIC | Opcodes.ACC_STATIC);
client.addField(field);
}
use of net.runelite.asm.ClassFile in project runelite by runelite.
the class ParallelExecutorMapping method mapClass.
private void mapClass(StaticInitializerIndexer staticIndexer1, StaticInitializerIndexer staticIndexer2, Object one, Object two) {
ClassFile cf1, cf2;
if (one instanceof Field || two instanceof Field) {
assert one instanceof Field;
assert two instanceof Field;
Field f1 = (Field) one;
Field f2 = (Field) two;
assert f1.isStatic() == f2.isStatic();
if (staticIndexer1.isStatic(f1) && staticIndexer2.isStatic(f2)) {
logger.debug("Mapping class of {} -> {} due to static initializer", f1, f2);
} else if (f1.isStatic() || f2.isStatic()) {
return;
}
cf1 = f1.getClassFile();
cf2 = f2.getClassFile();
} else if (one instanceof Method || two instanceof Method) {
assert one instanceof Method;
assert two instanceof Method;
Method m1 = (Method) one;
Method m2 = (Method) two;
assert m1.isStatic() == m1.isStatic();
if (m1.isStatic() || m2.isStatic()) {
return;
}
cf1 = m1.getClassFile();
cf2 = m2.getClassFile();
} else {
assert false;
return;
}
belongs(cf1, group);
belongs(cf2, group2);
Mapping m = getMapping(cf1, cf2);
m.inc();
}
use of net.runelite.asm.ClassFile in project runelite by runelite.
the class ParallelExecutorMapping method buildClasses.
public void buildClasses() {
for (Object o : new HashSet<>(map.keySet())) {
if (o instanceof ClassFile) {
map.removeAll(o);
}
}
StaticInitializerIndexer staticIndexer1 = new StaticInitializerIndexer(group);
staticIndexer1.index();
StaticInitializerIndexer staticIndexer2 = new StaticInitializerIndexer(group2);
staticIndexer2.index();
Map<Object, Object> map = getMap();
for (Object key : map.keySet()) {
Object value = map.get(key);
mapClass(staticIndexer1, staticIndexer2, key, value);
}
// rebuild map now we've inserted classes...
map = getMap();
reduce();
/* get leftover classes, they usually contain exclusively static
* fields and methods so they're hard to pinpoint
*/
ClassGroupMapper m = new ClassGroupMapper(group, group2);
m.map();
for (ClassFile cf : group.getClasses()) {
if (!map.containsKey(cf)) {
ClassFile other = m.get(cf);
if (other == null) {
logger.info("Unable to map class {}", cf);
} else {
// these are both probably very small
long nonStaticFields = cf.getFields().stream().filter(f -> !f.isStatic()).count(), nonStaticMethods = cf.getMethods().stream().filter(m2 -> !m2.isStatic()).count();
logger.info("Build classes fallback {} -> {}, non static fields: {}, non static methods: {}", cf, other, nonStaticFields, nonStaticMethods);
Mapping ma = getMapping(cf, other);
ma.inc();
}
}
}
}
use of net.runelite.asm.ClassFile in project runelite by runelite.
the class PacketTypeFinder method find.
public void find() {
for (ClassFile cf : group.getClasses()) {
for (Method method : cf.getMethods()) {
run(method.getCode());
}
}
packetType = sets.entrySet().stream().max((entry1, entry2) -> Integer.compare(entry1.getValue(), entry2.getValue())).get().getKey();
logger.info("Identified {} as packetType", packetType);
}
Aggregations