Search in sources :

Example 6 with DecodedInstruction

use of com.android.dx.io.instructions.DecodedInstruction in project buck by facebook.

the class CodeReader method visitAll.

public void visitAll(DecodedInstruction[] decodedInstructions) throws DexException {
    int size = decodedInstructions.length;
    for (int i = 0; i < size; i++) {
        DecodedInstruction one = decodedInstructions[i];
        if (one == null) {
            continue;
        }
        callVisit(decodedInstructions, one);
    }
}
Also used : DecodedInstruction(com.android.dx.io.instructions.DecodedInstruction)

Example 7 with DecodedInstruction

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

the class InsnDecoder method getMoveResultRegister.

private int getMoveResultRegister(DecodedInstruction[] insnArr, int offset) {
    int nextOffset = getNextInsnOffset(insnArr, offset);
    if (nextOffset >= 0) {
        DecodedInstruction next = insnArr[nextOffset];
        int opc = next.getOpcode();
        if (opc == Opcodes.MOVE_RESULT || opc == Opcodes.MOVE_RESULT_WIDE || opc == Opcodes.MOVE_RESULT_OBJECT) {
            return next.getA();
        }
    }
    return -1;
}
Also used : 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)

Example 8 with DecodedInstruction

use of com.android.dx.io.instructions.DecodedInstruction 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)8 FillArrayDataPayloadDecodedInstruction (com.android.dx.io.instructions.FillArrayDataPayloadDecodedInstruction)4 PackedSwitchPayloadDecodedInstruction (com.android.dx.io.instructions.PackedSwitchPayloadDecodedInstruction)4 SparseSwitchPayloadDecodedInstruction (com.android.dx.io.instructions.SparseSwitchPayloadDecodedInstruction)4 ShortArrayCodeOutput (com.android.dx.io.instructions.ShortArrayCodeOutput)2 ShortArrayCodeInput (com.android.dx.io.instructions.ShortArrayCodeInput)1 InsnNode (jadx.core.dex.nodes.InsnNode)1 DecodeException (jadx.core.utils.exceptions.DecodeException)1