Need to split aeq from ieq

This commit is contained in:
Adam
2016-01-03 20:33:57 -05:00
parent eef43dd913
commit 02a4041306
3 changed files with 52 additions and 1 deletions

View File

@@ -105,7 +105,8 @@ public abstract class If0 extends Instruction implements JumpingInstruction, Com
// we can map these if they are getfield instructions?
assert ctx.getInstruction().getClass().equals(other.getInstruction().getClass());
// this is already checked before this
//assert ctx.getInstruction().getClass().equals(other.getInstruction().getClass());
Frame branch1 = ctx.getBranches().get(0),
branch2 = other.getBranches().get(0);

View File

@@ -3,7 +3,9 @@ package net.runelite.deob.attributes.code.instructions;
import net.runelite.deob.attributes.code.InstructionType;
import net.runelite.deob.attributes.code.Instructions;
import net.runelite.deob.attributes.code.instruction.types.MappableInstruction;
import net.runelite.deob.attributes.code.instruction.types.PushConstantInstruction;
import net.runelite.deob.execution.InstructionContext;
import net.runelite.deob.execution.StackContext;
public class IfNe extends If0
{
@@ -21,6 +23,29 @@ public class IfNe extends If0
if (otherIc.getInstruction() instanceof IfCmpNe)
{
// check for one side being 0
StackContext s1 = otherIc.getPops().get(0),
s2 = otherIc.getPops().get(1);
if (s1.getPushed().getInstruction() instanceof PushConstantInstruction)
{
PushConstantInstruction pci = (PushConstantInstruction) s1.getPushed().getInstruction();
Object o = pci.getConstant().getObject();
if (o.equals(0))
{
return true;
}
}
if (s2.getPushed().getInstruction() instanceof PushConstantInstruction)
{
PushConstantInstruction pci = (PushConstantInstruction) s2.getPushed().getInstruction();
Object o = pci.getConstant().getObject();
if (o.equals(0))
{
return true;
}
}
}
return false;

View File

@@ -2,6 +2,8 @@ package net.runelite.deob.attributes.code.instructions;
import net.runelite.deob.attributes.code.InstructionType;
import net.runelite.deob.attributes.code.Instructions;
import net.runelite.deob.execution.InstructionContext;
import net.runelite.deob.execution.StackContext;
public class IfNull extends If0
{
@@ -10,4 +12,27 @@ public class IfNull extends If0
super(instructions, type, pc);
}
@Override
public boolean isSame(InstructionContext thisIc, InstructionContext otherIc)
{
if (super.isSame(thisIc, otherIc))
return true;
if (otherIc.getInstruction() instanceof IfCmpEq)
{
StackContext s1 = otherIc.getPops().get(0),
s2 = otherIc.getPops().get(1);
if (s1.getPushed().getInstruction() instanceof AConstNull)
{
return true;
}
if (s2.getPushed().getInstruction() instanceof AConstNull)
{
return true;
}
}
return false;
}
}