Java Code Examples for com.android.dx.rop.type.Type#isCategory2()

The following examples show how to use com.android.dx.rop.type.Type#isCategory2() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OneLocalsArray.java    From Box with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override
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;
}
 
Example 2
Source File: CodeObserver.java    From Box with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override
public void visitLocal(int opcode, int offset, int length,
        int idx, Type type, int value) {
    String idxStr = (length <= 3) ? Hex.u1(idx) : Hex.u2(idx);
    boolean argComment = (length == 1);
    String valueStr = "";

    if (opcode == ByteOps.IINC) {
        valueStr = ", #" +
            ((length <= 3) ? Hex.s1(value) : Hex.s2(value));
    }

    String catStr = "";
    if (type.isCategory2()) {
        catStr = (argComment ? "," : " //") + " category-2";
    }

    observer.parsed(bytes, offset, length,
                    header(offset) + (argComment ? " // " : " ") +
                    idxStr + valueStr + catStr);
}
 
Example 3
Source File: Rops.java    From Box with Apache License 2.0 6 votes vote down vote up
/**
 * Returns the appropriate {@code filled-new-array} rop for the given
 * type. The result may be a shared instance.
 *
 * @param arrayType {@code non-null;} type of array being created
 * @param count {@code count >= 0;} number of elements that the array should have
 * @return {@code non-null;} an appropriate instance
 */
public static Rop opFilledNewArray(TypeBearer arrayType, int count) {
    Type type = arrayType.getType();
    Type elementType = type.getComponentType();

    if (elementType.isCategory2()) {
        return throwBadType(arrayType);
    }

    if (count < 0) {
        throw new IllegalArgumentException("count < 0");
    }

    StdTypeList sourceTypes = new StdTypeList(count);

    for (int i = 0; i < count; i++) {
        sourceTypes.set(i, elementType);
    }

    // Note: The resulting rop is considered call-like.
    return new Rop(RegOps.FILLED_NEW_ARRAY,
                   sourceTypes,
                   Exceptions.LIST_Error);
}
 
Example 4
Source File: OneLocalsArray.java    From Box with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override
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;
}
 
Example 5
Source File: CodeObserver.java    From Box with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override
public void visitLocal(int opcode, int offset, int length,
        int idx, Type type, int value) {
    String idxStr = (length <= 3) ? Hex.u1(idx) : Hex.u2(idx);
    boolean argComment = (length == 1);
    String valueStr = "";

    if (opcode == ByteOps.IINC) {
        valueStr = ", #" +
            ((length <= 3) ? Hex.s1(value) : Hex.s2(value));
    }

    String catStr = "";
    if (type.isCategory2()) {
        catStr = (argComment ? "," : " //") + " category-2";
    }

    observer.parsed(bytes, offset, length,
                    header(offset) + (argComment ? " // " : " ") +
                    idxStr + valueStr + catStr);
}
 
Example 6
Source File: Rops.java    From Box with Apache License 2.0 6 votes vote down vote up
/**
 * Returns the appropriate {@code filled-new-array} rop for the given
 * type. The result may be a shared instance.
 *
 * @param arrayType {@code non-null;} type of array being created
 * @param count {@code count >= 0;} number of elements that the array should have
 * @return {@code non-null;} an appropriate instance
 */
public static Rop opFilledNewArray(TypeBearer arrayType, int count) {
    Type type = arrayType.getType();
    Type elementType = type.getComponentType();

    if (elementType.isCategory2()) {
        return throwBadType(arrayType);
    }

    if (count < 0) {
        throw new IllegalArgumentException("count < 0");
    }

    StdTypeList sourceTypes = new StdTypeList(count);

    for (int i = 0; i < count; i++) {
        sourceTypes.set(i, elementType);
    }

    // Note: The resulting rop is considered call-like.
    return new Rop(RegOps.FILLED_NEW_ARRAY,
                   sourceTypes,
                   Exceptions.LIST_Error);
}
 
