/** * Look up a method id declaring class index from a method index. Cheaper than: * {@code methodIds().get(methodIndex).getDeclaringClassIndex();} */ public int declaringClassIndexFromMethodIndex(int methodIndex) { checkBounds(methodIndex, tableOfContents.methodIds.size); int position = tableOfContents.methodIds.off + (SizeOf.MEMBER_ID_ITEM * methodIndex); return data.getShort(position) & 0xFFFF; // declaringClassIndex }
/** * Look up a method id name index from a method index. Cheaper than: * {@code methodIds().get(methodIndex).getNameIndex();} */ public int nameIndexFromMethodIndex(int methodIndex) { checkBounds(methodIndex, tableOfContents.methodIds.size); int position = tableOfContents.methodIds.off + (SizeOf.MEMBER_ID_ITEM * methodIndex); position += SizeOf.USHORT; // declaringClassIndex position += SizeOf.USHORT; // protoIndex return data.getInt(position); // nameIndex }
/** * Look up a type index index from a class def index. */ public int typeIndexFromClassDefIndex(int classDefIndex) { checkBounds(classDefIndex, tableOfContents.classDefs.size); int position = tableOfContents.classDefs.off + (SizeOf.CLASS_DEF_ITEM * classDefIndex); return data.getInt(position); }
/** * Look up a field id name index from a field index. Cheaper than: * {@code fieldIds().get(fieldDexIndex).getNameIndex();} */ public int nameIndexFromFieldIndex(int fieldIndex) { checkBounds(fieldIndex, tableOfContents.fieldIds.size); int position = tableOfContents.fieldIds.off + (SizeOf.MEMBER_ID_ITEM * fieldIndex); position += SizeOf.USHORT; // declaringClassIndex position += SizeOf.USHORT; // typeIndex return data.getInt(position); // nameIndex }
/** * Look up a field id type index from a field index. Cheaper than: * {@code fieldIds().get(fieldDexIndex).getTypeIndex();} */ public int typeIndexFromFieldIndex(int fieldIndex) { checkBounds(fieldIndex, tableOfContents.fieldIds.size); int position = tableOfContents.fieldIds.off + (SizeOf.MEMBER_ID_ITEM * fieldIndex); position += SizeOf.USHORT; // declaringClassIndex return data.getShort(position) & 0xFFFF; // typeIndex }
/** * Look up a descriptor index from a type index. Cheaper than: * {@code openSection(tableOfContents.typeIds.off + (index * SizeOf.TYPE_ID_ITEM)).readInt();} */ public int descriptorIndexFromTypeIndex(int typeIndex) { checkBounds(typeIndex, tableOfContents.typeIds.size); int position = tableOfContents.typeIds.off + (SizeOf.TYPE_ID_ITEM * typeIndex); return data.getInt(position); }
/** * Look up an annotation directory offset from a class def index. */ public int annotationDirectoryOffsetFromClassDefIndex(int classDefIndex) { checkBounds(classDefIndex, tableOfContents.classDefs.size); int position = tableOfContents.classDefs.off + (SizeOf.CLASS_DEF_ITEM * classDefIndex); position += SizeOf.UINT; // type position += SizeOf.UINT; // accessFlags position += SizeOf.UINT; // superType position += SizeOf.UINT; // interfacesOffset position += SizeOf.UINT; // sourceFileIndex return data.getInt(position); }
/** * Look up a method id return type index from a method index. Cheaper than: * {@code protoIds().get(methodIds().get(methodDexIndex).getProtoIndex()).getReturnTypeIndex();} */ public int returnTypeIndexFromMethodIndex(int methodIndex) { checkBounds(methodIndex, tableOfContents.methodIds.size); int position = tableOfContents.methodIds.off + (SizeOf.MEMBER_ID_ITEM * methodIndex); position += SizeOf.USHORT; // declaringClassIndex int protoIndex = data.getShort(position) & 0xFFFF; checkBounds(protoIndex, tableOfContents.protoIds.size); position = tableOfContents.protoIds.off + (SizeOf.PROTO_ID_ITEM * protoIndex); position += SizeOf.UINT; // shortyIndex return data.getInt(position); // returnTypeIndex }
/** * Look up a parameter type ids from a method index. Cheaper than: * {@code readTypeList(protoIds.get(methodIds().get(methodDexIndex).getProtoIndex()).getParametersOffset()).getTypes();} */ public short[] parameterTypeIndicesFromMethodIndex(int methodIndex) { checkBounds(methodIndex, tableOfContents.methodIds.size); int position = tableOfContents.methodIds.off + (SizeOf.MEMBER_ID_ITEM * methodIndex); position += SizeOf.USHORT; // declaringClassIndex int protoIndex = data.getShort(position) & 0xFFFF; checkBounds(protoIndex, tableOfContents.protoIds.size); position = tableOfContents.protoIds.off + (SizeOf.PROTO_ID_ITEM * protoIndex); position += SizeOf.UINT; // shortyIndex position += SizeOf.UINT; // returnTypeIndex int parametersOffset = data.getInt(position); if (parametersOffset == 0) { return EMPTY_SHORT_ARRAY; } position = parametersOffset; int size = data.getInt(position); if (size <= 0) { throw new AssertionError("Unexpected parameter type list size: " + size); } position += SizeOf.UINT; short[] types = new short[size]; for (int i = 0; i < size; i++) { types[i] = data.getShort(position); position += SizeOf.USHORT; } return types; }
/** * Look up a parameter type ids from a methodId. Cheaper than: * {@code readTypeList(protoIds.get(methodIds().get(methodDexIndex).getProtoIndex()).getParametersOffset()).getTypes();} */ public short[] parameterTypeIndicesFromMethodId(MethodId methodId) { int protoIndex = methodId.protoIndex & 0xFFFF; checkBounds(protoIndex, tableOfContents.protoIds.size); int position = tableOfContents.protoIds.off + (SizeOf.PROTO_ID_ITEM * protoIndex); position += SizeOf.UINT; // shortyIndex position += SizeOf.UINT; // returnTypeIndex int parametersOffset = data.getInt(position); if (parametersOffset == 0) { return EMPTY_SHORT_ARRAY; } position = parametersOffset; int size = data.getInt(position); if (size <= 0) { throw new AssertionError("Unexpected parameter type list size: " + size); } position += SizeOf.UINT; short[] types = new short[size]; for (int i = 0; i < size; i++) { types[i] = data.getShort(position); position += SizeOf.USHORT; } return types; }
/** * Look up interface types indices from a return type index from a method index. Cheaper than: * {@code ...getClassDef(classDefIndex).getInterfaces();} */ public short[] interfaceTypeIndicesFromClassDefIndex(int classDefIndex) { checkBounds(classDefIndex, tableOfContents.classDefs.size); int position = tableOfContents.classDefs.off + (SizeOf.CLASS_DEF_ITEM * classDefIndex); position += SizeOf.UINT; // type position += SizeOf.UINT; // accessFlags position += SizeOf.UINT; // superType int interfacesOffset = data.getInt(position); if (interfacesOffset == 0) { return EMPTY_SHORT_ARRAY; } position = interfacesOffset; int size = data.getInt(position); if (size <= 0) { throw new AssertionError("Unexpected interfaces list size: " + size); } position += SizeOf.UINT; short[] types = new short[size]; for (int i = 0; i < size; i++) { types[i] = data.getShort(position); position += SizeOf.USHORT; } return types; }
public int findClassDefIndexFromTypeIndex(int typeIndex) { checkBounds(typeIndex, tableOfContents.typeIds.size); if (!tableOfContents.classDefs.exists()) { return -1; } for (int i = 0; i < tableOfContents.classDefs.size; i++) { if (typeIndexFromClassDefIndex(i) == typeIndex) { return i; } } return -1; }
/** * Look up a method id declaring class index from a method index. Cheaper than: * {@code methodIds().get(methodIndex).getDeclaringClassIndex();} */ public int declaringClassIndexFromMethodIndex(int methodIndex) { checkBounds(methodIndex, tableOfContents.methodIds.size); int position = tableOfContents.methodIds.off + (SizeOf.MEMBER_ID_ITEM * methodIndex); return data.getShort(position) & 0xFFFF; // declaringClassIndex }
/** * Look up a field id name index from a field index. Cheaper than: * {@code fieldIds().get(fieldDexIndex).getNameIndex();} */ public int nameIndexFromFieldIndex(int fieldIndex) { checkBounds(fieldIndex, tableOfContents.fieldIds.size); int position = tableOfContents.fieldIds.off + (SizeOf.MEMBER_ID_ITEM * fieldIndex); position += SizeOf.USHORT; // declaringClassIndex position += SizeOf.USHORT; // typeIndex return data.getInt(position); // nameIndex }
/** * Look up a descriptor index from a type index. Cheaper than: * {@code openSection(tableOfContents.typeIds.off + (index * SizeOf.TYPE_ID_ITEM)).readInt();} */ public int descriptorIndexFromTypeIndex(int typeIndex) { checkBounds(typeIndex, tableOfContents.typeIds.size); int position = tableOfContents.typeIds.off + (SizeOf.TYPE_ID_ITEM * typeIndex); return data.getInt(position); }
/** * Look up a field id type index from a field index. Cheaper than: * {@code fieldIds().get(fieldDexIndex).getTypeIndex();} */ public int typeIndexFromFieldIndex(int fieldIndex) { checkBounds(fieldIndex, tableOfContents.fieldIds.size); int position = tableOfContents.fieldIds.off + (SizeOf.MEMBER_ID_ITEM * fieldIndex); position += SizeOf.USHORT; // declaringClassIndex return data.getShort(position) & 0xFFFF; // typeIndex }
/** * Look up a method id name index from a method index. Cheaper than: * {@code methodIds().get(methodIndex).getNameIndex();} */ public int nameIndexFromMethodIndex(int methodIndex) { checkBounds(methodIndex, tableOfContents.methodIds.size); int position = tableOfContents.methodIds.off + (SizeOf.MEMBER_ID_ITEM * methodIndex); position += SizeOf.USHORT; // declaringClassIndex position += SizeOf.USHORT; // protoIndex return data.getInt(position); // nameIndex }
/** * Look up a type index index from a class def index. */ public int typeIndexFromClassDefIndex(int classDefIndex) { checkBounds(classDefIndex, tableOfContents.classDefs.size); int position = tableOfContents.classDefs.off + (SizeOf.CLASS_DEF_ITEM * classDefIndex); return data.getInt(position); }
/** * Look up an annotation directory offset from a class def index. */ public int annotationDirectoryOffsetFromClassDefIndex(int classDefIndex) { checkBounds(classDefIndex, tableOfContents.classDefs.size); int position = tableOfContents.classDefs.off + (SizeOf.CLASS_DEF_ITEM * classDefIndex); position += SizeOf.UINT; // type position += SizeOf.UINT; // accessFlags position += SizeOf.UINT; // superType position += SizeOf.UINT; // interfacesOffset position += SizeOf.UINT; // sourceFileIndex return data.getInt(position); }
public int findClassDefIndexFromTypeIndex(int typeIndex) { checkBounds(typeIndex, tableOfContents.typeIds.size); if (!tableOfContents.classDefs.exists()) { return -1; } for (int i = 0; i < tableOfContents.classDefs.size; i++) { if (typeIndexFromClassDefIndex(i) == typeIndex) { return i; } } return -1; }