use of com.googlecode.dex2jar.ir.expr.Local in project dex2jar by pxb1988.
the class BaseTransformerTest method addLocal.
public Local addLocal(String name) {
Local local = Exprs.nLocal(name);
method.locals.add(local);
return local;
}
use of com.googlecode.dex2jar.ir.expr.Local in project dex2jar by pxb1988.
the class ConstTransformerTest method test04.
@Test
public void test04() {
IrMethod jm = new IrMethod();
Local a = nLocal("a");
Local b = nLocal("b");
Local p = nLocal("p");
jm.locals.add(a);
jm.locals.add(b);
jm.locals.add(p);
jm.stmts.add(nAssign(a, nString(new String("a String"))));
jm.stmts.add(nAssign(b, nString(new String("a String"))));
jm.stmts.add(nAssign(p, Exprs.nPhi(a, b)));
UnopStmt retStmt = nReturn(p);
jm.stmts.add(retStmt);
new ConstTransformer().transform(jm);
Assert.assertTrue(jm.locals.size() == 3);
Assert.assertTrue(jm.stmts.getSize() == 4);
Assert.assertEquals(VT.CONSTANT, retStmt.op.vt);
}
use of com.googlecode.dex2jar.ir.expr.Local in project dex2jar by pxb1988.
the class UnSSATransformerTransformerTest method test04OneInPhi.
@Test
public void test04OneInPhi() {
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")));
Stmt j = addStmt(nIf(niGt(nInt(100), nInt(0)), L1));
Stmt s2 = addStmt(nAssign(b, nString("456")));
addStmt(L1);
attachPhi(L1, nAssign(phi, nPhi(a)));
addStmt(nReturn(phi));
transform();
Assert.assertTrue("p=a should inserted", j.getPre() != s1);
}
use of com.googlecode.dex2jar.ir.expr.Local 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.expr.Local in project dex2jar by pxb1988.
the class ConstTransformerTest method test00.
@Test
public void test00() {
IrMethod jm = new IrMethod();
Local a = nLocal("a");
jm.locals.add(a);
jm.stmts.add(nAssign(a, nString("a String")));
UnopStmt retStmt = nReturn(a);
jm.stmts.add(retStmt);
new ConstTransformer().transform(jm);
Assert.assertTrue(jm.locals.size() == 1);
Assert.assertTrue(jm.stmts.getSize() == 2);
Assert.assertEquals("a String", ((Constant) retStmt.op.trim()).value);
}
Aggregations