Search in sources :

Example 31 with Type

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

the class Rops method opNewArray.

/**
     * Returns the appropriate {@code new-array} rop for the given
     * type. The result is a shared instance.
     *
     * @param arrayType {@code non-null;} array type of array being created
     * @return {@code non-null;} an appropriate instance
     */
public static Rop opNewArray(TypeBearer arrayType) {
    Type type = arrayType.getType();
    Type elementType = type.getComponentType();
    switch(elementType.getBasicType()) {
        case Type.BT_INT:
            return NEW_ARRAY_INT;
        case Type.BT_LONG:
            return NEW_ARRAY_LONG;
        case Type.BT_FLOAT:
            return NEW_ARRAY_FLOAT;
        case Type.BT_DOUBLE:
            return NEW_ARRAY_DOUBLE;
        case Type.BT_BOOLEAN:
            return NEW_ARRAY_BOOLEAN;
        case Type.BT_BYTE:
            return NEW_ARRAY_BYTE;
        case Type.BT_CHAR:
            return NEW_ARRAY_CHAR;
        case Type.BT_SHORT:
            return NEW_ARRAY_SHORT;
        case Type.BT_OBJECT:
            {
                return new Rop(RegOps.NEW_ARRAY, type, StdTypeList.INT, Exceptions.LIST_Error_NegativeArraySizeException, "new-array-object");
            }
    }
    return throwBadType(type);
}
Also used : CstType(com.taobao.android.dx.rop.cst.CstType) Type(com.taobao.android.dx.rop.type.Type)

Example 32 with Type

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

the class CstBaseMethodRef method getPrototype.

/**
     * Gets the prototype of this method as either a
     * {@code static} or instance method. In the case of a
     * {@code static} method, this is the same as the raw
     * prototype. In the case of an instance method, this has an
     * appropriately-typed {@code this} argument as the first
     * one.
     *
     * @param isStatic whether the method should be considered static
     * @return {@code non-null;} the method prototype
     */
public final Prototype getPrototype(boolean isStatic) {
    if (isStatic) {
        return prototype;
    } else {
        if (instancePrototype == null) {
            Type thisType = getDefiningClass().getClassType();
            instancePrototype = prototype.withFirstParameter(thisType);
        }
        return instancePrototype;
    }
}
Also used : Type(com.taobao.android.dx.rop.type.Type)

Example 33 with Type

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

the class TypeIdsSection method intern.

/**
     * Interns an element into this instance.
     *
     * @param type {@code non-null;} the type to intern
     * @return {@code non-null;} the interned reference
     */
public synchronized TypeIdItem intern(CstType type) {
    if (type == null) {
        throw new NullPointerException("type == null");
    }
    throwIfPrepared();
    Type typePerSe = type.getClassType();
    if (typePerSe.getDescriptor().equals("L;")) {
        System.out.println("xxxxxx");
    }
    TypeIdItem result = typeIds.get(typePerSe);
    if (result == null) {
        result = new TypeIdItem(type);
        typeIds.put(typePerSe, result);
    }
    return result;
}
Also used : CstType(com.taobao.android.dx.rop.cst.CstType) Type(com.taobao.android.dx.rop.type.Type)

Aggregations

Type (com.taobao.android.dx.rop.type.Type)33 CstType (com.taobao.android.dx.rop.cst.CstType)19 Constant (com.taobao.android.dx.rop.cst.Constant)5 StdTypeList (com.taobao.android.dx.rop.type.StdTypeList)5 TypeBearer (com.taobao.android.dx.rop.type.TypeBearer)5 RegisterSpec (com.taobao.android.dx.rop.code.RegisterSpec)4 CstString (com.taobao.android.dx.rop.cst.CstString)4 TypeList (com.taobao.android.dx.rop.type.TypeList)3 BasicBlock (com.taobao.android.dx.rop.code.BasicBlock)2 Insn (com.taobao.android.dx.rop.code.Insn)2 LocalItem (com.taobao.android.dx.rop.code.LocalItem)2 PlainCstInsn (com.taobao.android.dx.rop.code.PlainCstInsn)2 PlainInsn (com.taobao.android.dx.rop.code.PlainInsn)2 RegisterSpecList (com.taobao.android.dx.rop.code.RegisterSpecList)2 SourcePosition (com.taobao.android.dx.rop.code.SourcePosition)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 ByteArrayByteInput (com.taobao.android.dex.util.ByteArrayByteInput)1 ByteInput (com.taobao.android.dex.util.ByteInput)1