private void writeCallSites(DexDataWriter writer) throws IOException { callSiteSectionOffset = writer.getPosition(); List<Map.Entry<? extends CallSiteKey, Integer>> callSiteEntries = Lists.newArrayList(callSiteSection.getItems()); Collections.sort(callSiteEntries, callSiteComparator); int index = 0; for (Map.Entry<? extends CallSiteKey, Integer> callSite: callSiteEntries) { callSite.setValue(index++); writer.writeInt(encodedArraySection.getItemOffset(callSiteSection.getEncodedCallSite(callSite.getKey()))); } }
private int getDataSectionOffset() { return HeaderItem.ITEM_SIZE + stringSection.getItemCount() * StringIdItem.ITEM_SIZE + typeSection.getItemCount() * TypeIdItem.ITEM_SIZE + protoSection.getItemCount() * ProtoIdItem.ITEM_SIZE + fieldSection.getItemCount() * FieldIdItem.ITEM_SIZE + methodSection.getItemCount() * MethodIdItem.ITEM_SIZE + classSection.getItemCount() * ClassDefItem.ITEM_SIZE + callSiteSection.getItemCount() * CallSiteIdItem.ITEM_SIZE + methodHandleSection.getItemCount() * MethodHandleItem.ITEM_SIZE; }
numItems++; if (callSiteSection.getItems().size() > 0) { numItems++;
@Override public int compare(Entry<? extends CallSiteKey, Integer> o1, Entry<? extends CallSiteKey, Integer> o2) { int offset1 = encodedArraySection.getItemOffset(callSiteSection.getEncodedCallSite(o1.getKey())); int offset2 = encodedArraySection.getItemOffset(callSiteSection.getEncodedCallSite(o2.getKey())); return Ints.compare(offset1, offset2); } };
private int getReferenceIndex(int referenceType, Reference reference) { switch (referenceType) { case ReferenceType.FIELD: return fieldSection.getItemIndex((FieldRefKey) reference); case ReferenceType.METHOD: return methodSection.getItemIndex((MethodRefKey) reference); case ReferenceType.STRING: return stringSection.getItemIndex((StringRef) reference); case ReferenceType.TYPE: return typeSection.getItemIndex((TypeRef) reference); case ReferenceType.METHOD_PROTO: return protoSection.getItemIndex((ProtoRefKey) reference); case ReferenceType.METHOD_HANDLE: return methodHandleSection.getItemIndex((MethodHandleKey) reference); case ReferenceType.CALL_SITE: return callSiteSection.getItemIndex((CallSiteKey) reference); default: throw new ExceptionWithContext("Unknown reference type: %d", referenceType); } } }
writeMapItem(writer, ItemType.METHOD_ID_ITEM, methodSection.getItems().size(), methodSectionOffset); writeMapItem(writer, ItemType.CLASS_DEF_ITEM, classSection.getItems().size(), classIndexSectionOffset); writeMapItem(writer, ItemType.CALL_SITE_ID_ITEM, callSiteSection.getItems().size(), callSiteSectionOffset); writeMapItem(writer, ItemType.METHOD_HANDLE_ITEM, methodHandleSection.getItems().size(), methodHandleSectionOffset);
@Override public int compare(Entry<? extends CallSiteKey, Integer> o1, Entry<? extends CallSiteKey, Integer> o2) { int offset1 = encodedArraySection.getItemOffset(callSiteSection.getEncodedCallSite(o1.getKey())); int offset2 = encodedArraySection.getItemOffset(callSiteSection.getEncodedCallSite(o2.getKey())); return Ints.compare(offset1, offset2); } };
private int getReferenceIndex(int referenceType, Reference reference) { switch (referenceType) { case ReferenceType.FIELD: return fieldSection.getItemIndex((FieldRefKey) reference); case ReferenceType.METHOD: return methodSection.getItemIndex((MethodRefKey) reference); case ReferenceType.STRING: return stringSection.getItemIndex((StringRef) reference); case ReferenceType.TYPE: return typeSection.getItemIndex((TypeRef) reference); case ReferenceType.METHOD_PROTO: return protoSection.getItemIndex((ProtoRefKey) reference); case ReferenceType.METHOD_HANDLE: return methodHandleSection.getItemIndex((MethodHandleKey) reference); case ReferenceType.CALL_SITE: return callSiteSection.getItemIndex((CallSiteKey) reference); default: throw new ExceptionWithContext("Unknown reference type: %d", referenceType); } } }
private void writeCallSites(DexDataWriter writer) throws IOException { callSiteSectionOffset = writer.getPosition(); List<Map.Entry<? extends CallSiteKey, Integer>> callSiteEntries = Lists.newArrayList(callSiteSection.getItems()); Collections.sort(callSiteEntries, callSiteComparator); int index = 0; for (Map.Entry<? extends CallSiteKey, Integer> callSite: callSiteEntries) { callSite.setValue(index++); writer.writeInt(encodedArraySection.getItemOffset(callSiteSection.getEncodedCallSite(callSite.getKey()))); } }
callSiteSection.getItemCount() * CallSiteIdItem.ITEM_SIZE); try { writeMethodHandles(methodHandleWriter);
numItems++; if (callSiteSection.getItems().size() > 0) { numItems++;
private int getDataSectionOffset() { return HeaderItem.ITEM_SIZE + stringSection.getItemCount() * StringIdItem.ITEM_SIZE + typeSection.getItemCount() * TypeIdItem.ITEM_SIZE + protoSection.getItemCount() * ProtoIdItem.ITEM_SIZE + fieldSection.getItemCount() * FieldIdItem.ITEM_SIZE + methodSection.getItemCount() * MethodIdItem.ITEM_SIZE + classSection.getItemCount() * ClassDefItem.ITEM_SIZE + callSiteSection.getItemCount() * CallSiteIdItem.ITEM_SIZE + methodHandleSection.getItemCount() * MethodHandleItem.ITEM_SIZE; }
writeMapItem(writer, ItemType.METHOD_ID_ITEM, methodSection.getItems().size(), methodSectionOffset); writeMapItem(writer, ItemType.CLASS_DEF_ITEM, classSection.getItems().size(), classIndexSectionOffset); writeMapItem(writer, ItemType.CALL_SITE_ID_ITEM, callSiteSection.getItems().size(), callSiteSectionOffset); writeMapItem(writer, ItemType.METHOD_HANDLE_ITEM, methodHandleSection.getItems().size(), methodHandleSectionOffset);
callSiteSection.getItemCount() * CallSiteIdItem.ITEM_SIZE); try { writeMethodHandles(methodHandleWriter);