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;
}
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;
}
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;
}
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;
}
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));
}
Aggregations