Search in sources :

Example 1 with SwitchPayload

use of jadx.api.plugins.input.insns.custom.impl.SwitchPayload in project jadx by skylot.

the class TableSwitchDecoder method read.

private static void read(CodeDecodeState state, boolean skip) {
    DataReader reader = state.reader();
    JavaInsnData insn = state.insn();
    int dataOffset = reader.getOffset();
    int insnOffset = insn.getOffset();
    reader.skip(3 - insnOffset % 4);
    int defTarget = insnOffset + reader.readS4();
    int low = reader.readS4();
    int high = reader.readS4();
    int count = high - low + 1;
    if (skip) {
        reader.skip(count * 4);
    } else {
        state.pop(0);
        int[] keys = new int[count];
        int[] targets = new int[count];
        for (int i = 0; i < count; i++) {
            int target = insnOffset + reader.readS4();
            keys[i] = low + i;
            targets[i] = target;
            state.registerJump(target);
        }
        insn.setTarget(defTarget);
        state.registerJump(defTarget);
        insn.setPayload(new SwitchPayload(count, keys, targets));
    }
    insn.setPayloadSize(reader.getOffset() - dataOffset);
}
Also used : DataReader(jadx.plugins.input.java.data.DataReader) SwitchPayload(jadx.api.plugins.input.insns.custom.impl.SwitchPayload) JavaInsnData(jadx.plugins.input.java.data.code.JavaInsnData)

Example 2 with SwitchPayload

use of jadx.api.plugins.input.insns.custom.impl.SwitchPayload in project jadx by skylot.

the class LookupSwitchDecoder method read.

private static void read(CodeDecodeState state, boolean skip) {
    DataReader reader = state.reader();
    JavaInsnData insn = state.insn();
    int dataOffset = reader.getOffset();
    int insnOffset = insn.getOffset();
    reader.skip(3 - insnOffset % 4);
    int defTarget = insnOffset + reader.readS4();
    int pairs = reader.readS4();
    if (skip) {
        reader.skip(pairs * 8);
    } else {
        state.pop(0);
        int[] keys = new int[pairs];
        int[] targets = new int[pairs];
        for (int i = 0; i < pairs; i++) {
            keys[i] = reader.readS4();
            int target = insnOffset + reader.readS4();
            targets[i] = target;
            state.registerJump(target);
        }
        insn.setTarget(defTarget);
        state.registerJump(defTarget);
        insn.setPayload(new SwitchPayload(pairs, keys, targets));
    }
    insn.setPayloadSize(reader.getOffset() - dataOffset);
}
Also used : DataReader(jadx.plugins.input.java.data.DataReader) SwitchPayload(jadx.api.plugins.input.insns.custom.impl.SwitchPayload) JavaInsnData(jadx.plugins.input.java.data.code.JavaInsnData)

Aggregations

SwitchPayload (jadx.api.plugins.input.insns.custom.impl.SwitchPayload)2 DataReader (jadx.plugins.input.java.data.DataReader)2 JavaInsnData (jadx.plugins.input.java.data.code.JavaInsnData)2