use of net.runelite.asm.Field in project runelite by runelite.
the class ArrayStore method map.
@Override
public void map(ParallelExecutorMapping mapping, InstructionContext ctx, InstructionContext other) {
assert ctx.getInstruction().getClass() == other.getInstruction().getClass();
Field myField = this.getMyField(ctx), otherField = ((ArrayStore) other.getInstruction()).getMyField(other);
mapping.map(this, myField, otherField);
// map value
StackContext // value set to.
object1 = ctx.getPops().get(0), object2 = other.getPops().get(0);
InstructionContext base1 = MappingExecutorUtil.resolve(object1.getPushed(), object1);
InstructionContext base2 = MappingExecutorUtil.resolve(object2.getPushed(), object2);
if (base1.getInstruction() instanceof GetFieldInstruction && base2.getInstruction() instanceof GetFieldInstruction) {
GetFieldInstruction gf1 = (GetFieldInstruction) base1.getInstruction(), gf2 = (GetFieldInstruction) base2.getInstruction();
Field f1 = gf1.getMyField(), f2 = gf2.getMyField();
assert MappingExecutorUtil.isMaybeEqual(f1, f2);
if (f1 != null && f2 != null) {
mapping.map(this, f1, f2);
}
}
}
use of net.runelite.asm.Field in project runelite by runelite.
the class SubtractionInstruction method map.
@Override
default void map(ParallelExecutorMapping mappings, InstructionContext ctx, InstructionContext other) {
StackContext s1 = ctx.getPops().get(0), s2 = ctx.getPops().get(1);
StackContext o1 = other.getPops().get(0), o2 = other.getPops().get(1);
InstructionContext i1 = MappingExecutorUtil.resolve(s1.getPushed(), s1);
InstructionContext i2 = MappingExecutorUtil.resolve(s2.getPushed(), s2);
InstructionContext io1 = MappingExecutorUtil.resolve(o1.getPushed(), o1);
InstructionContext io2 = MappingExecutorUtil.resolve(o2.getPushed(), o2);
if (i1.getInstruction() instanceof GetFieldInstruction && io1.getInstruction() instanceof GetFieldInstruction) {
GetFieldInstruction f1 = (GetFieldInstruction) i1.getInstruction();
GetFieldInstruction f2 = (GetFieldInstruction) io1.getInstruction();
Field fi1 = f1.getMyField(), fi2 = f2.getMyField();
assert MappingExecutorUtil.isMaybeEqual(fi1, fi2);
if (fi1 != null && fi2 != null) {
mappings.map((Instruction) this, fi1, fi2);
}
}
if (i2.getInstruction() instanceof GetFieldInstruction && io2.getInstruction() instanceof GetFieldInstruction) {
GetFieldInstruction f1 = (GetFieldInstruction) i2.getInstruction();
GetFieldInstruction f2 = (GetFieldInstruction) io2.getInstruction();
Field fi1 = f1.getMyField(), fi2 = f2.getMyField();
assert MappingExecutorUtil.isMaybeEqual(fi1, fi2);
if (fi1 != null && fi2 != null) {
mappings.map((Instruction) this, fi1, fi2);
}
}
}
use of net.runelite.asm.Field in project runelite by runelite.
the class AdditionInstruction method map.
@Override
default void map(ParallelExecutorMapping mappings, InstructionContext ctx, InstructionContext other) {
/* lhs/rhs of addition instructions are randomally swapped, but
* we still map if each side is recognizable
*
* N.B. since the lhs/rhs of nested iadds can be swapped, and
* the mapper maps the first that it encounters, this can certainly
* attempt to map the wrong instructions even when mapping the correct
* method, so be careful.
*/
StackContext ctx1 = ctx.getPops().get(0);
StackContext ctx2 = ctx.getPops().get(1);
StackContext other1 = other.getPops().get(0);
StackContext other2 = other.getPops().get(1);
InstructionContext rc1 = ctx1.getPushed().resolve(ctx1);
// iaload
InstructionContext rc2 = ctx2.getPushed().resolve(ctx2);
InstructionContext ro1 = other1.getPushed().resolve(other1);
// iaload
InstructionContext ro2 = other2.getPushed().resolve(other2);
// There are a couple static final arrays that are only ever read from 1 or 2 places.. and never written
InstructionContext al1 = findArrayLoad(rc1, rc2);
InstructionContext al2 = findArrayLoad(ro1, ro2);
if (al1 == null || al2 == null) {
return;
}
StackContext array1 = al1.getPops().get(1);
StackContext array2 = al2.getPops().get(1);
InstructionContext field1 = array1.getPushed().resolve(array1);
InstructionContext field2 = array2.getPushed().resolve(array2);
if (!(field1.getInstruction() instanceof GetFieldInstruction) || !(field2.getInstruction() instanceof GetFieldInstruction)) {
return;
}
GetFieldInstruction gf1 = (GetFieldInstruction) field1.getInstruction();
GetFieldInstruction gf2 = (GetFieldInstruction) field2.getInstruction();
Field f1 = gf1.getMyField();
Field f2 = gf2.getMyField();
if (f1 == null || f2 == null || !MappingExecutorUtil.isMaybeEqual(f1, f2)) {
return;
}
mappings.map((Instruction) this, f1, f2);
}
use of net.runelite.asm.Field 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.Field in project runelite by runelite.
the class BufferMethodInjector method inject.
private void inject(ClassFile bufferClass, Field field) {
Field newField = new Field(bufferClass, field.getName(), field.getType());
newField.setAccessFlags(field.getAccessFlags());
newField.setValue(field.getValue());
bufferClass.addField(newField);
}
Aggregations