Search in sources :

Example 16 with LabelStmt

use of com.googlecode.dex2jar.ir.stmt.LabelStmt in project dex2jar by pxb1988.

the class TypeTransformerTest method test3Z.

@Test
public void test3Z() {
    initMethod(true, "V");
    Local b = addLocal("b");
    addStmt(nAssign(b, nInt(1)));
    LabelStmt L0 = newLabel();
    addStmt(nIf(nEq(b, nInt(0), TypeClass.ZIFL.name), L0));
    addStmt(L0);
    addStmt(nReturnVoid());
    transform();
// FIXME local should type to Z but I works as well
// Assert.assertEquals("", "Z", b.valueType);
}
Also used : LabelStmt(com.googlecode.dex2jar.ir.stmt.LabelStmt) Local(com.googlecode.dex2jar.ir.expr.Local) Test(org.junit.Test)

Example 17 with LabelStmt

use of com.googlecode.dex2jar.ir.stmt.LabelStmt 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);
}
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 18 with LabelStmt

use of com.googlecode.dex2jar.ir.stmt.LabelStmt in project dex2jar by pxb1988.

the class UnSSATransformerTransformerTest method test07PhiInHandler.

@Test
public void test07PhiInHandler() {
    initMethod(true, "I");
    Local a1 = addLocal("a1");
    Local a2 = addLocal("a2");
    Local a = addLocal("a");
    Local ex = addLocal("ex");
    addStmt(Stmts.nAssign(a1, nInt(1)));
    LabelStmt L0 = newLabel();
    LabelStmt L2 = newLabel();
    LabelStmt L3 = newLabel();
    addStmt(L0);
    addStmt(Stmts.nVoidInvoke(Exprs.nInvokeStatic(new Value[0], "La;", "m", new String[0], "V")));
    addStmt(Stmts.nAssign(a2, nInt(2)));
    addStmt(Stmts.nVoidInvoke(Exprs.nInvokeStatic(new Value[0], "La;", "m", new String[0], "V")));
    addStmt(L2);
    addStmt(Stmts.nReturn(a2));
    addStmt(L3);
    Stmt ref = addStmt(Stmts.nIdentity(ex, Exprs.nExceptionRef("Ljava/lang/Exception;")));
    attachPhi(L3, Stmts.nAssign(a, nPhi(a1, a2)));
    addStmt(Stmts.nVoidInvoke(Exprs.nInvokeStatic(new Value[] { a1 }, "La;", "m", new String[] { "I" }, "V")));
    addStmt(Stmts.nReturn(a));
    method.traps.add(new Trap(L0, L2, new LabelStmt[] { L3 }, new String[] { "Ljava/lang/Exception" }));
    transform();
    Assert.assertTrue("the fix assign should insert after x=@ExceptionRef", L3.getNext() == ref);
}
Also used : LabelStmt(com.googlecode.dex2jar.ir.stmt.LabelStmt) Local(com.googlecode.dex2jar.ir.expr.Local) Trap(com.googlecode.dex2jar.ir.Trap) LabelStmt(com.googlecode.dex2jar.ir.stmt.LabelStmt) Stmt(com.googlecode.dex2jar.ir.stmt.Stmt) Test(org.junit.Test)

Example 19 with LabelStmt

use of com.googlecode.dex2jar.ir.stmt.LabelStmt in project dex2jar by pxb1988.

the class Dex2IrAdapter method visitTryCatch.

@Override
public void visitTryCatch(DexLabel start, DexLabel end, DexLabel[] handlers, String[] types) {
    LabelStmt[] xlabelStmts = new LabelStmt[types.length];
    for (int i = 0; i < types.length; i++) {
        xlabelStmts[i] = toLabelStmt(handlers[i]);
    }
    irMethod.traps.add(new Trap(toLabelStmt(start), toLabelStmt(end), xlabelStmts, types));
}
Also used : LabelStmt(com.googlecode.dex2jar.ir.stmt.LabelStmt) Trap(com.googlecode.dex2jar.ir.Trap)

Example 20 with LabelStmt

use of com.googlecode.dex2jar.ir.stmt.LabelStmt in project dex2jar by pxb1988.

the class Dex2IrAdapter method visitSparseSwitchStmt.

@Override
public void visitSparseSwitchStmt(Op op, int aA, int[] cases, DexLabel[] labels) {
    LabelStmt[] lss = new LabelStmt[cases.length];
    for (int i = 0; i < cases.length; i++) {
        lss[i] = toLabelStmt(labels[i]);
    }
    LabelStmt d = new LabelStmt();
    x(nLookupSwitch(locals[aA], cases, lss, d));
    x(d);
}
Also used : LabelStmt(com.googlecode.dex2jar.ir.stmt.LabelStmt)

Aggregations

LabelStmt (com.googlecode.dex2jar.ir.stmt.LabelStmt)39 Local (com.googlecode.dex2jar.ir.expr.Local)26 Stmt (com.googlecode.dex2jar.ir.stmt.Stmt)22 AssignStmt (com.googlecode.dex2jar.ir.stmt.AssignStmt)17 Test (org.junit.Test)14 Value (com.googlecode.dex2jar.ir.expr.Value)8 ArrayList (java.util.ArrayList)7 Trap (com.googlecode.dex2jar.ir.Trap)4 JumpStmt (com.googlecode.dex2jar.ir.stmt.JumpStmt)4 StmtList (com.googlecode.dex2jar.ir.stmt.StmtList)4 List (java.util.List)3 StmtTraveler (com.googlecode.dex2jar.ir.StmtTraveler)2 PhiExpr (com.googlecode.dex2jar.ir.expr.PhiExpr)2 Cfg (com.googlecode.dex2jar.ir.ts.Cfg)2 HashSet (java.util.HashSet)2 IR2JConverter (com.googlecode.d2j.converter.IR2JConverter)1 DexFileNode (com.googlecode.d2j.node.DexFileNode)1 DexMethodNode (com.googlecode.d2j.node.DexMethodNode)1 IrMethod (com.googlecode.dex2jar.ir.IrMethod)1 LabelAndLocalMapper (com.googlecode.dex2jar.ir.LabelAndLocalMapper)1