another test

This commit is contained in:
Adam
2016-01-17 17:00:43 -05:00
parent a82a9ba4b9
commit c632beac50
2 changed files with 39 additions and 2 deletions

View File

@@ -2,6 +2,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.PushConstantInstruction;
import net.runelite.deob.execution.InstructionContext;
import net.runelite.deob.execution.StackContext;
public class IfICmpNe extends If
{
@@ -10,4 +13,36 @@ public class IfICmpNe extends If
super(instructions, type, pc);
}
private static boolean isZero(StackContext s)
{
if (s.getPushed().getInstruction() instanceof PushConstantInstruction)
{
PushConstantInstruction pc = (PushConstantInstruction) s.getPushed().getInstruction();
Object o = pc.getConstant().getObject();
if (o instanceof Integer && (int) o == 0)
return true;
}
return false;
}
@Override
public boolean isSame(InstructionContext thisIc, InstructionContext otherIc)
{
if (super.isSame(thisIc, otherIc))
return true;
// check for other being ifne and this has a constant 0
if (otherIc.getInstruction() instanceof IfNe)
{
StackContext s1 = thisIc.getPops().get(0),
s2 = thisIc.getPops().get(1);
if (isZero(s1) || isZero(s2))
return true;
}
return false;
}
}

View File

@@ -22,6 +22,8 @@ public class MapStaticTest
{ "client.method585", "class44.method930" },
{ "class222.method4086", "class222.method3957" },
{ "class40.method851", "class40.method803" },
{ "class55.method1187", "class55.method1140" },
{ "class107.method2427", "class107.method2344" },
};
// @Test
@@ -66,8 +68,8 @@ public class MapStaticTest
ClassGroup group1 = JarUtil.loadJar(new File("d:/rs/07/adamin1.jar"));
ClassGroup group2 = JarUtil.loadJar(new File("d:/rs/07/adamin2.jar"));
Method m1 = group1.findClass("class55").findMethod("method1187");
Method m2 = group2.findClass("class55").findMethod("method1140");
Method m1 = group1.findClass("class107").findMethod("method2427");
Method m2 = group2.findClass("class107").findMethod("method2344");
ParallelExecutorMapping mappings = MappingExecutorUtil.map(m1, m2);
}