private int readIntoMap(Dex.Section in, TableOfContents.Section section, IndexMap indexMap, int index, TreeMap<T, List<Integer>> values, int dex) { int offset = in != null ? in.getPosition() : -1; if (index < section.size) { T v = read(in, indexMap, index); List<Integer> l = values.get(v); if (l == null) { l = new ArrayList<Integer>(); values.put(v, l); } l.add(new Integer(dex)); } return offset; }
private List<UnsortedValue> readUnsortedValues(Dex source, IndexMap indexMap) { TableOfContents.Section section = getSection(source.getTableOfContents()); if (!section.exists()) { return Collections.emptyList(); } List<UnsortedValue> result = new ArrayList<UnsortedValue>(); Dex.Section in = source.open(section.off); for (int i = 0; i < section.size; i++) { int offset = in.getPosition(); T value = read(in, indexMap, 0); result.add(new UnsortedValue(source, indexMap, value, i, offset)); } return result; }
/** * Writes the catch handlers to {@code codeOut} and returns their indices. */ private int[] transformCatchHandlers(IndexMap indexMap, Code.CatchHandler[] catchHandlers) { int baseOffset = codeOut.getPosition(); codeOut.writeUleb128(catchHandlers.length); int[] offsets = new int[catchHandlers.length]; for (int i = 0; i < catchHandlers.length; i++) { offsets[i] = codeOut.getPosition() - baseOffset; transformEncodedCatchHandler(catchHandlers[i], indexMap); } return offsets; }
/** * Transform all annotations on a single type, member or parameter. */ private void transformAnnotationSet(IndexMap indexMap, Dex.Section setIn) { contentsOut.annotationSets.size++; annotationSetOut.assertFourByteAligned(); indexMap.putAnnotationSetOffset(setIn.getPosition(), annotationSetOut.getPosition()); int size = setIn.readInt(); annotationSetOut.writeInt(size); for (int j = 0; j < size; j++) { annotationSetOut.writeInt(indexMap.adjustAnnotation(setIn.readInt())); } }
public ClassDef readClassDef() { int offset = getPosition(); int type = readInt(); int accessFlags = readInt(); int supertype = readInt(); int interfacesOffset = readInt(); int sourceFileIndex = readInt(); int annotationsOffset = readInt(); int classDataOffset = readInt(); int staticValuesOffset = readInt(); return new ClassDef(Dex.this, offset, type, accessFlags, supertype, interfacesOffset, sourceFileIndex, annotationsOffset, classDataOffset, staticValuesOffset); }
@Override void updateIndex(int offset, IndexMap indexMap, int oldIndex, int newIndex) { indexMap.putTypeListOffset(offset, typeListOut.getPosition()); }
@Override void updateIndex(int offset, IndexMap indexMap, int oldIndex, int newIndex) { indexMap.putTypeListOffset(offset, typeListOut.getPosition()); }
public ClassDef readClassDef() { int offset = getPosition(); int type = readInt(); int accessFlags = readInt(); int supertype = readInt(); int interfacesOffset = readInt(); int sourceFileIndex = readInt(); int annotationsOffset = readInt(); int classDataOffset = readInt(); int staticValuesOffset = readInt(); return new ClassDef(Dex.this, offset, type, accessFlags, supertype, interfacesOffset, sourceFileIndex, annotationsOffset, classDataOffset, staticValuesOffset); }
@Override void updateIndex(int offset, IndexMap indexMap, int oldIndex, int newIndex) { indexMap.putTypeListOffset(offset, typeListOut.getPosition()); }
/** * Writes the catch handlers to {@code codeOut} and returns their indices. */ private int[] transformCatchHandlers(IndexMap indexMap, Code.CatchHandler[] catchHandlers) { int baseOffset = codeOut.getPosition(); codeOut.writeUleb128(catchHandlers.length); int[] offsets = new int[catchHandlers.length]; for (int i = 0; i < catchHandlers.length; i++) { offsets[i] = codeOut.getPosition() - baseOffset; transformEncodedCatchHandler(catchHandlers[i], indexMap); } return offsets; }
/** * Transform all annotations on a single type, member or parameter. */ private void transformAnnotationSet(IndexMap indexMap, Dex.Section setIn) { contentsOut.annotationSets.size++; annotationSetOut.assertFourByteAligned(); indexMap.putAnnotationSetOffset(setIn.getPosition(), annotationSetOut.getPosition()); int size = setIn.readInt(); annotationSetOut.writeInt(size); for (int j = 0; j < size; j++) { annotationSetOut.writeInt(indexMap.adjustAnnotation(setIn.readInt())); } }
private void transformStaticValues(Dex.Section in, IndexMap indexMap) { contentsOut.encodedArrays.size++; indexMap.putStaticValuesOffset(in.getPosition(), encodedArrayOut.getPosition()); indexMap.adjustEncodedArray(in.readEncodedArray()).writeTo(encodedArrayOut); }
private void mergeClassDefs() { SortableType[] types = getSortedTypes(); contentsOut.classDefs.off = idsDefsOut.getPosition(); contentsOut.classDefs.size = types.length; for (SortableType type : types) { Dex in = type.getDex(); IndexMap indexMap = (in == dexA) ? aIndexMap : bIndexMap; transformClassDef(in, type.getClassDef(), indexMap); } }
@Override void write(String value) { contentsOut.stringDatas.size++; idsDefsOut.writeInt(stringDataOut.getPosition()); stringDataOut.writeStringData(value); } }.mergeSorted();
@Override void write(String value) { contentsOut.stringDatas.size++; idsDefsOut.writeInt(stringDataOut.getPosition()); stringDataOut.writeStringData(value); } }.mergeSorted();
@Override void write(String value) { contentsOut.stringDatas.size++; idsDefsOut.writeInt(stringDataOut.getPosition()); stringDataOut.writeStringData(value); } }.mergeSorted();
private void transformStaticValues(Dex.Section in, IndexMap indexMap) { contentsOut.encodedArrays.size++; indexMap.putEncodedArrayValueOffset(in.getPosition(), encodedArrayOut.getPosition()); indexMap.adjustEncodedArray(in.readEncodedArray()).writeTo(encodedArrayOut); }
private void mergeClassDefs() { SortableType[] types = getSortedTypes(); contentsOut.classDefs.off = idsDefsOut.getPosition(); contentsOut.classDefs.size = types.length; for (SortableType type : types) { Dex in = type.getDex(); transformClassDef(in, type.getClassDef(), type.getIndexMap()); } }
private void transformStaticValues(Dex.Section in, IndexMap indexMap) { contentsOut.encodedArrays.size++; indexMap.putStaticValuesOffset(in.getPosition(), encodedArrayOut.getPosition()); indexMap.adjustEncodedArray(in.readEncodedArray()).writeTo(encodedArrayOut); }
private void mergeClassDefs() { SortableType[] types = getSortedTypes(); contentsOut.classDefs.off = idsDefsOut.getPosition(); contentsOut.classDefs.size = types.length; for (SortableType type : types) { Dex in = type.getDex(); transformClassDef(in, type.getClassDef(), type.getIndexMap()); } }