/** * Gets the array. The returned array contains exactly the data * written (e.g. no leftover space at the end). */ public short[] getArray() { int cursor = cursor(); if (cursor == array.length) { return array; } short[] result = new short[cursor]; System.arraycopy(array, 0, result, 0, cursor); return result; }
private void ensureArrayLength(int shortCountToWrite) { int currPos = cursor(); if (array.length - currPos < shortCountToWrite) { short[] newArray = new short[array.length + (array.length >> 1)]; System.arraycopy(array, 0, newArray, 0, currPos); array = newArray; } } }
/** * Writes a code unit. */ public void write(short codeUnit) { ensureArrayLength(1); array[cursor()] = codeUnit; advance(1); }
int relativeTarget = InstructionCodec.getTarget(target, codeOut.cursor()); if (relativeTarget != (byte) relativeTarget) { if (relativeTarget != (short) relativeTarget) { int relativeTarget = InstructionCodec.getTargetByte(target, codeOut.cursor()); codeOut.write(InstructionCodec.codeUnit(opcode, relativeTarget)); int relativeTarget = InstructionCodec.getTarget(target, codeOut.cursor()); if (relativeTarget != (short) relativeTarget) { short opcodeUnit = (short) Opcodes.GOTO_32; short relativeTarget = InstructionCodec.getTargetUnit(target, codeOut.cursor()); short opcodeUnit = (short) opcode; codeOut.write(opcodeUnit, relativeTarget); int relativeTarget = InstructionCodec.getTarget(target, codeOut.cursor()); short opcodeUnit = (short) opcode; codeOut.write(opcodeUnit, InstructionCodec.unit0(relativeTarget), InstructionCodec.unit1(relativeTarget));
case Opcodes.IF_GTZ: case Opcodes.IF_LEZ: { short relativeTarget = InstructionCodec.getTargetUnit(target, codeOut.cursor()); codeOut.write(InstructionCodec.codeUnit(opcode, a), relativeTarget); break; case Opcodes.PACKED_SWITCH: case Opcodes.SPARSE_SWITCH: { codeOut.setBaseAddress(target, codeOut.cursor()); break; int relativeTarget = InstructionCodec.getTarget(target, codeOut.cursor()); codeOut.write( InstructionCodec.codeUnit(opcode, a),
case Opcodes.IF_GT: case Opcodes.IF_LE: { short relativeTarget = InstructionCodec.getTargetUnit(target, codeOut.cursor()); codeOut.write( InstructionCodec.codeUnit(
private void ensureArrayLength(int shortCountToWrite) { int currPos = cursor(); if (array.length - currPos < shortCountToWrite) { short[] newArray = new short[array.length + (array.length >> 1)]; System.arraycopy(array, 0, newArray, 0, currPos); array = newArray; } } }
/** * Gets the array. The returned array contains exactly the data * written (e.g. no leftover space at the end). */ public short[] getArray() { int cursor = cursor(); if (cursor == array.length) { return array; } short[] result = new short[cursor]; System.arraycopy(array, 0, result, 0, cursor); return result; }
/** * Writes a code unit. */ public void write(short codeUnit) { ensureArrayLength(1); array[cursor()] = codeUnit; advance(1); }
int relativeTarget = InstructionCodec.getTarget(target, codeOut.cursor()); if (relativeTarget != (byte) relativeTarget) { if (relativeTarget != (short) relativeTarget) { int relativeTarget = InstructionCodec.getTargetByte(target, codeOut.cursor()); codeOut.write(InstructionCodec.codeUnit(opcode, relativeTarget)); int relativeTarget = InstructionCodec.getTarget(target, codeOut.cursor()); if (relativeTarget != (short) relativeTarget) { short opcodeUnit = (short) Opcodes.GOTO_32; short relativeTarget = InstructionCodec.getTargetUnit(target, codeOut.cursor()); short opcodeUnit = (short) opcode; codeOut.write(opcodeUnit, relativeTarget); int relativeTarget = InstructionCodec.getTarget(target, codeOut.cursor()); short opcodeUnit = (short) opcode; codeOut.write(opcodeUnit, InstructionCodec.unit0(relativeTarget), InstructionCodec.unit1(relativeTarget));
case Opcodes.IF_GTZ: case Opcodes.IF_LEZ: { short relativeTarget = InstructionCodec.getTargetUnit(target, codeOut.cursor()); codeOut.write(InstructionCodec.codeUnit(opcode, a), relativeTarget); break; case Opcodes.PACKED_SWITCH: case Opcodes.SPARSE_SWITCH: { codeOut.setBaseAddress(target, codeOut.cursor()); break; int relativeTarget = InstructionCodec.getTarget(target, codeOut.cursor()); codeOut.write( InstructionCodec.codeUnit(opcode, a),
case Opcodes.IF_GT: case Opcodes.IF_LE: { short relativeTarget = InstructionCodec.getTargetUnit(target, codeOut.cursor()); codeOut.write( InstructionCodec.codeUnit(