addBinaryShiftChar method

State addBinaryShiftChar(
  1. int index
)

Implementation

State addBinaryShiftChar(int index) {
  Token token = _token;
  int mode = _mode;
  int bitCount = _bitCount;
  if (_mode == HighLevelEncoder.MODE_PUNCT ||
      _mode == HighLevelEncoder.MODE_DIGIT) {
    //assert binaryShiftByteCount == 0;
    final int latch =
        HighLevelEncoder.LATCH_TABLE[mode][HighLevelEncoder.MODE_UPPER];
    token = token.add(latch & 0xFFFF, latch >> 16);
    bitCount += latch >> 16;
    mode = HighLevelEncoder.MODE_UPPER;
  }
  final int deltaBitCount =
      (_binaryShiftByteCount == 0 || _binaryShiftByteCount == 31)
          ? 18
          : (_binaryShiftByteCount == 62)
              ? 9
              : 8;
  State result =
      State(token, mode, _binaryShiftByteCount + 1, bitCount + deltaBitCount);
  if (result._binaryShiftByteCount == 2047 + 31) {
    // The string is as long as it's allowed to be.  We should end it.
    result = result.endBinaryShift(index + 1);
  }
  return result;
}