Search in sources :

Example 11 with Trap

use of com.googlecode.dex2jar.ir.Trap in project dex2jar by pxb1988.

the class Dex2IRConverter method initExceptionHandlers.

private void initExceptionHandlers(DexCodeNode dexCodeNode, BitSet[] exBranch, BitSet handlers) {
    if (dexCodeNode.tryStmts != null) {
        for (TryCatchNode tcb : dexCodeNode.tryStmts) {
            target.traps.add(new Trap(getLabel(tcb.start), getLabel(tcb.end), getLabels(tcb.handler), tcb.type));
            for (DexLabel h : tcb.handler) {
                handlers.set(indexOf(h));
            }
            int endIndex = indexOf(tcb.end);
            for (int p = indexOf(tcb.start) + 1; p < endIndex; p++) {
                DexStmtNode stmt = insnList.get(p);
                if (stmt.op != null && stmt.op.canThrow()) {
                    BitSet x = exBranch[p];
                    if (x == null) {
                        x = exBranch[p] = new BitSet(insnList.size());
                    }
                    for (DexLabel h : tcb.handler) {
                        int hIndex = indexOf(h);
                        x.set(hIndex);
                        parentCount[hIndex]++;
                    }
                }
            }
        }
    }
}
Also used : TryCatchNode(com.googlecode.d2j.node.TryCatchNode) Trap(com.googlecode.dex2jar.ir.Trap) DexLabel(com.googlecode.d2j.DexLabel)

Aggregations

Trap (com.googlecode.dex2jar.ir.Trap)11 LabelStmt (com.googlecode.dex2jar.ir.stmt.LabelStmt)4 Local (com.googlecode.dex2jar.ir.expr.Local)3 Stmt (com.googlecode.dex2jar.ir.stmt.Stmt)3 ArrayList (java.util.ArrayList)2 Test (org.junit.Test)2 DexLabel (com.googlecode.d2j.DexLabel)1 TryCatchNode (com.googlecode.d2j.node.TryCatchNode)1 LabelAndLocalMapper (com.googlecode.dex2jar.ir.LabelAndLocalMapper)1 PhiExpr (com.googlecode.dex2jar.ir.expr.PhiExpr)1 Value (com.googlecode.dex2jar.ir.expr.Value)1 AssignStmt (com.googlecode.dex2jar.ir.stmt.AssignStmt)1 E2Stmt (com.googlecode.dex2jar.ir.stmt.Stmt.E2Stmt)1 Value (org.objectweb.asm.tree.analysis.Value)1