use of com.googlecode.d2j.DexLabel in project dex2jar by pxb1988.
the class Dex2IRConverter method dfs.
private void dfs(BitSet[] exBranch, BitSet handlers, BitSet access, DvmInterpreter<DvmValue> interpreter) {
currentEmit = preEmit;
Dex2IrFrame first = initFirstFrame(dexCodeNode, target);
if (parentCount[0] > 1) {
merge(first, 0);
} else {
frames[0] = first;
}
Stack<DexStmtNode> stack = new Stack<>();
stack.push(insnList.get(0));
Dex2IrFrame tmp = new Dex2IrFrame(dexCodeNode.totalRegister);
while (!stack.isEmpty()) {
DexStmtNode p = stack.pop();
int index = p.__index;
if (!access.get(index)) {
access.set(index);
} else {
continue;
}
Dex2IrFrame frame = frames[index];
setCurrentEmit(index);
if (p instanceof DexLabelStmtNode) {
emit(getLabel(((DexLabelStmtNode) p).label));
if (handlers.get(index)) {
Local ex = newLocal();
emit(Stmts.nIdentity(ex, Exprs.nExceptionRef("Ljava/lang/Throwable;")));
frame.setTmp(new DvmValue(ex));
}
}
BitSet ex = exBranch[index];
if (ex != null) {
for (int i = ex.nextSetBit(0); i >= 0; i = ex.nextSetBit(i + 1)) {
merge(frame, i);
stack.push(insnList.get(i));
}
}
tmp.init(frame);
try {
if (p.op != null) {
switch(p.op) {
case RETURN_VOID:
emit(nReturnVoid());
break;
case GOTO:
case GOTO_16:
case GOTO_32:
emit(nGoto(getLabel(((JumpStmtNode) p).label)));
break;
case NOP:
emit(nNop());
break;
case BAD_OP:
emit(nThrow(nInvokeNew(new Value[] { nString("bad dex opcode") }, new String[] { "Ljava/lang/String;" }, "Ljava/lang/VerifyError;")));
break;
default:
tmp.execute(p, interpreter);
break;
}
}
} catch (Exception exception) {
throw new RuntimeException("Fail on Op " + p.op + " index " + index, exception);
}
if (p.op != null) {
Op op = p.op;
if (op.canBranch()) {
JumpStmtNode jump = (JumpStmtNode) p;
int targetIndex = indexOf(jump.label);
stack.push(insnList.get(targetIndex));
merge(tmp, targetIndex);
}
if (op.canSwitch()) {
BaseSwitchStmtNode switchStmtNode = (BaseSwitchStmtNode) p;
for (DexLabel label : switchStmtNode.labels) {
int targetIndex = indexOf(label);
stack.push(insnList.get(targetIndex));
merge(tmp, targetIndex);
}
}
if (op.canContinue()) {
stack.push(insnList.get(index + 1));
merge(tmp, index + 1);
}
} else {
stack.push(insnList.get(index + 1));
merge(tmp, index + 1);
}
// cleanup frame it is useless
if (parentCount[index] <= 1) {
frames[index] = null;
}
}
}
Aggregations