Search in sources :

Example 1 with DecodedInstruction

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

the class InsnDecoder method process.

public InsnNode[] process() throws DecodeException {
    InsnNode[] instructions = new InsnNode[insnArr.length];
    for (int i = 0; i < insnArr.length; i++) {
        DecodedInstruction rawInsn = insnArr[i];
        if (rawInsn != null) {
            InsnNode insn = decode(rawInsn, i);
            if (insn != null) {
                insn.setOffset(i);
            }
            instructions[i] = insn;
        } else {
            instructions[i] = null;
        }
    }
    insnArr = null;
    return instructions;
}
Also used : InsnNode(jadx.core.dex.nodes.InsnNode) 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 2 with DecodedInstruction

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

the class InsnDecoder method decodeInsns.

public void decodeInsns(Code mthCode) throws DecodeException {
    short[] encodedInstructions = mthCode.getInstructions();
    int size = encodedInstructions.length;
    DecodedInstruction[] decoded = new DecodedInstruction[size];
    ShortArrayCodeInput in = new ShortArrayCodeInput(encodedInstructions);
    try {
        while (in.hasMore()) {
            decoded[in.cursor()] = DecodedInstruction.decode(in);
        }
    } catch (Exception e) {
        throw new DecodeException(method, "", e);
    }
    insnArr = decoded;
}
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) ShortArrayCodeInput(com.android.dx.io.instructions.ShortArrayCodeInput) DecodeException(jadx.core.utils.exceptions.DecodeException) DecodeException(jadx.core.utils.exceptions.DecodeException)

Example 3 with DecodedInstruction

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

the class InstructionTransformer method transform.

public short[] transform(IndexMap indexMap, short[] encodedInstructions) throws DexException {
    DecodedInstruction[] decodedInstructions = DecodedInstruction.decodeAll(encodedInstructions);
    int size = decodedInstructions.length;
    this.indexMap = indexMap;
    mappedInstructions = new DecodedInstruction[size];
    mappedAt = 0;
    reader.visitAll(decodedInstructions);
    ShortArrayCodeOutput out = new ShortArrayCodeOutput(size);
    for (DecodedInstruction instruction : mappedInstructions) {
        if (instruction != null) {
            instruction.encode(out);
        }
    }
    this.indexMap = null;
    return out.getArray();
}
Also used : DecodedInstruction(com.android.dx.io.instructions.DecodedInstruction) ShortArrayCodeOutput(com.android.dx.io.instructions.ShortArrayCodeOutput)

Example 4 with DecodedInstruction

use of com.android.dx.io.instructions.DecodedInstruction in project J2ME-Loader by nikita36078.

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 5 with DecodedInstruction

use of com.android.dx.io.instructions.DecodedInstruction in project J2ME-Loader by nikita36078.

the class InstructionTransformer method transform.

public short[] transform(IndexMap indexMap, short[] encodedInstructions) throws DexException {
    DecodedInstruction[] decodedInstructions = DecodedInstruction.decodeAll(encodedInstructions);
    int size = decodedInstructions.length;
    this.indexMap = indexMap;
    mappedInstructions = new DecodedInstruction[size];
    mappedAt = 0;
    reader.visitAll(decodedInstructions);
    ShortArrayCodeOutput out = new ShortArrayCodeOutput(size);
    for (DecodedInstruction instruction : mappedInstructions) {
        if (instruction != null) {
            instruction.encode(out);
        }
    }
    this.indexMap = null;
    return out.getArray();
}
Also used : DecodedInstruction(com.android.dx.io.instructions.DecodedInstruction) ShortArrayCodeOutput(com.android.dx.io.instructions.ShortArrayCodeOutput)

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