Search in sources :

Example 16 with Local

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;
}
Also used : Local(com.googlecode.dex2jar.ir.expr.Local)

Example 17 with 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);
}
Also used : ConstTransformer(com.googlecode.dex2jar.ir.ts.ConstTransformer) Exprs.nLocal(com.googlecode.dex2jar.ir.expr.Exprs.nLocal) Local(com.googlecode.dex2jar.ir.expr.Local) Exprs.nString(com.googlecode.dex2jar.ir.expr.Exprs.nString) IrMethod(com.googlecode.dex2jar.ir.IrMethod) UnopStmt(com.googlecode.dex2jar.ir.stmt.UnopStmt) Test(org.junit.Test)

Example 18 with Local

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);
}
Also used : LabelStmt(com.googlecode.dex2jar.ir.stmt.LabelStmt) Local(com.googlecode.dex2jar.ir.expr.Local) LabelStmt(com.googlecode.dex2jar.ir.stmt.LabelStmt) Stmt(com.googlecode.dex2jar.ir.stmt.Stmt) Test(org.junit.Test)

Example 19 with Local

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]);
}
Also used : LabelStmt(com.googlecode.dex2jar.ir.stmt.LabelStmt) Local(com.googlecode.dex2jar.ir.expr.Local) LabelStmt(com.googlecode.dex2jar.ir.stmt.LabelStmt) Stmt(com.googlecode.dex2jar.ir.stmt.Stmt) Test(org.junit.Test)

Example 20 with Local

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);
}
Also used : ConstTransformer(com.googlecode.dex2jar.ir.ts.ConstTransformer) Exprs.nLocal(com.googlecode.dex2jar.ir.expr.Exprs.nLocal) Local(com.googlecode.dex2jar.ir.expr.Local) IrMethod(com.googlecode.dex2jar.ir.IrMethod) UnopStmt(com.googlecode.dex2jar.ir.stmt.UnopStmt) Test(org.junit.Test)

Aggregations

Local (com.googlecode.dex2jar.ir.expr.Local)86 Test (org.junit.Test)44 LabelStmt (com.googlecode.dex2jar.ir.stmt.LabelStmt)28 Stmt (com.googlecode.dex2jar.ir.stmt.Stmt)23 Value (com.googlecode.dex2jar.ir.expr.Value)19 AssignStmt (com.googlecode.dex2jar.ir.stmt.AssignStmt)15 ArrayList (java.util.ArrayList)8 IrMethod (com.googlecode.dex2jar.ir.IrMethod)6 Exprs.nLocal (com.googlecode.dex2jar.ir.expr.Exprs.nLocal)6 UnopStmt (com.googlecode.dex2jar.ir.stmt.UnopStmt)6 JumpStmt (com.googlecode.dex2jar.ir.stmt.JumpStmt)5 ConstTransformer (com.googlecode.dex2jar.ir.ts.ConstTransformer)5 Exprs.nString (com.googlecode.dex2jar.ir.expr.Exprs.nString)4 StmtList (com.googlecode.dex2jar.ir.stmt.StmtList)4 Trap (com.googlecode.dex2jar.ir.Trap)3 Exprs.nArrayValue (com.googlecode.dex2jar.ir.expr.Exprs.nArrayValue)3 AnalyzeValue (com.googlecode.dex2jar.ir.ts.an.AnalyzeValue)3 List (java.util.List)3 DexLabel (com.googlecode.d2j.DexLabel)2 Op (com.googlecode.d2j.reader.Op)2