Search in sources :

Example 31 with Value

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

the class LUShR 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()) {
        long l2 = (long) two.getValue().as(long.class), l1 = (long) two.getValue().as(long.class);
        result = new Value(l1 >>> l2);
    }
    StackContext ctx = new StackContext(ins, Type.LONG, 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)

Example 32 with Value

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

the class LDiv 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()) {
        long l2 = (long) two.getValue().getValue(), l1 = (long) one.getValue().getValue();
        if (l2 != 0L)
            result = new Value(l1 / l2);
    }
    StackContext ctx = new StackContext(ins, Type.LONG, 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)

Example 33 with Value

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

the class LNeg method execute.

@Override
public InstructionContext execute(Frame frame) {
    InstructionContext ins = new InstructionContext(this, frame);
    Stack stack = frame.getStack();
    StackContext value = stack.pop();
    ins.pop(value);
    Value result = Value.UNKNOWN;
    if (!value.getValue().isUnknownOrNull()) {
        long l = (long) value.getValue().getValue();
        result = new Value(-l);
    }
    StackContext ctx = new StackContext(ins, Type.LONG, 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)

Example 34 with Value

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

the class LShR 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()) {
        long l2 = (long) two.getValue().as(long.class), l1 = (long) two.getValue().as(long.class);
        result = new Value(l1 >> l2);
    }
    StackContext ctx = new StackContext(ins, Type.LONG, 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)

Example 35 with Value

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

the class IfICmpEqTest method testIsSame.

@Test
public void testIsSame() {
    Instructions ins = mock(Instructions.class);
    Frame frame = mock(Frame.class);
    Stack stack = new Stack(42);
    Variables variables = new Variables(42);
    when(frame.getStack()).thenReturn(stack);
    when(frame.getVariables()).thenReturn(variables);
    IfICmpEq ifeq = new IfICmpEq(ins, InstructionType.IF_ICMPEQ);
    InstructionContext ifeqCtx = new InstructionContext(ifeq, frame);
    ifeqCtx.pop(new StackContext(getConstantCtx(ins, 1), INT, new Value(1)));
    ifeqCtx.pop(new StackContext(getConstantCtx(ins, 1), INT, new Value(1)));
    IfNe ifne = new IfNe(ins, InstructionType.IFNE);
    InstructionContext ifneCtx = new InstructionContext(ifne, frame);
    ifneCtx.pop(new StackContext(getConstantCtx(ins, 42), INT, new Value(42)));
    assertTrue(ifeq.isSame(ifeqCtx, ifneCtx));
}
Also used : Variables(net.runelite.asm.execution.Variables) InstructionContext(net.runelite.asm.execution.InstructionContext) Frame(net.runelite.asm.execution.Frame) StackContext(net.runelite.asm.execution.StackContext) Value(net.runelite.asm.execution.Value) Instructions(net.runelite.asm.attributes.code.Instructions) Stack(net.runelite.asm.execution.Stack) Test(org.junit.Test)

Aggregations

InstructionContext (net.runelite.asm.execution.InstructionContext)48 Value (net.runelite.asm.execution.Value)48 Stack (net.runelite.asm.execution.Stack)47 StackContext (net.runelite.asm.execution.StackContext)47 Variables (net.runelite.asm.execution.Variables)3 Instructions (net.runelite.asm.attributes.code.Instructions)2 Frame (net.runelite.asm.execution.Frame)2 VariableContext (net.runelite.asm.execution.VariableContext)2 Test (org.junit.Test)2 Instruction (net.runelite.asm.attributes.code.Instruction)1 ParallelExecutorMapping (net.runelite.deob.deobfuscators.mapping.ParallelExecutorMapping)1