Java Code Examples for com.android.dex.ClassDef#NO_INDEX

The following examples show how to use com.android.dex.ClassDef#NO_INDEX . 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: SortableType.java    From Box with Apache License 2.0 5 votes vote down vote up
/**
 * Assigns this type's depth if the depths of its supertype and implemented
 * interfaces are known. Returns false if the depth couldn't be computed
 * yet.
 */
public boolean tryAssignDepth(SortableType[] types) {
    int max;
    if (classDef.getSupertypeIndex() == ClassDef.NO_INDEX) {
        max = 0; // this is Object.class or an interface
    } else if (classDef.getSupertypeIndex() == classDef.getTypeIndex()) {
        // This is an invalid class extending itself.
        throw new DexException("Class with type index " + classDef.getTypeIndex()
                + " extends itself");
    } else {
        SortableType sortableSupertype = types[classDef.getSupertypeIndex()];
        if (sortableSupertype == null) {
            max = 1; // unknown, so assume it's a root.
        } else if (sortableSupertype.depth == -1) {
            return false;
        } else {
            max = sortableSupertype.depth;
        }
    }

    for (short interfaceIndex : classDef.getInterfaces()) {
        SortableType implemented = types[interfaceIndex];
        if (implemented == null) {
            max = Math.max(max, 1); // unknown, so assume it's a root.
        } else if (implemented.depth == -1) {
            return false;
        } else {
            max = Math.max(max, implemented.depth);
        }
    }

    depth = max + 1;
    return true;
}
 
Example 2
Source File: SortableType.java    From Box with Apache License 2.0 5 votes vote down vote up
/**
 * Assigns this type's depth if the depths of its supertype and implemented
 * interfaces are known. Returns false if the depth couldn't be computed
 * yet.
 */
public boolean tryAssignDepth(SortableType[] types) {
    int max;
    if (classDef.getSupertypeIndex() == ClassDef.NO_INDEX) {
        max = 0; // this is Object.class or an interface
    } else if (classDef.getSupertypeIndex() == classDef.getTypeIndex()) {
        // This is an invalid class extending itself.
        throw new DexException("Class with type index " + classDef.getTypeIndex()
                + " extends itself");
    } else {
        SortableType sortableSupertype = types[classDef.getSupertypeIndex()];
        if (sortableSupertype == null) {
            max = 1; // unknown, so assume it's a root.
        } else if (sortableSupertype.depth == -1) {
            return false;
        } else {
            max = sortableSupertype.depth;
        }
    }

    for (short interfaceIndex : classDef.getInterfaces()) {
        SortableType implemented = types[interfaceIndex];
        if (implemented == null) {
            max = Math.max(max, 1); // unknown, so assume it's a root.
        } else if (implemented.depth == -1) {
            return false;
        } else {
            max = Math.max(max, implemented.depth);
        }
    }

    depth = max + 1;
    return true;
}
 
Example 3
Source File: SortableType.java    From buck with Apache License 2.0 5 votes vote down vote up
/**
 * Assigns this type's depth if the depths of its supertype and implemented
 * interfaces are known. Returns false if the depth couldn't be computed
 * yet.
 */
public boolean tryAssignDepth(SortableType[] types) {
    int max;
    if (classDef.getSupertypeIndex() == ClassDef.NO_INDEX) {
        max = 0; // this is Object.class or an interface
    } else {
        SortableType sortableSupertype = types[classDef.getSupertypeIndex()];
        if (sortableSupertype == null) {
            max = 1; // unknown, so assume it's a root.
        } else if (sortableSupertype.depth == -1) {
            return false;
        } else {
            max = sortableSupertype.depth;
        }
    }

    for (short interfaceIndex : classDef.getInterfaces()) {
        SortableType implemented = types[interfaceIndex];
        if (implemented == null) {
            max = Math.max(max, 1); // unknown, so assume it's a root.
        } else if (implemented.depth == -1) {
            return false;
        } else {
            max = Math.max(max, implemented.depth);
        }
    }

    depth = max + 1;
    return true;
}
 
Example 4
Source File: IndexMap.java    From Box with Apache License 2.0 4 votes vote down vote up
public int adjustString(int stringIndex) {
    return stringIndex == ClassDef.NO_INDEX ? ClassDef.NO_INDEX : stringIds[stringIndex];
}
 
Example 5
Source File: IndexMap.java    From Box with Apache License 2.0 4 votes vote down vote up
public int adjustType(int typeIndex) {
    return (typeIndex == ClassDef.NO_INDEX) ? ClassDef.NO_INDEX : (typeIds[typeIndex] & 0xffff);
}
 
Example 6
Source File: IndexMap.java    From Box with Apache License 2.0 4 votes vote down vote up
public int adjustString(int stringIndex) {
    return stringIndex == ClassDef.NO_INDEX ? ClassDef.NO_INDEX : stringIds[stringIndex];
}
 
Example 7
Source File: IndexMap.java    From Box with Apache License 2.0 4 votes vote down vote up
public int adjustType(int typeIndex) {
    return (typeIndex == ClassDef.NO_INDEX) ? ClassDef.NO_INDEX : (typeIds[typeIndex] & 0xffff);
}
 
Example 8
Source File: IndexMap.java    From buck with Apache License 2.0 4 votes vote down vote up
public int adjustString(int stringIndex) {
    return stringIndex == ClassDef.NO_INDEX ? ClassDef.NO_INDEX : stringIds[stringIndex];
}
 
Example 9
Source File: IndexMap.java    From buck with Apache License 2.0 4 votes vote down vote up
public int adjustType(int typeIndex) {
    return (typeIndex == ClassDef.NO_INDEX) ? ClassDef.NO_INDEX : (typeIds[typeIndex] & 0xffff);
}