Search in sources :

Example 1 with PackedSwitchPayloadDecodedInstruction

use of com.android.dx.io.instructions.PackedSwitchPayloadDecodedInstruction in project jadx by skylot.

the class InsnDecoder method decodeSwitch.

private InsnNode decodeSwitch(DecodedInstruction insn, int offset, boolean packed) {
    int payloadOffset = insn.getTarget();
    DecodedInstruction payload = insnArr[payloadOffset];
    Object[] keys;
    int[] targets;
    if (packed) {
        PackedSwitchPayloadDecodedInstruction ps = (PackedSwitchPayloadDecodedInstruction) payload;
        targets = ps.getTargets();
        keys = new Object[targets.length];
        int k = ps.getFirstKey();
        for (int i = 0; i < keys.length; i++) {
            keys[i] = k++;
        }
    } else {
        SparseSwitchPayloadDecodedInstruction ss = (SparseSwitchPayloadDecodedInstruction) payload;
        targets = ss.getTargets();
        keys = new Object[targets.length];
        for (int i = 0; i < keys.length; i++) {
            keys[i] = ss.getKeys()[i];
        }
    }
    // convert from relative to absolute offsets
    for (int i = 0; i < targets.length; i++) {
        targets[i] = targets[i] - payloadOffset + offset;
    }
    int nextOffset = getNextInsnOffset(insnArr, offset);
    return new SwitchNode(InsnArg.reg(insn, 0, ArgType.NARROW), keys, targets, nextOffset);
}
Also used : PackedSwitchPayloadDecodedInstruction(com.android.dx.io.instructions.PackedSwitchPayloadDecodedInstruction) SparseSwitchPayloadDecodedInstruction(com.android.dx.io.instructions.SparseSwitchPayloadDecodedInstruction) DecodedInstruction(com.android.dx.io.instructions.DecodedInstruction) FillArrayDataPayloadDecodedInstruction(com.android.dx.io.instructions.FillArrayDataPayloadDecodedInstruction) SparseSwitchPayloadDecodedInstruction(com.android.dx.io.instructions.SparseSwitchPayloadDecodedInstruction) PackedSwitchPayloadDecodedInstruction(com.android.dx.io.instructions.PackedSwitchPayloadDecodedInstruction)

Aggregations

DecodedInstruction (com.android.dx.io.instructions.DecodedInstruction)1 FillArrayDataPayloadDecodedInstruction (com.android.dx.io.instructions.FillArrayDataPayloadDecodedInstruction)1 PackedSwitchPayloadDecodedInstruction (com.android.dx.io.instructions.PackedSwitchPayloadDecodedInstruction)1 SparseSwitchPayloadDecodedInstruction (com.android.dx.io.instructions.SparseSwitchPayloadDecodedInstruction)1