示例#1
0
    /**
     * Calculates the size of this <code>EncodedField</code> and returns the offset immediately
     * following it
     *
     * @param offset the offset of this <code>EncodedField</code> in the <code>DexFile</code>
     * @param previousEncodedField The previous <code>EncodedField</code> in the list containing
     *     this <code>EncodedField</code>.
     * @return the offset immediately following this <code>EncodedField</code>
     */
    private int place(int offset, EncodedField previousEncodedField) {
      int previousIndex = previousEncodedField == null ? 0 : previousEncodedField.field.getIndex();

      offset += Leb128Utils.unsignedLeb128Size(field.getIndex() - previousIndex);
      offset += Leb128Utils.unsignedLeb128Size(accessFlags);
      return offset;
    }
示例#2
0
  /** {@inheritDoc} */
  protected int placeItem(int offset) {
    offset += Leb128Utils.unsignedLeb128Size(staticFields.length);
    offset += Leb128Utils.unsignedLeb128Size(instanceFields.length);
    offset += Leb128Utils.unsignedLeb128Size(directMethods.length);
    offset += Leb128Utils.unsignedLeb128Size(virtualMethods.length);

    EncodedField previousEncodedField = null;
    for (EncodedField encodedField : staticFields) {
      offset = encodedField.place(offset, previousEncodedField);
      previousEncodedField = encodedField;
    }

    previousEncodedField = null;
    for (EncodedField encodedField : instanceFields) {
      offset = encodedField.place(offset, previousEncodedField);
      previousEncodedField = encodedField;
    }

    EncodedMethod previousEncodedMethod = null;
    for (EncodedMethod encodedMethod : directMethods) {
      offset = encodedMethod.place(offset, previousEncodedMethod);
      previousEncodedMethod = encodedMethod;
    }

    previousEncodedMethod = null;
    for (EncodedMethod encodedMethod : virtualMethods) {
      offset = encodedMethod.place(offset, previousEncodedMethod);
      previousEncodedMethod = encodedMethod;
    }

    return offset;
  }
示例#3
0
    /**
     * 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;
    }