public void writeStringData(String value) { try { int length = value.length(); writeUleb128(length); write(Mutf8.encode(value)); writeByte(0); } catch (UTFDataFormatException e) { throw new AssertionError(); } }
codeOut.writeUleb128(catchHandlers.length); for (Code.CatchHandler catchHandler : catchHandlers) { transformEncodedCatchHandler(catchHandler, 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 transformClassData(DexBuffer 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 transformMethods(DexBuffer 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.alignToFourBytes(); classDataOut.writeUleb128(codeOut.getPosition()); transformCode(in, in.readCode(method), indexMap); } } }
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()); } }
public void writeTo(DexBuffer.Section out) { out.writeByte(visibility); out.writeUleb128(typeIndex); out.writeUleb128(names.length); for (int i = 0; i < names.length; i++) { out.writeUleb128(names[i]); values[i].writeTo(out); } }