/** * Helper for {@link #writeConstant}, which writes out the value * for any unsigned integral type. * * @param type the type constant * @param value {@code long} bits of the value */ private void writeUnsignedIntegralValue(int type, long value) { // Figure out how many bits are needed to represent the value. int requiredBits = 64 - Long.numberOfLeadingZeros(value); if (requiredBits == 0) { requiredBits = 1; } // Round up the requiredBits to a number of bytes. int requiredBytes = (requiredBits + 0x07) >> 3; /* * Write the header byte, which includes the type and * requiredBytes - 1. */ out.writeByte(type | ((requiredBytes - 1) << 5)); // Write the value, per se. while (requiredBytes > 0) { out.writeByte((byte) value); value >>= 8; requiredBytes--; } }
/** * Helper for {@link #writeConstant}, which writes out a * right-zero-extended value. * * @param type the type constant * @param value {@code long} bits of the value */ private void writeRightZeroExtendedValue(int type, long value) { // Figure out how many bits are needed to represent the value. int requiredBits = 64 - Long.numberOfTrailingZeros(value); if (requiredBits == 0) { requiredBits = 1; } // Round up the requiredBits to a number of bytes. int requiredBytes = (requiredBits + 0x07) >> 3; // Scootch the first bits to be written down to the low-order bits. value >>= 64 - (requiredBytes * 8); /* * Write the header byte, which includes the type and * requiredBytes - 1. */ out.writeByte(type | ((requiredBytes - 1) << 5)); // Write the value, per se. while (requiredBytes > 0) { out.writeByte((byte) value); value >>= 8; requiredBytes--; } }
/** * Helper for {@link #writeConstant}, which writes out the value * for any unsigned integral type. * * @param type the type constant * @param value {@code long} bits of the value */ private void writeUnsignedIntegralValue(int type, long value) { // Figure out how many bits are needed to represent the value. int requiredBits = 64 - Long.numberOfLeadingZeros(value); if (requiredBits == 0) { requiredBits = 1; } // Round up the requiredBits to a number of bytes. int requiredBytes = (requiredBits + 0x07) >> 3; /* * Write the header byte, which includes the type and * requiredBytes - 1. */ out.writeByte(type | ((requiredBytes - 1) << 5)); // Write the value, per se. while (requiredBytes > 0) { out.writeByte((byte) value); value >>= 8; requiredBytes--; } }
/** * Helper for {@link #writeConstant}, which writes out the value * for any unsigned integral type. * * @param type the type constant * @param value {@code long} bits of the value */ private void writeUnsignedIntegralValue(int type, long value) { // Figure out how many bits are needed to represent the value. int requiredBits = 64 - Long.numberOfLeadingZeros(value); if (requiredBits == 0) { requiredBits = 1; } // Round up the requiredBits to a number of bytes. int requiredBytes = (requiredBits + 0x07) >> 3; /* * Write the header byte, which includes the type and * requiredBytes - 1. */ out.writeByte(type | ((requiredBytes - 1) << 5)); // Write the value, per se. while (requiredBytes > 0) { out.writeByte((byte) value); value >>= 8; requiredBytes--; } }
/** * Helper for {@link #writeConstant}, which writes out the value * for any unsigned integral type. * * @param type the type constant * @param value {@code long} bits of the value */ private void writeUnsignedIntegralValue(int type, long value) { // Figure out how many bits are needed to represent the value. int requiredBits = 64 - Long.numberOfLeadingZeros(value); if (requiredBits == 0) { requiredBits = 1; } // Round up the requiredBits to a number of bytes. int requiredBytes = (requiredBits + 0x07) >> 3; /* * Write the header byte, which includes the type and * requiredBytes - 1. */ out.writeByte(type | ((requiredBytes - 1) << 5)); // Write the value, per se. while (requiredBytes > 0) { out.writeByte((byte) value); value >>= 8; requiredBytes--; } }
/** * Helper for {@link #writeConstant}, which writes out a * right-zero-extended value. * * @param type the type constant * @param value {@code long} bits of the value */ private void writeRightZeroExtendedValue(int type, long value) { // Figure out how many bits are needed to represent the value. int requiredBits = 64 - Long.numberOfTrailingZeros(value); if (requiredBits == 0) { requiredBits = 1; } // Round up the requiredBits to a number of bytes. int requiredBytes = (requiredBits + 0x07) >> 3; // Scootch the first bits to be written down to the low-order bits. value >>= 64 - (requiredBytes * 8); /* * Write the header byte, which includes the type and * requiredBytes - 1. */ out.writeByte(type | ((requiredBytes - 1) << 5)); // Write the value, per se. while (requiredBytes > 0) { out.writeByte((byte) value); value >>= 8; requiredBytes--; } }
/** * Helper for {@link #writeConstant}, which writes out a * right-zero-extended value. * * @param type the type constant * @param value {@code long} bits of the value */ private void writeRightZeroExtendedValue(int type, long value) { // Figure out how many bits are needed to represent the value. int requiredBits = 64 - Long.numberOfTrailingZeros(value); if (requiredBits == 0) { requiredBits = 1; } // Round up the requiredBits to a number of bytes. int requiredBytes = (requiredBits + 0x07) >> 3; // Scootch the first bits to be written down to the low-order bits. value >>= 64 - (requiredBytes * 8); /* * Write the header byte, which includes the type and * requiredBytes - 1. */ out.writeByte(type | ((requiredBytes - 1) << 5)); // Write the value, per se. while (requiredBytes > 0) { out.writeByte((byte) value); value >>= 8; requiredBytes--; } }
/** {@inheritDoc} */ @Override public void writeTo0(DexFile file, AnnotatedOutput out) { ByteArray bytes = value.getBytes(); int utf16Size = value.getUtf16Size(); if (out.annotates()) { out.annotate(Leb128.unsignedLeb128Size(utf16Size), "utf16_size: " + Hex.u4(utf16Size)); out.annotate(bytes.size() + 1, value.toQuoted()); } out.writeUleb128(utf16Size); out.write(bytes); out.writeByte(0); }
/** {@inheritDoc} */ @Override public void writeTo0(DexFile file, AnnotatedOutput out) { ByteArray bytes = value.getBytes(); int utf16Size = value.getUtf16Size(); if (out.annotates()) { out.annotate(Leb128Utils.unsignedLeb128Size(utf16Size), "utf16_size: " + Hex.u4(utf16Size)); out.annotate(bytes.size() + 1, value.toQuoted()); } out.writeUleb128(utf16Size); out.write(bytes); out.writeByte(0); }
/** {@inheritDoc} */ @Override public void writeTo0(DexFile file, AnnotatedOutput out) { ByteArray bytes = value.getBytes(); int utf16Size = value.getUtf16Size(); if (out.annotates()) { out.annotate(Leb128Utils.unsignedLeb128Size(utf16Size), "utf16_size: " + Hex.u4(utf16Size)); out.annotate(bytes.size() + 1, value.toQuoted()); } out.writeUleb128(utf16Size); out.write(bytes); out.writeByte(0); }
/** {@inheritDoc} */ @Override public void writeTo0(DexFile file, AnnotatedOutput out) { ByteArray bytes = value.getBytes(); int utf16Size = value.getUtf16Size(); if (out.annotates()) { out.annotate(Leb128Utils.unsignedLeb128Size(utf16Size), "utf16_size: " + Hex.u4(utf16Size)); out.annotate(bytes.size() + 1, value.toQuoted()); } out.writeUleb128(utf16Size); out.write(bytes); out.writeByte(0); }
/** {@inheritDoc} */ @Override public void writeTo0(DexFile file, AnnotatedOutput out) { ByteArray bytes = value.getBytes(); int utf16Size = value.getUtf16Size(); if (out.annotates()) { out.annotate(Leb128.unsignedLeb128Size(utf16Size), "utf16_size: " + Hex.u4(utf16Size)); out.annotate(bytes.size() + 1, value.toQuoted()); } out.writeUleb128(utf16Size); out.write(bytes); out.writeByte(0); }
/** {@inheritDoc} */ @Override public void writeTo0(DexFile file, AnnotatedOutput out) { ByteArray bytes = value.getBytes(); int utf16Size = value.getUtf16Size(); if (out.annotates()) { out.annotate(Leb128Utils.unsignedLeb128Size(utf16Size), "utf16_size: " + Hex.u4(utf16Size)); out.annotate(bytes.size() + 1, value.toQuoted()); } out.writeUnsignedLeb128(utf16Size); out.write(bytes); out.writeByte(0); }
/** {@inheritDoc} */ @Override public void writeTo0(DexFile file, AnnotatedOutput out) { ByteArray bytes = value.getBytes(); int utf16Size = value.getUtf16Size(); if (out.annotates()) { out.annotate(Leb128.unsignedLeb128Size(utf16Size), "utf16_size: " + Hex.u4(utf16Size)); out.annotate(bytes.size() + 1, value.toQuoted()); } out.writeUleb128(utf16Size); out.write(bytes); out.writeByte(0); }
/** {@inheritDoc} */ @Override public void writeTo0(DexFile file, AnnotatedOutput out) { ByteArray bytes = value.getBytes(); int utf16Size = value.getUtf16Size(); if (out.annotates()) { out.annotate(Leb128.unsignedLeb128Size(utf16Size), "utf16_size: " + Hex.u4(utf16Size)); out.annotate(bytes.size() + 1, value.toQuoted()); } out.writeUleb128(utf16Size); out.write(bytes); out.writeByte(0); }