Search in sources :

Example 1 with IfNull

use of net.runelite.asm.attributes.code.instructions.IfNull in project runelite by runelite.

the class ClientErrorTransformer method transform.

private void transform(Method m) {
    if (!m.isStatic() || m.getDescriptor().size() != 2 || !m.getDescriptor().getTypeOfArg(0).equals(Type.STRING) || !m.getDescriptor().getTypeOfArg(1).equals(Type.THROWABLE))
        return;
    Code code = m.getCode();
    Instructions ins = code.getInstructions();
    /*
			Makes it so the old code in this method is logically dead,
			letting the mapper map it but making it so it's never executed.
		 */
    // load throwable
    Instruction aload0 = new ALoad(ins, 1);
    IfNull ifNull = new IfNull(ins, InstructionType.IFNULL);
    ifNull.setTo(ins.createLabelFor(ins.getInstructions().get(0)));
    // load throwable
    Instruction aload1 = new ALoad(ins, 1);
    InvokeVirtual printStackTrace = new InvokeVirtual(ins, new net.runelite.asm.pool.Method(new net.runelite.asm.pool.Class("java/lang/Throwable"), "printStackTrace", new Signature("()V")));
    Instruction ret = new VReturn(ins);
    ins.addInstruction(0, aload0);
    ins.addInstruction(1, ifNull);
    ins.addInstruction(2, aload1);
    ins.addInstruction(3, printStackTrace);
    ins.addInstruction(4, ret);
    done = true;
}
Also used : Instructions(net.runelite.asm.attributes.code.Instructions) Instruction(net.runelite.asm.attributes.code.Instruction) Code(net.runelite.asm.attributes.Code) VReturn(net.runelite.asm.attributes.code.instructions.VReturn) IfNull(net.runelite.asm.attributes.code.instructions.IfNull) InvokeVirtual(net.runelite.asm.attributes.code.instructions.InvokeVirtual) Signature(net.runelite.asm.signature.Signature) ALoad(net.runelite.asm.attributes.code.instructions.ALoad)

Aggregations

Code (net.runelite.asm.attributes.Code)1 Instruction (net.runelite.asm.attributes.code.Instruction)1 Instructions (net.runelite.asm.attributes.code.Instructions)1 ALoad (net.runelite.asm.attributes.code.instructions.ALoad)1 IfNull (net.runelite.asm.attributes.code.instructions.IfNull)1 InvokeVirtual (net.runelite.asm.attributes.code.instructions.InvokeVirtual)1 VReturn (net.runelite.asm.attributes.code.instructions.VReturn)1 Signature (net.runelite.asm.signature.Signature)1