Search in sources :

Example 6 with RegisterSpecSet

use of com.taobao.android.dx.rop.code.RegisterSpecSet in project atlas by alibaba.

the class OutputFinisher method addConstants.

/**
     * Helper for {@link #getAllConstants} which adds all the info for
     * a single instruction.
     *
     * @param result {@code non-null;} result set to add to
     * @param insn {@code non-null;} instruction to scrutinize
     */
private static void addConstants(HashSet<Constant> result, DalvInsn insn) {
    if (insn instanceof CstInsn) {
        Constant cst = ((CstInsn) insn).getConstant();
        result.add(cst);
    } else if (insn instanceof LocalSnapshot) {
        RegisterSpecSet specs = ((LocalSnapshot) insn).getLocals();
        int size = specs.size();
        for (int i = 0; i < size; i++) {
            addConstants(result, specs.get(i));
        }
    } else if (insn instanceof LocalStart) {
        RegisterSpec spec = ((LocalStart) insn).getLocal();
        addConstants(result, spec);
    }
}
Also used : RegisterSpecSet(com.taobao.android.dx.rop.code.RegisterSpecSet) Constant(com.taobao.android.dx.rop.cst.Constant) RegisterSpec(com.taobao.android.dx.rop.code.RegisterSpec)

Example 7 with RegisterSpecSet

use of com.taobao.android.dx.rop.code.RegisterSpecSet in project atlas by alibaba.

the class LocalList method make.

/**
     * Constructs an instance for the given method, based on the given
     * block order and intermediate local information.
     *
     * @param insns {@code non-null;} instructions to convert
     * @return {@code non-null;} the constructed list
     */
public static LocalList make(DalvInsnList insns) {
    int sz = insns.size();
    /*
         * Go through the insn list, looking for all the local
         * variable pseudoinstructions, splitting out LocalSnapshots
         * into separate per-variable starts, adding explicit ends
         * wherever a variable is replaced or moved, and collecting
         * these and all the other local variable "activity"
         * together into an output list (without the other insns).
         *
         * Note: As of this writing, this method won't be handed any
         * insn lists that contain local ends, but I (danfuzz) expect
         * that to change at some point, when we start feeding that
         * info explicitly into the rop layer rather than only trying
         * to infer it. So, given that expectation, this code is
         * written to deal with them.
         */
    MakeState state = new MakeState(sz);
    for (int i = 0; i < sz; i++) {
        DalvInsn insn = insns.get(i);
        if (insn instanceof LocalSnapshot) {
            RegisterSpecSet snapshot = ((LocalSnapshot) insn).getLocals();
            state.snapshot(insn.getAddress(), snapshot);
        } else if (insn instanceof LocalStart) {
            RegisterSpec local = ((LocalStart) insn).getLocal();
            state.startLocal(insn.getAddress(), local);
        }
    }
    LocalList result = state.finish();
    if (DEBUG) {
        debugVerify(result);
    }
    return result;
}
Also used : RegisterSpecSet(com.taobao.android.dx.rop.code.RegisterSpecSet) RegisterSpec(com.taobao.android.dx.rop.code.RegisterSpec)

Aggregations

RegisterSpecSet (com.taobao.android.dx.rop.code.RegisterSpecSet)7 RegisterSpec (com.taobao.android.dx.rop.code.RegisterSpec)5 FillArrayDataInsn (com.taobao.android.dx.rop.code.FillArrayDataInsn)1 Insn (com.taobao.android.dx.rop.code.Insn)1 PlainCstInsn (com.taobao.android.dx.rop.code.PlainCstInsn)1 PlainInsn (com.taobao.android.dx.rop.code.PlainInsn)1 Rop (com.taobao.android.dx.rop.code.Rop)1 SwitchInsn (com.taobao.android.dx.rop.code.SwitchInsn)1 ThrowingCstInsn (com.taobao.android.dx.rop.code.ThrowingCstInsn)1 ThrowingInsn (com.taobao.android.dx.rop.code.ThrowingInsn)1 Constant (com.taobao.android.dx.rop.cst.Constant)1 IntList (com.taobao.android.dx.util.IntList)1