Search in sources :

Example 1 with InstructionContext

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

the class Dup2_X1 method getOtherBranch.

@Override
public StackContext getOtherBranch(StackContext sctx) {
    InstructionContext ctx = sctx.getPushed();
    assert ctx.getInstruction() == this;
    assert ctx.getPushes().contains(sctx);
    int idx = ctx.getPushes().indexOf(sctx);
    // 2 1 0 -> 1 0 2 1 0 OR 1 0 -> 0 1 0
    int other;
    if (ctx.getPushes().size() == 5) {
        switch(idx) {
            case 0:
                other = 3;
                break;
            case 1:
                other = 4;
                break;
            case 3:
                other = 0;
                break;
            case 4:
                other = 1;
                break;
            default:
                return null;
        }
    } else if (ctx.getPushes().size() == 3) {
        switch(idx) {
            case 0:
                other = 2;
                break;
            case 2:
                other = 0;
                break;
            default:
                return null;
        }
    } else {
        throw new IllegalStateException();
    }
    return ctx.getPushes().get(other);
}
Also used : InstructionContext(net.runelite.asm.execution.InstructionContext)

Example 2 with InstructionContext

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

the class Dup_X1 method getOriginal.

@Override
public StackContext getOriginal(StackContext sctx) {
    // ctx = stack pushed by this instruction, return stack popped by this instruction
    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 2:
            poppedIndex = 0;
            break;
        case 1:
            poppedIndex = 1;
            break;
        default:
            throw new IllegalStateException();
    }
    // get popped ctx
    return ctx.getPops().get(poppedIndex);
}
Also used : InstructionContext(net.runelite.asm.execution.InstructionContext)

Example 3 with InstructionContext

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

the class Dup_X1 method execute.

@Override
public InstructionContext execute(Frame frame) {
    InstructionContext ins = new InstructionContext(this, frame);
    Stack stack = frame.getStack();
    StackContext one = stack.pop();
    StackContext two = stack.pop();
    ins.pop(one, two);
    StackContext ctx = new StackContext(ins, one.getType(), one.getValue());
    stack.push(ctx);
    ins.push(ctx);
    ctx = new StackContext(ins, two.getType(), two.getValue());
    stack.push(ctx);
    ins.push(ctx);
    ctx = new StackContext(ins, one.getType(), one.getValue());
    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 4 with InstructionContext

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

the class F2D 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.DOUBLE, object.getValue().cast(double.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 5 with InstructionContext

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

the class DSub method execute.

@Override
public InstructionContext execute(Frame frame) {
    InstructionContext ins = new InstructionContext(this, frame);
    Stack stack = frame.getStack();
    StackContext two = stack.pop();
    StackContext one = stack.pop();
    ins.pop(two, one);
    Value result = Value.UNKNOWN;
    if (!two.getValue().isUnknownOrNull() && !one.getValue().isUnknownOrNull()) {
        double d2 = (double) two.getValue().getValue(), d1 = (double) one.getValue().getValue();
        result = new Value(d1 - d2);
    }
    StackContext ctx = new StackContext(ins, Type.DOUBLE, result);
    stack.push(ctx);
    ins.push(ctx);
    return ins;
}
Also used : InstructionContext(net.runelite.asm.execution.InstructionContext) StackContext(net.runelite.asm.execution.StackContext) Value(net.runelite.asm.execution.Value) 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