use of net.runelite.asm.attributes.code.instruction.types.LVTInstruction in project runelite by runelite.
the class ExprArgOrder method canRemove.
private boolean canRemove(MethodContext mctx, Instructions ins, Instruction i) {
Set<InstructionContext> ctxs = new HashSet<>(mctx.getInstructonContexts(i));
if (!alwaysPoppedBySameInstruction(ctxs, i) || !alwaysPopsFromSameInstructions(ctxs, i)) {
return false;
}
if (i instanceof InvokeInstruction) {
// func1() + func2() vs func2() + func1() is not the same thing
return false;
}
int idx = ins.getInstructions().indexOf(i);
if (idx == -1) {
return false;
}
for (InstructionContext ictx : ctxs) {
for (StackContext sctx : ictx.getPops()) {
Instruction pushed = sctx.getPushed().getInstruction();
int idx2 = ins.getInstructions().indexOf(pushed);
if (idx2 == -1) {
return false;
}
assert idx > idx2;
// instructions, we can't move them
for (int j = idx2; j <= idx; ++j) {
Instruction i2 = ins.getInstructions().get(j);
if (i2 instanceof LVTInstruction) {
if (((LVTInstruction) i2).store()) {
return false;
}
}
if (i2 instanceof IInc) {
return false;
}
}
if (!canRemove(mctx, ins, pushed)) {
return false;
}
}
}
return true;
}
Aggregations