use of com.googlecode.dex2jar.ir.stmt.Stmt in project dex2jar by pxb1988.
the class DeadCodeTrnasformerTest method test09DeadCode.
@Test
public void test09DeadCode() {
Stmt ret = addStmt(Stmts.nReturnVoid());
Stmt lb = addStmt(newLabel());
addStmt(Stmts.nReturnVoid());
transform();
Assert.assertSame(ret, method.stmts.getFirst());
Assert.assertSame(ret, method.stmts.getLast());
}
use of com.googlecode.dex2jar.ir.stmt.Stmt in project dex2jar by pxb1988.
the class RemoveConstantFromSSATest method t005PhiValueEqual.
@Test
public void t005PhiValueEqual() {
Local a0 = addLocal("a0");
Local a1 = addLocal("a1");
Local ax = addLocal("aX");
LabelStmt L1 = newLabel();
LabelStmt L2 = newLabel();
addStmt(nIf(niGt(nInt(100), nInt(0)), L1));
addStmt(nAssign(a0, nString("123")));
addStmt(nGoto(L2));
addStmt(L1);
addStmt(nAssign(a1, nString("123")));
addStmt(L2);
attachPhi(L2, nAssign(ax, Exprs.nPhi(a0, a1)));
Stmt ret = addStmt(nReturn(ax));
transform();
Assert.assertTrue("should return '123'", ret.getOp().vt == Value.VT.CONSTANT);
}
use of com.googlecode.dex2jar.ir.stmt.Stmt in project dex2jar by pxb1988.
the class RemoveConstantFromSSATest method t001.
@Test
public void t001() {
Local a = addLocal("a");
Local b = addLocal("b");
Local c1 = addLocal("c1");
Local c2 = addLocal("c2");
Local cphi = addLocal("cphi");
LabelStmt L1 = newLabel();
LabelStmt L2 = newLabel();
Stmt sa = addStmt(nAssign(a, nInt(5)));
Stmt sb = addStmt(nAssign(b, nInt(6)));
addStmt(nIf(niGt(a, b), L1));
addStmt(nAssign(c1, a));
addStmt(nGoto(L2));
addStmt(L1);
addStmt(nAssign(c2, b));
addStmt(L2);
attachPhi(L2, nAssign(cphi, Exprs.nPhi(c1, c2)));
addStmt(nReturn(cphi));
transform();
Assert.assertFalse("SA should remove from method", method.stmts.contains(sa));
Assert.assertFalse("SB should remove from method", method.stmts.contains(sb));
}
use of com.googlecode.dex2jar.ir.stmt.Stmt in project dex2jar by pxb1988.
the class RemoveLocalFromSSATest method t001.
@Test
public void t001() {
Local a = addLocal("a");
Local b = addLocal("b");
Local c = addLocal("c");
Stmt sa = addStmt(nAssign(a, nInt(0)));
addStmt(nAssign(b, a));
addStmt(nAssign(c, b));
Stmt sb = addStmt(nReturn(c));
transform();
Assert.assertEquals(sa.getOp1(), sb.getOp());
Assert.assertEquals("1 local should left", 1, locals.size());
}
use of com.googlecode.dex2jar.ir.stmt.Stmt in project dex2jar by pxb1988.
the class UnSSATransformerTransformerTest method test00Base.
@Test
public void test00Base() {
initMethod(true, "V");
Local a = addLocal("a");
Local b = addLocal("b");
Local phi = addLocal("p");
LabelStmt L1 = newLabel();
Stmt s1 = addStmt(nAssign(a, nString("123")));
addStmt(nIf(niGt(nInt(100), nInt(0)), L1));
Stmt s2 = addStmt(nAssign(b, nString("456")));
addStmt(L1);
attachPhi(L1, nAssign(phi, nPhi(a, b)));
addStmt(nReturn(phi));
transform();
Assert.assertEquals("insert assign after s1", ST.ASSIGN, s1.getNext().st);
Assert.assertEquals("insert assign after s1", ST.ASSIGN, s2.getNext().st);
// Assert.assertEquals("local should index to 0", 0, b._ls_index);
}
Aggregations