use of net.runelite.asm.attributes.code.instruction.types.PushConstantInstruction in project runelite by runelite.
the class MixinInjector method setOwnersToTargetClass.
private void setOwnersToTargetClass(ClassFile mixinCf, ClassFile cf, Method method, Map<net.runelite.asm.pool.Field, Field> shadowFields, Map<net.runelite.asm.pool.Method, CopiedMethod> copiedMethods) throws InjectionException {
ListIterator<Instruction> iterator = method.getCode().getInstructions().getInstructions().listIterator();
while (iterator.hasNext()) {
Instruction i = iterator.next();
if (i instanceof InvokeInstruction) {
InvokeInstruction ii = (InvokeInstruction) i;
CopiedMethod copiedMethod = copiedMethods.get(ii.getMethod());
if (copiedMethod != null) {
ii.setMethod(copiedMethod.obMethod.getPoolMethod());
// Pass through garbage value if the method has one
if (copiedMethod.hasGarbageValue) {
int garbageIndex = copiedMethod.obMethod.isStatic() ? copiedMethod.obMethod.getDescriptor().size() - 1 : copiedMethod.obMethod.getDescriptor().size();
iterator.previous();
iterator.add(new ILoad(method.getCode().getInstructions(), garbageIndex));
iterator.next();
}
} else if (ii.getMethod().getClazz().getName().equals(mixinCf.getName())) {
ii.setMethod(new net.runelite.asm.pool.Method(new net.runelite.asm.pool.Class(cf.getName()), ii.getMethod().getName(), ii.getMethod().getType()));
}
} else if (i instanceof FieldInstruction) {
FieldInstruction fi = (FieldInstruction) i;
Field shadowed = shadowFields.get(fi.getField());
if (shadowed != null) {
fi.setField(shadowed.getPoolField());
} else if (fi.getField().getClazz().getName().equals(mixinCf.getName())) {
fi.setField(new net.runelite.asm.pool.Field(new net.runelite.asm.pool.Class(cf.getName()), fi.getField().getName(), fi.getField().getType()));
}
} else if (i instanceof PushConstantInstruction) {
PushConstantInstruction pi = (PushConstantInstruction) i;
if (mixinCf.getPoolClass().equals(pi.getConstant())) {
pi.setConstant(cf.getPoolClass());
}
}
verify(mixinCf, i);
}
}
Aggregations