Search in sources :

Example 1 with AThrow

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

the class IllegalStateExceptions method processOne.

private void processOne(InstructionContext ic) {
    Instruction ins = ic.getInstruction();
    Instructions instructions = ins.getInstructions();
    if (instructions == null)
        return;
    List<Instruction> ilist = instructions.getInstructions();
    JumpingInstruction jumpIns = (JumpingInstruction) ins;
    assert jumpIns.getJumps().size() == 1;
    Instruction to = jumpIns.getJumps().get(0);
    // remove stack of if.
    if (ins instanceof If) {
        ic.removeStack(1);
    }
    ic.removeStack(0);
    int i = ilist.indexOf(ins);
    assert i != -1;
    // remove up to athrow
    while (!(ins instanceof AThrow)) {
        instructions.remove(ins);
        // don't need to ++i because
        ins = ilist.get(i);
    }
    // remove athrow
    instructions.remove(ins);
    // insert goto
    assert ilist.contains(to);
    Goto g = new Goto(instructions, instructions.createLabelFor(to));
    ilist.add(i, g);
    ++count;
}
Also used : JumpingInstruction(net.runelite.asm.attributes.code.instruction.types.JumpingInstruction) Goto(net.runelite.asm.attributes.code.instructions.Goto) Instructions(net.runelite.asm.attributes.code.Instructions) ComparisonInstruction(net.runelite.asm.attributes.code.instruction.types.ComparisonInstruction) JumpingInstruction(net.runelite.asm.attributes.code.instruction.types.JumpingInstruction) Instruction(net.runelite.asm.attributes.code.Instruction) If(net.runelite.asm.attributes.code.instructions.If) AThrow(net.runelite.asm.attributes.code.instructions.AThrow)

Aggregations

Instruction (net.runelite.asm.attributes.code.Instruction)1 Instructions (net.runelite.asm.attributes.code.Instructions)1 ComparisonInstruction (net.runelite.asm.attributes.code.instruction.types.ComparisonInstruction)1 JumpingInstruction (net.runelite.asm.attributes.code.instruction.types.JumpingInstruction)1 AThrow (net.runelite.asm.attributes.code.instructions.AThrow)1 Goto (net.runelite.asm.attributes.code.instructions.Goto)1 If (net.runelite.asm.attributes.code.instructions.If)1