Search in sources :

Example 26 with Local

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

Example 27 with Local

use of com.googlecode.dex2jar.ir.expr.Local in project dex2jar by pxb1988.

the class SSATransformerTest method test01HugeLocalStmt.

/**
     * Test for huge local and stmt size
     */
@Test
public void test01HugeLocalStmt() {
    for (int i = 0; i < 2000; i++) {
        Local b = addLocal("a");
        addStmt(nAssign(b, nString("123")));
    }
    Local b = addLocal("a");
    for (int i = 0; i < 20000; i++) {
        addStmt(nAssign(b, nString("123")));
    }
    addStmt(nReturn(b));
    transform();
}
Also used : Local(com.googlecode.dex2jar.ir.expr.Local) Test(org.junit.Test)

Example 28 with Local

use of com.googlecode.dex2jar.ir.expr.Local in project dex2jar by pxb1988.

the class SSATransformerTest method test03NotInsertPhiInLoop.

@Test
public void test03NotInsertPhiInLoop() {
    Local b = addLocal("a");
    addStmt(nAssign(b, nString("123")));
    LabelStmt L1 = newLabel();
    LabelStmt L2 = newLabel();
    addStmt(L1);
    addStmt(Stmts.nIf(Exprs.niEq(nInt(0), nInt(9)), L2));
    addStmt(Stmts.nNop());
    addStmt(Stmts.nIf(Exprs.niEq(nInt(0), nInt(9)), L1));
    addStmt(L2);
    addStmt(nReturn(b));
    transform();
    Assert.assertEquals(1, method.locals.size());
}
Also used : Local(com.googlecode.dex2jar.ir.expr.Local) Test(org.junit.Test)

Example 29 with Local

use of com.googlecode.dex2jar.ir.expr.Local in project dex2jar by pxb1988.

the class SSATransformerTest method test04NotInsertPhiLoop2.

@Test
public void test04NotInsertPhiLoop2() {
    Local b = addLocal("a");
    addStmt(nAssign(b, nString("123")));
    LabelStmt L1 = newLabel();
    LabelStmt L2 = newLabel();
    addStmt(L1);
    addStmt(Stmts.nIf(Exprs.niEq(nInt(0), nInt(9)), L2));
    addStmt(Stmts.nNop());
    addStmt(Stmts.nIf(Exprs.niEq(nInt(0), nInt(9)), L1));
    addStmt(Stmts.nNop());
    addStmt(L2);
    addStmt(Stmts.nIf(Exprs.niEq(nInt(0), nInt(9)), L1));
    addStmt(Stmts.nNop());
    addStmt(nReturn(b));
    transform();
    Assert.assertTrue("no phi should add", method.locals.size() == 1);
}
Also used : Local(com.googlecode.dex2jar.ir.expr.Local) Test(org.junit.Test)

Example 30 with Local

use of com.googlecode.dex2jar.ir.expr.Local 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();
}
Also used : LabelStmt(com.googlecode.dex2jar.ir.stmt.LabelStmt) Exprs.nLocal(com.googlecode.dex2jar.ir.expr.Exprs.nLocal) Local(com.googlecode.dex2jar.ir.expr.Local) StmtList(com.googlecode.dex2jar.ir.stmt.StmtList) 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