use of com.googlecode.dex2jar.ir.stmt.LabelStmt in project dex2jar by pxb1988.
the class ZeroTransformerTest method t001.
@Test
public void t001() {
Local a = addLocal("a");
Local c = addLocal("c");
Local p = addLocal("p");
Local q = addLocal("q");
addStmt(nAssign(a, nInt(0)));
addStmt(nAssign(c, nInvokeStatic(new Value[0], "La;", "a", new String[0], "I")));
LabelStmt L1 = newLabel();
addStmt(L1);
Stmt sa = attachPhi(L1, nAssign(q, nPhi(a, c)));
Stmt sb = attachPhi(L1, nAssign(p, nPhi(a, c)));
addStmt(nReturn(p));
transform();
Assert.assertNotEquals("a is split to 2 local", sb.getOp2().getOps()[0], sa.getOp2().getOps()[0]);
Assert.assertEquals("c is keep same", sb.getOp2().getOps()[1], sa.getOp2().getOps()[1]);
}
use of com.googlecode.dex2jar.ir.stmt.LabelStmt 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.LabelStmt in project dex2jar by pxb1988.
the class RemoveConstantFromSSATest method t004.
@Test
public void t004() {
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, nNull()));
addStmt(L2);
attachPhi(L2, nAssign(ax, Exprs.nPhi(a0, a1)));
addStmt(nReturn(ax));
transform();
Assert.assertEquals("all local should kept", 3, locals.size());
}
use of com.googlecode.dex2jar.ir.stmt.LabelStmt 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.LabelStmt in project dex2jar by pxb1988.
the class StmtListTest method toStringTest.
@Test
public void toStringTest() {
StmtList list = new StmtList();
Local a = nLocal("this");
Local b = nLocal("b");
Local c = nLocal("c");
Local d = nLocal("d");
LabelStmt L1 = Stmts.nLabel();
list.add(Stmts.nIdentity(a, nThisRef("La/Some;")));
list.add(Stmts.nIdentity(b, nParameterRef("I", 0)));
list.add(Stmts.nIdentity(c, nParameterRef("J", 1)));
list.add(Stmts.nIdentity(d, nParameterRef("F", 2)));
list.add(Stmts.nIf(nGt(b, nInt(0), "I"), L1));
list.add(Stmts.nAssign(c, nCast(d, "F", "J")));
list.add(L1);
list.toString();
}
Aggregations