예제 #1
0
 public static int DetermineContextID(this LiteralContextMode mode, byte mostRecentByte, byte secondRecentByte)
 {
     return(mode switch {
         LiteralContextMode.LSB6 => mostRecentByte & 0x3F,
         LiteralContextMode.MSB6 => mostRecentByte >> 2,
         LiteralContextMode.UTF8 => LUT0[mostRecentByte] | LUT1[secondRecentByte],
         LiteralContextMode.Signed => (LUT2[mostRecentByte] << 3) | LUT2[secondRecentByte],
         _ => throw new InvalidOperationException("Invalid literal context mode: " + mode)
     });
예제 #2
0
        // State helpers

        public int NextLiteralContextID(LiteralContextMode mode)
        {
            return(mode.DetermineContextID(LiteralBuffer.Front, LiteralBuffer.Back));
        }