Search in sources :

Example 1 with JumpStmt

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

the class UnSSATransformer method insertAssignPath.

private void insertAssignPath(StmtList stmts, Stmt from, LabelStmt labelStmt, List<AssignStmt> buff) {
    boolean insertBeforeFromStmt;
    if (from.exceptionHandlers != null && from.exceptionHandlers.contains(labelStmt)) {
        insertBeforeFromStmt = true;
    } else {
        switch(from.st) {
            case GOTO:
            case IF:
                JumpStmt jumpStmt = (JumpStmt) from;
                //
                insertBeforeFromStmt = jumpStmt.getTarget().equals(labelStmt);
                break;
            case TABLE_SWITCH:
            case LOOKUP_SWITCH:
                insertBeforeFromStmt = true;
                break;
            default:
                insertBeforeFromStmt = false;
                break;
        }
    }
    if (insertBeforeFromStmt) {
        for (AssignStmt as : buff) {
            stmts.insertBefore(from, as);
        }
    } else {
        for (AssignStmt as : buff) {
            stmts.insertAfter(from, as);
        }
    }
    LiveV[] frame = (LiveV[]) from.frame;
    List<LiveV> newLiveVs = new ArrayList<>(buff.size());
    for (AssignStmt as : buff) {
        Local left = (Local) as.getOp1();
        {
            LiveV liveV = new LiveV();
            liveV.local = left;
            liveV.used = true;
            newLiveVs.add(liveV);
        }
        RegAssign leftRegAssign = (RegAssign) left.tag;
        Local right = (Local) as.getOp2();
        int toSkip = right._ls_index;
        for (int i = 0; i < frame.length; i++) {
            if (i == toSkip) {
                continue;
            }
            LiveV v = frame[i];
            if (v != null && v.used) {
                RegAssign assign = (RegAssign) v.local.tag;
                assign.excludes.add(leftRegAssign);
                leftRegAssign.excludes.add(assign);
            }
        }
        for (AssignStmt as2 : buff) {
            RegAssign assign = (RegAssign) ((Local) as2.getOp1()).tag;
            assign.excludes.add(leftRegAssign);
            leftRegAssign.excludes.add(assign);
        }
    }
    LiveV[] newFrame = new LiveV[frame.length + newLiveVs.size()];
    System.arraycopy(frame, 0, newFrame, 0, frame.length);
    for (int i = 0; i < newLiveVs.size(); i++) {
        newFrame[i + frame.length] = newLiveVs.get(i);
    }
}
Also used : JumpStmt(com.googlecode.dex2jar.ir.stmt.JumpStmt) AssignStmt(com.googlecode.dex2jar.ir.stmt.AssignStmt) ArrayList(java.util.ArrayList) Local(com.googlecode.dex2jar.ir.expr.Local)

Aggregations

Local (com.googlecode.dex2jar.ir.expr.Local)1 AssignStmt (com.googlecode.dex2jar.ir.stmt.AssignStmt)1 JumpStmt (com.googlecode.dex2jar.ir.stmt.JumpStmt)1 ArrayList (java.util.ArrayList)1