public void writeStringData(String value) { try { int length = value.length(); writeUleb128(length); write(Mutf8.encode(value)); writeByte(0); } catch (UTFDataFormatException e) { throw new AssertionError(); } }
public void writeStringData(String value) { try { int length = value.length(); writeUleb128(length); write(Mutf8.encode(value)); writeByte(0); } catch (UTFDataFormatException e) { throw new AssertionError(); } }
private void transformDebugInfoItem(Dex.Section in, IndexMap indexMap) { contentsOut.debugInfos.size++; int lineStart = in.readUleb128(); debugInfoOut.writeUleb128(lineStart); debugInfoOut.writeUleb128(parametersSize); debugInfoOut.writeUleb128(addrDiff); break; case DBG_START_LOCAL_EXTENDED: registerNum = in.readUleb128(); debugInfoOut.writeUleb128(registerNum); nameIndex = in.readUleb128p1(); debugInfoOut.writeUleb128p1(indexMap.adjustString(nameIndex)); case DBG_RESTART_LOCAL: registerNum = in.readUleb128(); debugInfoOut.writeUleb128(registerNum); break;
private void transformEncodedCatchHandler(Code.CatchHandler catchHandler, IndexMap indexMap) { int catchAllAddress = catchHandler.getCatchAllAddress(); int[] typeIndexes = catchHandler.getTypeIndexes(); int[] addresses = catchHandler.getAddresses(); if (catchAllAddress != -1) { codeOut.writeSleb128(-typeIndexes.length); } else { codeOut.writeSleb128(typeIndexes.length); } for (int i = 0; i < typeIndexes.length; i++) { codeOut.writeUleb128(indexMap.adjustType(typeIndexes[i])); codeOut.writeUleb128(addresses[i]); } if (catchAllAddress != -1) { codeOut.writeUleb128(catchAllAddress); } }
private void transformMethods(Dex in, IndexMap indexMap, ClassData.Method[] methods) { int lastOutMethodIndex = 0; for (ClassData.Method method : methods) { int outMethodIndex = indexMap.adjustMethod(method.getMethodIndex()); classDataOut.writeUleb128(outMethodIndex - lastOutMethodIndex); lastOutMethodIndex = outMethodIndex; classDataOut.writeUleb128(method.getAccessFlags()); if (method.getCodeOffset() == 0) { classDataOut.writeUleb128(0); } else { codeOut.alignToFourBytesWithZeroFill(); classDataOut.writeUleb128(codeOut.getPosition()); transformCode(in, in.readCode(method), indexMap); } } }
private void transformMethods(Dex in, IndexMap indexMap, ClassData.Method[] methods) { int lastOutMethodIndex = 0; for (ClassData.Method method : methods) { int outMethodIndex = indexMap.adjustMethod(method.getMethodIndex()); classDataOut.writeUleb128(outMethodIndex - lastOutMethodIndex); lastOutMethodIndex = outMethodIndex; classDataOut.writeUleb128(method.getAccessFlags()); if (method.getCodeOffset() == 0) { classDataOut.writeUleb128(0); } else { codeOut.alignToFourBytesWithZeroFill(); classDataOut.writeUleb128(codeOut.getPosition()); transformCode(in, in.readCode(method), indexMap); } } }
private void transformEncodedCatchHandler(Code.CatchHandler catchHandler, IndexMap indexMap) { int catchAllAddress = catchHandler.getCatchAllAddress(); int[] typeIndexes = catchHandler.getTypeIndexes(); int[] addresses = catchHandler.getAddresses(); if (catchAllAddress != -1) { codeOut.writeSleb128(-typeIndexes.length); } else { codeOut.writeSleb128(typeIndexes.length); } for (int i = 0; i < typeIndexes.length; i++) { codeOut.writeUleb128(indexMap.adjustType(typeIndexes[i])); codeOut.writeUleb128(addresses[i]); } if (catchAllAddress != -1) { codeOut.writeUleb128(catchAllAddress); } }
private void transformEncodedCatchHandler(Code.CatchHandler catchHandler, IndexMap indexMap) { int catchAllAddress = catchHandler.getCatchAllAddress(); int[] typeIndexes = catchHandler.getTypeIndexes(); int[] addresses = catchHandler.getAddresses(); if (catchAllAddress != -1) { codeOut.writeSleb128(-typeIndexes.length); } else { codeOut.writeSleb128(typeIndexes.length); } for (int i = 0; i < typeIndexes.length; i++) { codeOut.writeUleb128(indexMap.adjustType(typeIndexes[i])); codeOut.writeUleb128(addresses[i]); } if (catchAllAddress != -1) { codeOut.writeUleb128(catchAllAddress); } }
private void transformMethods(Dex in, IndexMap indexMap, ClassData.Method[] methods) { int lastOutMethodIndex = 0; for (ClassData.Method method : methods) { int outMethodIndex = indexMap.adjustMethod(method.getMethodIndex()); classDataOut.writeUleb128(outMethodIndex - lastOutMethodIndex); lastOutMethodIndex = outMethodIndex; classDataOut.writeUleb128(method.getAccessFlags()); if (method.getCodeOffset() == 0) { classDataOut.writeUleb128(0); } else { codeOut.alignToFourBytesWithZeroFill(); classDataOut.writeUleb128(codeOut.getPosition()); transformCode(in, in.readCode(method), indexMap); } } }
private void transformClassData(Dex in, ClassData classData, IndexMap indexMap) { contentsOut.classDatas.size++; ClassData.Field[] staticFields = classData.getStaticFields(); ClassData.Field[] instanceFields = classData.getInstanceFields(); ClassData.Method[] directMethods = classData.getDirectMethods(); ClassData.Method[] virtualMethods = classData.getVirtualMethods(); classDataOut.writeUleb128(staticFields.length); classDataOut.writeUleb128(instanceFields.length); classDataOut.writeUleb128(directMethods.length); classDataOut.writeUleb128(virtualMethods.length); transformFields(indexMap, staticFields); transformFields(indexMap, instanceFields); transformMethods(in, indexMap, directMethods); transformMethods(in, indexMap, virtualMethods); }
private void transformClassData(Dex in, ClassData classData, IndexMap indexMap) { contentsOut.classDatas.size++; ClassData.Field[] staticFields = classData.getStaticFields(); ClassData.Field[] instanceFields = classData.getInstanceFields(); ClassData.Method[] directMethods = classData.getDirectMethods(); ClassData.Method[] virtualMethods = classData.getVirtualMethods(); classDataOut.writeUleb128(staticFields.length); classDataOut.writeUleb128(instanceFields.length); classDataOut.writeUleb128(directMethods.length); classDataOut.writeUleb128(virtualMethods.length); transformFields(indexMap, staticFields); transformFields(indexMap, instanceFields); transformMethods(in, indexMap, directMethods); transformMethods(in, indexMap, virtualMethods); }
private void transformClassData(Dex in, ClassData classData, IndexMap indexMap) { contentsOut.classDatas.size++; ClassData.Field[] staticFields = classData.getStaticFields(); ClassData.Field[] instanceFields = classData.getInstanceFields(); ClassData.Method[] directMethods = classData.getDirectMethods(); ClassData.Method[] virtualMethods = classData.getVirtualMethods(); classDataOut.writeUleb128(staticFields.length); classDataOut.writeUleb128(instanceFields.length); classDataOut.writeUleb128(directMethods.length); classDataOut.writeUleb128(virtualMethods.length); transformFields(indexMap, staticFields); transformFields(indexMap, instanceFields); transformMethods(in, indexMap, directMethods); transformMethods(in, indexMap, virtualMethods); }
public void writeUleb128p1(int i) { writeUleb128(i + 1); }
public void writeUleb128p1(int i) { writeUleb128(i + 1); }
/** * 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; }
/** * 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; }
/** * 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; }
private void transformFields(IndexMap indexMap, ClassData.Field[] fields) { int lastOutFieldIndex = 0; for (ClassData.Field field : fields) { int outFieldIndex = indexMap.adjustField(field.getFieldIndex()); classDataOut.writeUleb128(outFieldIndex - lastOutFieldIndex); lastOutFieldIndex = outFieldIndex; classDataOut.writeUleb128(field.getAccessFlags()); } }
private void transformFields(IndexMap indexMap, ClassData.Field[] fields) { int lastOutFieldIndex = 0; for (ClassData.Field field : fields) { int outFieldIndex = indexMap.adjustField(field.getFieldIndex()); classDataOut.writeUleb128(outFieldIndex - lastOutFieldIndex); lastOutFieldIndex = outFieldIndex; classDataOut.writeUleb128(field.getAccessFlags()); } }
private void transformFields(IndexMap indexMap, ClassData.Field[] fields) { int lastOutFieldIndex = 0; for (ClassData.Field field : fields) { int outFieldIndex = indexMap.adjustField(field.getFieldIndex()); classDataOut.writeUleb128(outFieldIndex - lastOutFieldIndex); lastOutFieldIndex = outFieldIndex; classDataOut.writeUleb128(field.getAccessFlags()); } }