Search in sources :

Example 6 with LDC

use of net.runelite.asm.attributes.code.InstructionType.LDC in project runelite by runelite.

the class ExprArgOrderTest method test.

@Test
public void test() {
    ClassGroup group = ClassGroupFactory.generateGroup();
    Code code = group.findClass("test").findMethod("func").getCode();
    Instructions ins = code.getInstructions();
    code.setMaxStack(2);
    // vars[0] = 3
    Instruction[] prepareVariables = { new LDC(ins, 3), new IStore(ins, 0) };
    for (Instruction i : prepareVariables) {
        ins.addInstruction(i);
    }
    Instruction[] body = { // 2
    new LDC(ins, 3), new ILoad(ins, 0), new IAdd(ins), new Pop(ins), new VReturn(ins) };
    for (Instruction i : body) {
        ins.addInstruction(i);
    }
    ExprArgOrder exprArgOrder = new ExprArgOrder();
    exprArgOrder.run(group);
    List<Instruction> instructions = ins.getInstructions();
    assertEquals(ILOAD, instructions.get(2).getType());
    assertEquals(LDC, instructions.get(3).getType());
    assertEquals(IADD, instructions.get(4).getType());
}
Also used : IStore(net.runelite.asm.attributes.code.instructions.IStore) ILoad(net.runelite.asm.attributes.code.instructions.ILoad) Instructions(net.runelite.asm.attributes.code.Instructions) LDC(net.runelite.asm.attributes.code.InstructionType.LDC) LDC(net.runelite.asm.attributes.code.instructions.LDC) Instruction(net.runelite.asm.attributes.code.Instruction) Code(net.runelite.asm.attributes.Code) VReturn(net.runelite.asm.attributes.code.instructions.VReturn) Pop(net.runelite.asm.attributes.code.instructions.Pop) ClassGroup(net.runelite.asm.ClassGroup) IAdd(net.runelite.asm.attributes.code.instructions.IAdd) Test(org.junit.Test)

Aggregations

ClassGroup (net.runelite.asm.ClassGroup)6 Code (net.runelite.asm.attributes.Code)6 Instruction (net.runelite.asm.attributes.code.Instruction)6 LDC (net.runelite.asm.attributes.code.InstructionType.LDC)6 Instructions (net.runelite.asm.attributes.code.Instructions)6 IAdd (net.runelite.asm.attributes.code.instructions.IAdd)6 ILoad (net.runelite.asm.attributes.code.instructions.ILoad)6 IStore (net.runelite.asm.attributes.code.instructions.IStore)6 LDC (net.runelite.asm.attributes.code.instructions.LDC)6 VReturn (net.runelite.asm.attributes.code.instructions.VReturn)6 Test (org.junit.Test)6 Pop (net.runelite.asm.attributes.code.instructions.Pop)4 Label (net.runelite.asm.attributes.code.Label)2 IfICmpEq (net.runelite.asm.attributes.code.instructions.IfICmpEq)2 SiPush (net.runelite.asm.attributes.code.instructions.SiPush)2 IAnd (net.runelite.asm.attributes.code.instructions.IAnd)1 IMul (net.runelite.asm.attributes.code.instructions.IMul)1