Search in sources :

Example 11 with TypeBearer

use of com.taobao.android.dx.rop.type.TypeBearer in project atlas by alibaba.

the class OneLocalsArray method annotate.

/** @inheritDoc */
public void annotate(ExceptionWithContext ex) {
    for (int i = 0; i < locals.length; i++) {
        TypeBearer type = locals[i];
        String s = (type == null) ? "<invalid>" : type.toString();
        ex.addContext("locals[" + Hex.u2(i) + "]: " + s);
    }
}
Also used : TypeBearer(com.taobao.android.dx.rop.type.TypeBearer)

Example 12 with TypeBearer

use of com.taobao.android.dx.rop.type.TypeBearer in project atlas by alibaba.

the class OneLocalsArray method toHuman.

/** {@inheritDoc*/
public String toHuman() {
    StringBuilder sb = new StringBuilder();
    for (int i = 0; i < locals.length; i++) {
        TypeBearer type = locals[i];
        String s = (type == null) ? "<invalid>" : type.toString();
        sb.append("locals[" + Hex.u2(i) + "]: " + s + "\n");
    }
    return sb.toString();
}
Also used : TypeBearer(com.taobao.android.dx.rop.type.TypeBearer)

Example 13 with TypeBearer

use of com.taobao.android.dx.rop.type.TypeBearer in project atlas by alibaba.

the class OneLocalsArray method getCategory1.

/** @inheritDoc */
public TypeBearer getCategory1(int idx) {
    TypeBearer result = get(idx);
    Type type = result.getType();
    if (type.isUninitialized()) {
        return throwSimException(idx, "uninitialized instance");
    }
    if (type.isCategory2()) {
        return throwSimException(idx, "category-2");
    }
    return result;
}
Also used : Type(com.taobao.android.dx.rop.type.Type) TypeBearer(com.taobao.android.dx.rop.type.TypeBearer)

Example 14 with TypeBearer

use of com.taobao.android.dx.rop.type.TypeBearer in project atlas by alibaba.

the class ExecutionStack method change.

/**
     * Changes an element already on a stack. This method is useful in limited
     * contexts, particularly when merging two instances. As such, it places
     * the following restriction on its behavior: You may only replace
     * values with other values of the same category.
     *
     * @param n {@code >= 0;} which element to change, where {@code 0} is
     * the top element of the stack
     * @param type {@code non-null;} type of the new value
     * @throws SimException thrown if {@code n >= size()} or
     * the action is otherwise prohibited
     */
public void change(int n, TypeBearer type) {
    throwIfImmutable();
    try {
        type = type.getFrameType();
    } catch (NullPointerException ex) {
        // Elucidate the exception.
        throw new NullPointerException("type == null");
    }
    int idx = stackPtr - n - 1;
    TypeBearer orig = stack[idx];
    if ((orig == null) || (orig.getType().getCategory() != type.getType().getCategory())) {
        throwSimException("incompatible substitution: " + stackElementString(orig) + " -> " + stackElementString(type));
    }
    stack[idx] = type;
}
Also used : TypeBearer(com.taobao.android.dx.rop.type.TypeBearer)

Example 15 with TypeBearer

use of com.taobao.android.dx.rop.type.TypeBearer in project atlas by alibaba.

the class Merger method mergeLocals.

/**
     * Merges two locals arrays. If the merged result is the same as the first
     * argument, then return the first argument (not a copy).
     *
     * @param locals1 {@code non-null;} a locals array
     * @param locals2 {@code non-null;} another locals array
     * @return {@code non-null;} the result of merging the two locals arrays
     */
public static OneLocalsArray mergeLocals(OneLocalsArray locals1, OneLocalsArray locals2) {
    if (locals1 == locals2) {
        // Easy out.
        return locals1;
    }
    int sz = locals1.getMaxLocals();
    OneLocalsArray result = null;
    if (locals2.getMaxLocals() != sz) {
        throw new SimException("mismatched maxLocals values");
    }
    for (int i = 0; i < sz; i++) {
        TypeBearer tb1 = locals1.getOrNull(i);
        TypeBearer tb2 = locals2.getOrNull(i);
        TypeBearer resultType = mergeType(tb1, tb2);
        if (resultType != tb1) {
            /*
                 * We only need to do anything when the result differs
                 * from what is in the first array, since that's what the
                 * result gets initialized to.
                 */
            if (result == null) {
                result = locals1.copy();
            }
            if (resultType == null) {
                result.invalidate(i);
            } else {
                result.set(i, resultType);
            }
        }
    }
    if (result == null) {
        return locals1;
    }
    result.setImmutable();
    return result;
}
Also used : TypeBearer(com.taobao.android.dx.rop.type.TypeBearer)

Aggregations

TypeBearer (com.taobao.android.dx.rop.type.TypeBearer)19 RegisterSpec (com.taobao.android.dx.rop.code.RegisterSpec)7 Type (com.taobao.android.dx.rop.type.Type)5 Constant (com.taobao.android.dx.rop.cst.Constant)4 TypedConstant (com.taobao.android.dx.rop.cst.TypedConstant)4 Insn (com.taobao.android.dx.rop.code.Insn)3 PlainCstInsn (com.taobao.android.dx.rop.code.PlainCstInsn)3 PlainInsn (com.taobao.android.dx.rop.code.PlainInsn)3 RegisterSpecList (com.taobao.android.dx.rop.code.RegisterSpecList)3 ArrayList (java.util.ArrayList)3 HashSet (java.util.HashSet)3 FillArrayDataInsn (com.taobao.android.dx.rop.code.FillArrayDataInsn)2 Rop (com.taobao.android.dx.rop.code.Rop)2 ThrowingCstInsn (com.taobao.android.dx.rop.code.ThrowingCstInsn)2 ThrowingInsn (com.taobao.android.dx.rop.code.ThrowingInsn)2 CstInteger (com.taobao.android.dx.rop.cst.CstInteger)2 CstLiteralBits (com.taobao.android.dx.rop.cst.CstLiteralBits)2 SourcePosition (com.taobao.android.dx.rop.code.SourcePosition)1 SwitchInsn (com.taobao.android.dx.rop.code.SwitchInsn)1 CstFieldRef (com.taobao.android.dx.rop.cst.CstFieldRef)1