private void ensureCapacity(int size) { if (position + size > limit) { throw new DexException("Section limit " + limit + " exceeded by " + name); } }
private static void jumboCheck(int oldIndex, int newIndex) { if ((oldIndex <= 0xffff) && (newIndex > 0xffff)) { throw new DexException("Cannot handle conversion to jumbo index!"); } } }
/** * Gets the literal value, masked to be a byte in size. This will * throw if the value is out of the range of a signed byte. */ public final int getLiteralByte() { if (literal != (byte) literal) { throw new DexException("Literal out of range: " + Hex.u8(literal)); } return (int) literal & 0xff; }
/** * Gets the literal value, as a code unit. This will throw if the * value is out of the range of a signed code unit. */ public final short getLiteralUnit() { if (literal != (short) literal) { throw new DexException("Literal out of range: " + Hex.u8(literal)); } return (short) literal; }
/** * Gets the B register number, as a nibble. This will throw if the * value is out of the range of an unsigned nibble. */ public final short getBNibble() { int b = getB(); if ((b & ~0xf) != 0) { throw new DexException("Register B out of range: " + Hex.u8(b)); } return (short) b; }
/** * Gets the C register number, as a nibble. This will throw if the * value is out of the range of an unsigned nibble. */ public final short getCNibble() { int c = getC(); if ((c & ~0xf) != 0) { throw new DexException("Register C out of range: " + Hex.u8(c)); } return (short) c; }
/** * Gets the C register number, as a code unit. This will throw if the * value is out of the range of an unsigned code unit. */ public final short getCUnit() { int c = getC(); if ((c & ~0xffff) != 0) { throw new DexException("Register C out of range: " + Hex.u8(c)); } return (short) c; }
/** * Gets the D register number, as a code unit. This will throw if the * value is out of the range of an unsigned code unit. */ public final short getDUnit() { int d = getD(); if ((d & ~0xffff) != 0) { throw new DexException("Register D out of range: " + Hex.u8(d)); } return (short) d; }
/** * Gets the E register number, as a nibble. This will throw if the * value is out of the range of an unsigned nibble. */ public final short getENibble() { int e = getE(); if ((e & ~0xf) != 0) { throw new DexException("Register E out of range: " + Hex.u8(e)); } return (short) e; }
public void writeUleb128(int i) { try { Leb128Utils.writeUnsignedLeb128(this, i); ensureCapacity(0); } catch (ArrayIndexOutOfBoundsException e) { throw new DexException("Section limit " + limit + " exceeded by " + name); } }
/** * Gets the register count, as a code unit. This will throw if the * value is out of the range of an unsigned code unit. */ public final short getRegisterCountUnit() { int registerCount = getRegisterCount(); if ((registerCount & ~0xffff) != 0) { throw new DexException("Register count out of range: " + Hex.u8(registerCount)); } return (short) registerCount; }
/** * Gets the A register number, as a code unit. This will throw if the * value is out of the range of an unsigned code unit. */ public final short getAUnit() { int a = getA(); if ((a & ~0xffff) != 0) { throw new DexException("Register A out of range: " + Hex.u8(a)); } return (short) a; }
/** * Gets the C register number, as a byte. This will throw if the * value is out of the range of an unsigned byte. */ public final short getCByte() { int c = getC(); if ((c & ~0xff) != 0) { throw new DexException("Register C out of range: " + Hex.u8(c)); } return (short) c; }
/** * Gets the A register number, as a code unit. This will throw if the * value is out of the range of an unsigned code unit. */ public final short getAUnit() { int a = getA(); if ((a & ~0xffff) != 0) { throw new DexException("Register A out of range: " + Hex.u8(a)); } return (short) a; }
/** * Gets the B register number, as a byte. This will throw if the * value is out of the range of an unsigned byte. */ public final short getBByte() { int b = getB(); if ((b & ~0xff) != 0) { throw new DexException("Register B out of range: " + Hex.u8(b)); } return (short) b; }
/** * Gets the D register number, as a nibble. This will throw if the * value is out of the range of an unsigned nibble. */ public final short getDNibble() { int d = getD(); if ((d & ~0xf) != 0) { throw new DexException("Register D out of range: " + Hex.u8(d)); } return (short) d; }
/** * Gets the target as a relative offset from the given base * address, masked to be a byte in size. This will throw if the * value is out of the range of a signed byte. */ public final int getTargetByte(int baseAddress) { int relativeTarget = getTarget(baseAddress); if (relativeTarget != (byte) relativeTarget) { throw new DexException("Target out of range: " + Hex.s4(relativeTarget)); } return relativeTarget & 0xff; }
/** * Gets the A register number, as a nibble. This will throw if the * value is out of the range of an unsigned nibble. */ public final short getANibble() { int a = getA(); if ((a & ~0xf) != 0) { throw new DexException("Register A out of range: " + Hex.u8(a)); } return (short) a; }
/** * Gets the D register number, as a byte. This will throw if the * value is out of the range of an unsigned byte. */ public final short getDByte() { int d = getD(); if ((d & ~0xff) != 0) { throw new DexException("Register D out of range: " + Hex.u8(d)); } return (short) d; }
public void writeSleb128(int i) { try { Leb128Utils.writeSignedLeb128(this, i); ensureCapacity(0); } catch (ArrayIndexOutOfBoundsException e) { throw new DexException("Section limit " + limit + " exceeded by " + name); } }