Example 7
Source File: OneLocalsArray.java    From J2ME-Loader with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
   @Override
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;
   }
 
Example 8
Source File: CodeObserver.java    From J2ME-Loader with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
   @Override
public void visitLocal(int opcode, int offset, int length,
					   int idx, Type type, int value) {
       String idxStr = (length <= 3) ? Hex.u1(idx) : Hex.u2(idx);
       boolean argComment = (length == 1);
       String valueStr = "";

       if (opcode == ByteOps.IINC) {
           valueStr = ", #" +
               ((length <= 3) ? Hex.s1(value) : Hex.s2(value));
       }

       String catStr = "";
       if (type.isCategory2()) {
           catStr = (argComment ? "," : " //") + " category-2";
       }

       observer.parsed(bytes, offset, length,
                       header(offset) + (argComment ? " // " : " ") +
                       idxStr + valueStr + catStr);
   }
 
Example 9
Source File: Rops.java    From J2ME-Loader with Apache License 2.0 6 votes vote down vote up
/**
 * Returns the appropriate {@code filled-new-array} rop for the given
 * type. The result may be a shared instance.
 *
 * @param arrayType {@code non-null;} type of array being created
 * @param count {@code count >= 0;} number of elements that the array should have
 * @return {@code non-null;} an appropriate instance
 */
public static Rop opFilledNewArray(TypeBearer arrayType, int count) {
    Type type = arrayType.getType();
    Type elementType = type.getComponentType();

    if (elementType.isCategory2()) {
        return throwBadType(arrayType);
    }

    if (count < 0) {
        throw new IllegalArgumentException("count < 0");
    }

    StdTypeList sourceTypes = new StdTypeList(count);

    for (int i = 0; i < count; i++) {
        sourceTypes.set(i, elementType);
    }

    // Note: The resulting rop is considered call-like.
    return new Rop(RegOps.FILLED_NEW_ARRAY,
                   sourceTypes,
                   Exceptions.LIST_Error);
}
 
Example 10
Source File: CodeObserver.java    From buck with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
public void visitLocal(int opcode, int offset, int length,
        int idx, Type type, int value) {
    String idxStr = (length <= 3) ? Hex.u1(idx) : Hex.u2(idx);
    boolean argComment = (length == 1);
    String valueStr = "";

    if (opcode == ByteOps.IINC) {
        valueStr = ", #" +
            ((length <= 3) ? Hex.s1(value) : Hex.s2(value));
    }

    String catStr = "";
    if (type.isCategory2()) {
        catStr = (argComment ? "," : " //") + " category-2";
    }

    observer.parsed(bytes, offset, length,
                    header(offset) + (argComment ? " // " : " ") +
                    idxStr + valueStr + catStr);
}
 
Example 11
Source File: Rops.java    From buck with Apache License 2.0 6 votes vote down vote up
/**
 * Returns the appropriate {@code filled-new-array} rop for the given
 * type. The result may be a shared instance.
 *
 * @param arrayType {@code non-null;} type of array being created
 * @param count {@code >= 0;} number of elements that the array should have
 * @return {@code non-null;} an appropriate instance
 */
public static Rop opFilledNewArray(TypeBearer arrayType, int count) {
    Type type = arrayType.getType();
    Type elementType = type.getComponentType();

    if (elementType.isCategory2()) {
        return throwBadType(arrayType);
    }

    if (count < 0) {
        throw new IllegalArgumentException("count < 0");
    }

    StdTypeList sourceTypes = new StdTypeList(count);

    for (int i = 0; i < count; i++) {
        sourceTypes.set(i, elementType);
    }

    // Note: The resulting rop is considered call-like.
    return new Rop(RegOps.FILLED_NEW_ARRAY,
                   sourceTypes,
                   Exceptions.LIST_Error);
}
 
Example 12
Source File: OneLocalsArray.java    From buck with Apache License 2.0 5 votes vote down vote up
/** {@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;
}