/** * Calculates the size of this <code>EncodedMethod</code> and returns the offset immediately * following it * * @param offset the offset of this <code>EncodedMethod</code> in the <code>DexFile</code> * @param previousEncodedMethod The previous <code>EncodedMethod</code> in the list containing * this <code>EncodedMethod</code>. * @return the offset immediately following this <code>EncodedField</code> */ private int place(int offset, EncodedMethod previousEncodedMethod) { int previousIndex = previousEncodedMethod == null ? 0 : previousEncodedMethod.method.getIndex(); offset += Leb128Utils.unsignedLeb128Size(method.getIndex() - previousIndex); offset += Leb128Utils.unsignedLeb128Size(accessFlags); offset += codeItem == null ? 1 : Leb128Utils.unsignedLeb128Size(codeItem.getOffset()); return offset; }
/** * Writes the <code>EncodedMethod</code> to the given <code>AnnotatedOutput</code> object * * @param out the <code>AnnotatedOutput</code> object to write to * @param previousEncodedMethod The previous <code>EncodedMethod</code> in the list containing * this <code>EncodedMethod</code>. */ private void writeTo(AnnotatedOutput out, EncodedMethod previousEncodedMethod) { int previousIndex = previousEncodedMethod == null ? 0 : previousEncodedMethod.method.getIndex(); if (out.annotates()) { out.annotate("method: " + method.getMethodString()); out.writeUnsignedLeb128(method.getIndex() - previousIndex); out.annotate("access_flags: " + AccessFlags.formatAccessFlagsForMethod(accessFlags)); out.writeUnsignedLeb128(accessFlags); if (codeItem != null) { out.annotate("code_off: 0x" + Integer.toHexString(codeItem.getOffset())); out.writeUnsignedLeb128(codeItem.getOffset()); } else { out.annotate("code_off: 0x0"); out.writeUnsignedLeb128(0); } } else { out.writeUnsignedLeb128(method.getIndex() - previousIndex); out.writeUnsignedLeb128(accessFlags); out.writeUnsignedLeb128(codeItem == null ? 0 : codeItem.getOffset()); } }