Search in sources :

Example 6 with InstructionContext

use of net.runelite.asm.execution.InstructionContext in project runelite by runelite.

the class Dup2 method execute.

@Override
public InstructionContext execute(Frame frame) {
    InstructionContext ins = new InstructionContext(this, frame);
    Stack stack = frame.getStack();
    StackContext one = stack.pop();
    StackContext two = null;
    if (one.getType().getSize() == 1)
        two = stack.pop();
    ins.pop(one);
    if (two != null)
        ins.pop(two);
    if (two != null) {
        StackContext ctx = new StackContext(ins, two.getType(), two.getValue());
        stack.push(ctx);
        ins.push(ctx);
    }
    StackContext ctx = new StackContext(ins, one.getType(), one.getValue());
    stack.push(one);
    ins.push(ctx);
    if (two != null) {
        ctx = new StackContext(ins, two.getType(), two.getValue());
        stack.push(ctx);
        ins.push(ctx);
    }
    ctx = new StackContext(ins, one.getType(), one.getValue());
    stack.push(one);
    ins.push(ctx);
    return ins;
}
Also used : InstructionContext(net.runelite.asm.execution.InstructionContext) StackContext(net.runelite.asm.execution.StackContext) Stack(net.runelite.asm.execution.Stack)

Example 7 with InstructionContext

use of net.runelite.asm.execution.InstructionContext in project runelite by runelite.

the class Dup2_X2 method execute.

@Override
public InstructionContext execute(Frame frame) {
    InstructionContext ins = new InstructionContext(this, frame);
    Stack stack = frame.getStack();
    StackContext one = stack.pop();
    StackContext two = null;
    if (one.getType().getSize() == 1)
        two = stack.pop();
    StackContext three = stack.pop();
    StackContext four = null;
    if (one.getType().getSize() == 1)
        four = stack.pop();
    ins.pop(one);
    if (two != null)
        ins.pop(two);
    ins.pop(three);
    if (four != null)
        ins.pop(four);
    if (two != null) {
        StackContext ctx = new StackContext(ins, two.getType(), two.getValue());
        stack.push(ctx);
        ins.push(ctx);
    }
    StackContext ctx = new StackContext(ins, one.getType(), one.getValue());
    stack.push(one);
    ins.push(ctx);
    if (four != null) {
        ctx = new StackContext(ins, four.getType(), four.getValue());
        stack.push(ctx);
        ins.push(ctx);
    }
    ctx = new StackContext(ins, three.getType(), three.getValue());
    stack.push(one);
    ins.push(ctx);
    if (two != null) {
        ctx = new StackContext(ins, two.getType(), two.getValue());
        stack.push(ctx);
        ins.push(ctx);
    }
    ctx = new StackContext(ins, one.getType(), one.getValue());
    stack.push(one);
    ins.push(ctx);
    return ins;
}
Also used : InstructionContext(net.runelite.asm.execution.InstructionContext) StackContext(net.runelite.asm.execution.StackContext) Stack(net.runelite.asm.execution.Stack)

Example 8 with InstructionContext

use of net.runelite.asm.execution.InstructionContext in project runelite by runelite.

the class Dup_X2 method getOriginal.

@Override
public StackContext getOriginal(StackContext sctx) {
    // 3 2 1 -> 1 3 2 1
    InstructionContext ctx = sctx.getPushed();
    assert ctx.getInstruction() == this;
    assert ctx.getPushes().contains(sctx);
    int pushedIndex = ctx.getPushes().indexOf(sctx);
    int poppedIndex;
    switch(pushedIndex) {
        case 0:
        case 3:
            poppedIndex = 0;
            break;
        case 1:
            poppedIndex = 2;
            break;
        case 2:
            poppedIndex = 1;
            break;
        default:
            throw new IllegalStateException();
    }
    return ctx.getPops().get(poppedIndex);
}
Also used : InstructionContext(net.runelite.asm.execution.InstructionContext)

Example 9 with InstructionContext

use of net.runelite.asm.execution.InstructionContext in project runelite by runelite.

the class F2I method execute.

@Override
public InstructionContext execute(Frame frame) {
    InstructionContext ins = new InstructionContext(this, frame);
    Stack stack = frame.getStack();
    StackContext object = stack.pop();
    ins.pop(object);
    StackContext ctx = new StackContext(ins, Type.INT, object.getValue().cast(int.class));
    stack.push(ctx);
    ins.push(ctx);
    return ins;
}
Also used : InstructionContext(net.runelite.asm.execution.InstructionContext) StackContext(net.runelite.asm.execution.StackContext) Stack(net.runelite.asm.execution.Stack)

Example 10 with InstructionContext

use of net.runelite.asm.execution.InstructionContext in project runelite by runelite.

the class FALoad method execute.

@Override
public InstructionContext execute(Frame frame) {
    InstructionContext ins = new InstructionContext(this, frame);
    Stack stack = frame.getStack();
    StackContext index = stack.pop();
    StackContext array = stack.pop();
    ins.pop(index, array);
    StackContext ctx = new StackContext(ins, Type.FLOAT, array.getValue().arrayGet(index.getValue()).cast(float.class));
    stack.push(ctx);
    ins.push(ctx);
    return ins;
}
Also used : InstructionContext(net.runelite.asm.execution.InstructionContext) StackContext(net.runelite.asm.execution.StackContext) Stack(net.runelite.asm.execution.Stack)

Aggregations

InstructionContext (net.runelite.asm.execution.InstructionContext)179 StackContext (net.runelite.asm.execution.StackContext)153 Stack (net.runelite.asm.execution.Stack)120 Value (net.runelite.asm.execution.Value)48 Field (net.runelite.asm.Field)18 Instruction (net.runelite.asm.attributes.code.Instruction)18 Variables (net.runelite.asm.execution.Variables)16 GetFieldInstruction (net.runelite.asm.attributes.code.instruction.types.GetFieldInstruction)15 VariableContext (net.runelite.asm.execution.VariableContext)14 Instructions (net.runelite.asm.attributes.code.Instructions)12 Frame (net.runelite.asm.execution.Frame)12 PushConstantInstruction (net.runelite.asm.attributes.code.instruction.types.PushConstantInstruction)11 Execution (net.runelite.asm.execution.Execution)11 LVTInstruction (net.runelite.asm.attributes.code.instruction.types.LVTInstruction)9 InvokeInstruction (net.runelite.asm.attributes.code.instruction.types.InvokeInstruction)8 IMul (net.runelite.asm.attributes.code.instructions.IMul)7 ClassFile (net.runelite.asm.ClassFile)6 Method (net.runelite.asm.Method)6 Label (net.runelite.asm.attributes.code.Label)6 DupInstruction (net.runelite.asm.attributes.code.instruction.types.DupInstruction)6