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