{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE CPP #-}
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE MagicHash #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RankNTypes #-}
{-# OPTIONS_GHC -funfolding-keeness-factor=2.0 #-}
module Codec.CBOR.Read
( deserialiseFromBytes
, deserialiseFromBytesWithSize
, deserialiseIncremental
, DeserialiseFailure(..)
, IDecode(..)
, ByteOffset
) where
#include "cbor.h"
#if !MIN_VERSION_base(4,8,0)
import Control.Applicative
#endif
import GHC.Int
import Control.DeepSeq
import Control.Monad (ap)
import Control.Monad.ST
import Data.Array.IArray
import Data.Array.Unboxed
import qualified Data.Array.Base as A
import Data.Monoid
import Data.Bits
import Data.ByteString (ByteString)
import qualified Data.ByteString as BS
import qualified Data.ByteString.Unsafe as BS
import qualified Data.ByteString.Lazy as LBS
import qualified Data.ByteString.Lazy.Internal as LBS
import qualified Data.Text as T
import qualified Data.Text.Encoding as T
import Data.Word
import GHC.Word
#if defined(ARCH_32bit)
import GHC.IntWord64
#endif
import GHC.Exts
import GHC.Float (float2Double)
import Data.Typeable
import Control.Exception
import Prelude hiding (fromIntegral)
import qualified Codec.CBOR.ByteArray as BA
import Codec.CBOR.Decoding hiding (DecodeAction(Done, Fail))
import Codec.CBOR.Decoding (DecodeAction)
import qualified Codec.CBOR.Decoding as D
import Codec.CBOR.Magic
data DeserialiseFailure = DeserialiseFailure ByteOffset String
deriving (DeserialiseFailure -> DeserialiseFailure -> Bool
(DeserialiseFailure -> DeserialiseFailure -> Bool)
-> (DeserialiseFailure -> DeserialiseFailure -> Bool)
-> Eq DeserialiseFailure
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeserialiseFailure -> DeserialiseFailure -> Bool
$c/= :: DeserialiseFailure -> DeserialiseFailure -> Bool
== :: DeserialiseFailure -> DeserialiseFailure -> Bool
$c== :: DeserialiseFailure -> DeserialiseFailure -> Bool
Eq, Int -> DeserialiseFailure -> ShowS
[DeserialiseFailure] -> ShowS
DeserialiseFailure -> String
(Int -> DeserialiseFailure -> ShowS)
-> (DeserialiseFailure -> String)
-> ([DeserialiseFailure] -> ShowS)
-> Show DeserialiseFailure
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeserialiseFailure] -> ShowS
$cshowList :: [DeserialiseFailure] -> ShowS
show :: DeserialiseFailure -> String
$cshow :: DeserialiseFailure -> String
showsPrec :: Int -> DeserialiseFailure -> ShowS
$cshowsPrec :: Int -> DeserialiseFailure -> ShowS
Show, Typeable)
instance NFData DeserialiseFailure where
rnf :: DeserialiseFailure -> ()
rnf (DeserialiseFailure offset :: ByteOffset
offset msg :: String
msg) = ByteOffset -> ()
forall a. NFData a => a -> ()
rnf ByteOffset
offset () -> () -> ()
forall a b. a -> b -> b
`seq` String -> ()
forall a. NFData a => a -> ()
rnf String
msg () -> () -> ()
forall a b. a -> b -> b
`seq` ()
instance Exception DeserialiseFailure where
#if MIN_VERSION_base(4,8,0)
displayException :: DeserialiseFailure -> String
displayException (DeserialiseFailure off :: ByteOffset
off msg :: String
msg) =
"Codec.CBOR: deserialising failed at offset "
String -> ShowS
forall a. [a] -> [a] -> [a]
++ ByteOffset -> String
forall a. Show a => a -> String
show ByteOffset
off String -> ShowS
forall a. [a] -> [a] -> [a]
++ " : " String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
msg
#endif
data IDecode s a
=
Partial (Maybe BS.ByteString -> ST s (IDecode s a))
| Done !BS.ByteString {-# UNPACK #-} !ByteOffset a
| Fail !BS.ByteString {-# UNPACK #-} !ByteOffset DeserialiseFailure
deserialiseFromBytes :: (forall s. Decoder s a)
-> LBS.ByteString
-> Either DeserialiseFailure (LBS.ByteString, a)
deserialiseFromBytes :: (forall s. Decoder s a)
-> ByteString -> Either DeserialiseFailure (ByteString, a)
deserialiseFromBytes d :: forall s. Decoder s a
d lbs :: ByteString
lbs =
((ByteString, ByteOffset, a) -> (ByteString, a))
-> Either DeserialiseFailure (ByteString, ByteOffset, a)
-> Either DeserialiseFailure (ByteString, a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (ByteString, ByteOffset, a) -> (ByteString, a)
forall a b b. (a, b, b) -> (a, b)
f (Either DeserialiseFailure (ByteString, ByteOffset, a)
-> Either DeserialiseFailure (ByteString, a))
-> Either DeserialiseFailure (ByteString, ByteOffset, a)
-> Either DeserialiseFailure (ByteString, a)
forall a b. (a -> b) -> a -> b
$ (forall s. ST s (IDecode s a))
-> ByteString
-> Either DeserialiseFailure (ByteString, ByteOffset, a)
forall a.
(forall s. ST s (IDecode s a))
-> ByteString
-> Either DeserialiseFailure (ByteString, ByteOffset, a)
runIDecode (Decoder s a -> ST s (IDecode s a)
forall s a. Decoder s a -> ST s (IDecode s a)
deserialiseIncremental Decoder s a
forall s. Decoder s a
d) ByteString
lbs
where f :: (a, b, b) -> (a, b)
f (rest :: a
rest, _, x :: b
x) = (a
rest, b
x)
deserialiseFromBytesWithSize :: (forall s. Decoder s a)
-> LBS.ByteString
-> Either DeserialiseFailure (LBS.ByteString, ByteOffset, a)
deserialiseFromBytesWithSize :: (forall s. Decoder s a)
-> ByteString
-> Either DeserialiseFailure (ByteString, ByteOffset, a)
deserialiseFromBytesWithSize d :: forall s. Decoder s a
d lbs :: ByteString
lbs =
(forall s. ST s (IDecode s a))
-> ByteString
-> Either DeserialiseFailure (ByteString, ByteOffset, a)
forall a.
(forall s. ST s (IDecode s a))
-> ByteString
-> Either DeserialiseFailure (ByteString, ByteOffset, a)
runIDecode (Decoder s a -> ST s (IDecode s a)
forall s a. Decoder s a -> ST s (IDecode s a)
deserialiseIncremental Decoder s a
forall s. Decoder s a
d) ByteString
lbs
runIDecode :: (forall s. ST s (IDecode s a))
-> LBS.ByteString
-> Either DeserialiseFailure (LBS.ByteString, ByteOffset, a)
runIDecode :: (forall s. ST s (IDecode s a))
-> ByteString
-> Either DeserialiseFailure (ByteString, ByteOffset, a)
runIDecode d :: forall s. ST s (IDecode s a)
d lbs :: ByteString
lbs =
(forall s.
ST s (Either DeserialiseFailure (ByteString, ByteOffset, a)))
-> Either DeserialiseFailure (ByteString, ByteOffset, a)
forall a. (forall s. ST s a) -> a
runST (ByteString
-> IDecode s a
-> ST s (Either DeserialiseFailure (ByteString, ByteOffset, a))
forall s a.
ByteString
-> IDecode s a
-> ST s (Either DeserialiseFailure (ByteString, ByteOffset, a))
go ByteString
lbs (IDecode s a
-> ST s (Either DeserialiseFailure (ByteString, ByteOffset, a)))
-> ST s (IDecode s a)
-> ST s (Either DeserialiseFailure (ByteString, ByteOffset, a))
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< ST s (IDecode s a)
forall s. ST s (IDecode s a)
d)
where
go :: LBS.ByteString
-> IDecode s a
-> ST s (Either DeserialiseFailure (LBS.ByteString, ByteOffset, a))
go :: ByteString
-> IDecode s a
-> ST s (Either DeserialiseFailure (ByteString, ByteOffset, a))
go _ (Fail _ _ err :: DeserialiseFailure
err) = Either DeserialiseFailure (ByteString, ByteOffset, a)
-> ST s (Either DeserialiseFailure (ByteString, ByteOffset, a))
forall (m :: * -> *) a. Monad m => a -> m a
return (DeserialiseFailure
-> Either DeserialiseFailure (ByteString, ByteOffset, a)
forall a b. a -> Either a b
Left DeserialiseFailure
err)
go lbs' :: ByteString
lbs' (Done bs :: ByteString
bs off :: ByteOffset
off x :: a
x) = let rest :: ByteString
rest
| ByteString -> Bool
BS.null ByteString
bs = ByteString
lbs'
| Bool
otherwise = ByteString -> ByteString -> ByteString
LBS.Chunk ByteString
bs ByteString
lbs'
in Either DeserialiseFailure (ByteString, ByteOffset, a)
-> ST s (Either DeserialiseFailure (ByteString, ByteOffset, a))
forall (m :: * -> *) a. Monad m => a -> m a
return ((ByteString, ByteOffset, a)
-> Either DeserialiseFailure (ByteString, ByteOffset, a)
forall a b. b -> Either a b
Right (ByteString
rest, ByteOffset
off, a
x))
go LBS.Empty (Partial k :: Maybe ByteString -> ST s (IDecode s a)
k) = Maybe ByteString -> ST s (IDecode s a)
k Maybe ByteString
forall a. Maybe a
Nothing ST s (IDecode s a)
-> (IDecode s a
-> ST s (Either DeserialiseFailure (ByteString, ByteOffset, a)))
-> ST s (Either DeserialiseFailure (ByteString, ByteOffset, a))
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ByteString
-> IDecode s a
-> ST s (Either DeserialiseFailure (ByteString, ByteOffset, a))
forall s a.
ByteString
-> IDecode s a
-> ST s (Either DeserialiseFailure (ByteString, ByteOffset, a))
go ByteString
LBS.Empty
go (LBS.Chunk bs :: ByteString
bs lbs' :: ByteString
lbs') (Partial k :: Maybe ByteString -> ST s (IDecode s a)
k) = Maybe ByteString -> ST s (IDecode s a)
k (ByteString -> Maybe ByteString
forall a. a -> Maybe a
Just ByteString
bs) ST s (IDecode s a)
-> (IDecode s a
-> ST s (Either DeserialiseFailure (ByteString, ByteOffset, a)))
-> ST s (Either DeserialiseFailure (ByteString, ByteOffset, a))
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ByteString
-> IDecode s a
-> ST s (Either DeserialiseFailure (ByteString, ByteOffset, a))
forall s a.
ByteString
-> IDecode s a
-> ST s (Either DeserialiseFailure (ByteString, ByteOffset, a))
go ByteString
lbs'
deserialiseIncremental :: Decoder s a -> ST s (IDecode s a)
deserialiseIncremental :: Decoder s a -> ST s (IDecode s a)
deserialiseIncremental decoder :: Decoder s a
decoder = do
DecodeAction s a
da <- Decoder s a -> ST s (DecodeAction s a)
forall s a. Decoder s a -> ST s (DecodeAction s a)
getDecodeAction Decoder s a
decoder
IncrementalDecoder s (ByteString, ByteOffset, a)
-> ST s (IDecode s a)
forall s a.
IncrementalDecoder s (ByteString, ByteOffset, a)
-> ST s (IDecode s a)
runIncrementalDecoder (DecodeAction s a
-> IncrementalDecoder s (ByteString, ByteOffset, a)
forall s a.
DecodeAction s a
-> IncrementalDecoder s (ByteString, ByteOffset, a)
runDecodeAction DecodeAction s a
da)
newtype IncrementalDecoder s a = IncrementalDecoder {
IncrementalDecoder s a
-> forall r. (a -> ST s (IDecode s r)) -> ST s (IDecode s r)
unIncrementalDecoder ::
forall r. (a -> ST s (IDecode s r)) -> ST s (IDecode s r)
}
instance Functor (IncrementalDecoder s) where
fmap :: (a -> b) -> IncrementalDecoder s a -> IncrementalDecoder s b
fmap f :: a -> b
f a :: IncrementalDecoder s a
a = IncrementalDecoder s a
a IncrementalDecoder s a
-> (a -> IncrementalDecoder s b) -> IncrementalDecoder s b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= b -> IncrementalDecoder s b
forall (m :: * -> *) a. Monad m => a -> m a
return (b -> IncrementalDecoder s b)
-> (a -> b) -> a -> IncrementalDecoder s b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> b
f
instance Applicative (IncrementalDecoder s) where
pure :: a -> IncrementalDecoder s a
pure x :: a
x = (forall r. (a -> ST s (IDecode s r)) -> ST s (IDecode s r))
-> IncrementalDecoder s a
forall s a.
(forall r. (a -> ST s (IDecode s r)) -> ST s (IDecode s r))
-> IncrementalDecoder s a
IncrementalDecoder ((forall r. (a -> ST s (IDecode s r)) -> ST s (IDecode s r))
-> IncrementalDecoder s a)
-> (forall r. (a -> ST s (IDecode s r)) -> ST s (IDecode s r))
-> IncrementalDecoder s a
forall a b. (a -> b) -> a -> b
$ \k :: a -> ST s (IDecode s r)
k -> a -> ST s (IDecode s r)
k a
x
<*> :: IncrementalDecoder s (a -> b)
-> IncrementalDecoder s a -> IncrementalDecoder s b
(<*>) = IncrementalDecoder s (a -> b)
-> IncrementalDecoder s a -> IncrementalDecoder s b
forall (m :: * -> *) a b. Monad m => m (a -> b) -> m a -> m b
ap
instance Monad (IncrementalDecoder s) where
return :: a -> IncrementalDecoder s a
return = a -> IncrementalDecoder s a
forall (f :: * -> *) a. Applicative f => a -> f a
pure
{-# INLINE (>>=) #-}
m :: IncrementalDecoder s a
m >>= :: IncrementalDecoder s a
-> (a -> IncrementalDecoder s b) -> IncrementalDecoder s b
>>= f :: a -> IncrementalDecoder s b
f = (forall r. (b -> ST s (IDecode s r)) -> ST s (IDecode s r))
-> IncrementalDecoder s b
forall s a.
(forall r. (a -> ST s (IDecode s r)) -> ST s (IDecode s r))
-> IncrementalDecoder s a
IncrementalDecoder ((forall r. (b -> ST s (IDecode s r)) -> ST s (IDecode s r))
-> IncrementalDecoder s b)
-> (forall r. (b -> ST s (IDecode s r)) -> ST s (IDecode s r))
-> IncrementalDecoder s b
forall a b. (a -> b) -> a -> b
$ \k :: b -> ST s (IDecode s r)
k ->
IncrementalDecoder s a
-> forall r. (a -> ST s (IDecode s r)) -> ST s (IDecode s r)
forall s a.
IncrementalDecoder s a
-> forall r. (a -> ST s (IDecode s r)) -> ST s (IDecode s r)
unIncrementalDecoder IncrementalDecoder s a
m ((a -> ST s (IDecode s r)) -> ST s (IDecode s r))
-> (a -> ST s (IDecode s r)) -> ST s (IDecode s r)
forall a b. (a -> b) -> a -> b
$ \x :: a
x ->
IncrementalDecoder s b
-> (b -> ST s (IDecode s r)) -> ST s (IDecode s r)
forall s a.
IncrementalDecoder s a
-> forall r. (a -> ST s (IDecode s r)) -> ST s (IDecode s r)
unIncrementalDecoder (a -> IncrementalDecoder s b
f a
x) b -> ST s (IDecode s r)
k
runIncrementalDecoder :: IncrementalDecoder s (ByteString, ByteOffset, a)
-> ST s (IDecode s a)
runIncrementalDecoder :: IncrementalDecoder s (ByteString, ByteOffset, a)
-> ST s (IDecode s a)
runIncrementalDecoder (IncrementalDecoder f :: forall r.
((ByteString, ByteOffset, a) -> ST s (IDecode s r))
-> ST s (IDecode s r)
f) =
((ByteString, ByteOffset, a) -> ST s (IDecode s a))
-> ST s (IDecode s a)
forall r.
((ByteString, ByteOffset, a) -> ST s (IDecode s r))
-> ST s (IDecode s r)
f (\(trailing :: ByteString
trailing, off :: ByteOffset
off, x :: a
x) -> IDecode s a -> ST s (IDecode s a)
forall (m :: * -> *) a. Monad m => a -> m a
return (IDecode s a -> ST s (IDecode s a))
-> IDecode s a -> ST s (IDecode s a)
forall a b. (a -> b) -> a -> b
$ ByteString -> ByteOffset -> a -> IDecode s a
forall s a. ByteString -> ByteOffset -> a -> IDecode s a
Done ByteString
trailing ByteOffset
off a
x)
decodeFail :: ByteString -> ByteOffset -> String -> IncrementalDecoder s a
decodeFail :: ByteString -> ByteOffset -> String -> IncrementalDecoder s a
decodeFail trailing :: ByteString
trailing off :: ByteOffset
off msg :: String
msg = (forall r. (a -> ST s (IDecode s r)) -> ST s (IDecode s r))
-> IncrementalDecoder s a
forall s a.
(forall r. (a -> ST s (IDecode s r)) -> ST s (IDecode s r))
-> IncrementalDecoder s a
IncrementalDecoder ((forall r. (a -> ST s (IDecode s r)) -> ST s (IDecode s r))
-> IncrementalDecoder s a)
-> (forall r. (a -> ST s (IDecode s r)) -> ST s (IDecode s r))
-> IncrementalDecoder s a
forall a b. (a -> b) -> a -> b
$ \_ -> IDecode s r -> ST s (IDecode s r)
forall (m :: * -> *) a. Monad m => a -> m a
return (IDecode s r -> ST s (IDecode s r))
-> IDecode s r -> ST s (IDecode s r)
forall a b. (a -> b) -> a -> b
$ ByteString -> ByteOffset -> DeserialiseFailure -> IDecode s r
forall s a.
ByteString -> ByteOffset -> DeserialiseFailure -> IDecode s a
Fail ByteString
trailing ByteOffset
off DeserialiseFailure
exn
where exn :: DeserialiseFailure
exn = ByteOffset -> String -> DeserialiseFailure
DeserialiseFailure ByteOffset
off String
msg
needChunk :: IncrementalDecoder s (Maybe ByteString)
needChunk :: IncrementalDecoder s (Maybe ByteString)
needChunk = (forall r.
(Maybe ByteString -> ST s (IDecode s r)) -> ST s (IDecode s r))
-> IncrementalDecoder s (Maybe ByteString)
forall s a.
(forall r. (a -> ST s (IDecode s r)) -> ST s (IDecode s r))
-> IncrementalDecoder s a
IncrementalDecoder ((forall r.
(Maybe ByteString -> ST s (IDecode s r)) -> ST s (IDecode s r))
-> IncrementalDecoder s (Maybe ByteString))
-> (forall r.
(Maybe ByteString -> ST s (IDecode s r)) -> ST s (IDecode s r))
-> IncrementalDecoder s (Maybe ByteString)
forall a b. (a -> b) -> a -> b
$ \k :: Maybe ByteString -> ST s (IDecode s r)
k -> IDecode s r -> ST s (IDecode s r)
forall (m :: * -> *) a. Monad m => a -> m a
return (IDecode s r -> ST s (IDecode s r))
-> IDecode s r -> ST s (IDecode s r)
forall a b. (a -> b) -> a -> b
$ (Maybe ByteString -> ST s (IDecode s r)) -> IDecode s r
forall s a. (Maybe ByteString -> ST s (IDecode s a)) -> IDecode s a
Partial ((Maybe ByteString -> ST s (IDecode s r)) -> IDecode s r)
-> (Maybe ByteString -> ST s (IDecode s r)) -> IDecode s r
forall a b. (a -> b) -> a -> b
$ \mbs :: Maybe ByteString
mbs -> Maybe ByteString -> ST s (IDecode s r)
k Maybe ByteString
mbs
lift :: ST s a -> IncrementalDecoder s a
lift :: ST s a -> IncrementalDecoder s a
lift action :: ST s a
action = (forall r. (a -> ST s (IDecode s r)) -> ST s (IDecode s r))
-> IncrementalDecoder s a
forall s a.
(forall r. (a -> ST s (IDecode s r)) -> ST s (IDecode s r))
-> IncrementalDecoder s a
IncrementalDecoder (\k :: a -> ST s (IDecode s r)
k -> ST s a
action ST s a -> (a -> ST s (IDecode s r)) -> ST s (IDecode s r)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= a -> ST s (IDecode s r)
k)
runDecodeAction :: DecodeAction s a
-> IncrementalDecoder s (ByteString, ByteOffset, a)
runDecodeAction :: DecodeAction s a
-> IncrementalDecoder s (ByteString, ByteOffset, a)
runDecodeAction (D.Fail msg :: String
msg) = ByteString
-> ByteOffset
-> String
-> IncrementalDecoder s (ByteString, ByteOffset, a)
forall s a.
ByteString -> ByteOffset -> String -> IncrementalDecoder s a
decodeFail ByteString
BS.empty 0 String
msg
runDecodeAction (D.Done x :: a
x) = (ByteString, ByteOffset, a)
-> IncrementalDecoder s (ByteString, ByteOffset, a)
forall (m :: * -> *) a. Monad m => a -> m a
return (ByteString
BS.empty, 0, a
x)
runDecodeAction (D.PeekAvailable k :: Int# -> ST s (DecodeAction s a)
k) = ST s (DecodeAction s a) -> IncrementalDecoder s (DecodeAction s a)
forall s a. ST s a -> IncrementalDecoder s a
lift (Int# -> ST s (DecodeAction s a)
k 0#) IncrementalDecoder s (DecodeAction s a)
-> (DecodeAction s a
-> IncrementalDecoder s (ByteString, ByteOffset, a))
-> IncrementalDecoder s (ByteString, ByteOffset, a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= DecodeAction s a
-> IncrementalDecoder s (ByteString, ByteOffset, a)
forall s a.
DecodeAction s a
-> IncrementalDecoder s (ByteString, ByteOffset, a)
runDecodeAction
runDecodeAction da :: DecodeAction s a
da = do
Maybe ByteString
mbs <- IncrementalDecoder s (Maybe ByteString)
forall s. IncrementalDecoder s (Maybe ByteString)
needChunk
case Maybe ByteString
mbs of
Nothing -> ByteString
-> ByteOffset
-> String
-> IncrementalDecoder s (ByteString, ByteOffset, a)
forall s a.
ByteString -> ByteOffset -> String -> IncrementalDecoder s a
decodeFail ByteString
BS.empty 0 "end of input"
Just bs :: ByteString
bs -> DecodeAction s a
-> ByteString
-> ByteOffset
-> IncrementalDecoder s (ByteString, ByteOffset, a)
forall s a.
DecodeAction s a
-> ByteString
-> ByteOffset
-> IncrementalDecoder s (ByteString, ByteOffset, a)
go_slow DecodeAction s a
da ByteString
bs 0
data SlowPath s a
= FastDone {-# UNPACK #-} !ByteString a
| SlowConsumeTokenBytes {-# UNPACK #-} !ByteString (ByteString -> ST s (DecodeAction s a)) {-# UNPACK #-} !Int
| SlowConsumeTokenByteArray {-# UNPACK #-} !ByteString (BA.ByteArray -> ST s (DecodeAction s a)) {-# UNPACK #-} !Int
| SlowConsumeTokenString {-# UNPACK #-} !ByteString (T.Text -> ST s (DecodeAction s a)) {-# UNPACK #-} !Int
| SlowConsumeTokenUtf8ByteArray {-# UNPACK #-} !ByteString (BA.ByteArray -> ST s (DecodeAction s a)) {-# UNPACK #-} !Int
#if defined(ARCH_32bit)
| SlowPeekByteOffset {-# UNPACK #-} !ByteString (Int64# -> ST s (DecodeAction s a))
#else
| SlowPeekByteOffset {-# UNPACK #-} !ByteString (Int# -> ST s (DecodeAction s a))
#endif
| SlowDecodeAction {-# UNPACK #-} !ByteString (DecodeAction s a)
| SlowFail {-# UNPACK #-} !ByteString String
go_fast :: ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast :: ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast !ByteString
bs da :: DecodeAction s a
da | ByteString -> Int
BS.length ByteString
bs Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
< 9 = ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end ByteString
bs DecodeAction s a
da
go_fast !ByteString
bs da :: DecodeAction s a
da@(ConsumeWord k :: Word# -> ST s (DecodeAction s a)
k) =
case Word8 -> ByteString -> DecodedToken Word
tryConsumeWord (ByteString -> Word8
BS.unsafeHead ByteString
bs) ByteString
bs of
DecodeFailure -> ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end ByteString
bs DecodeAction s a
da
DecodedToken sz :: Int
sz (W# w# :: Word#
w#) -> Word# -> ST s (DecodeAction s a)
k Word#
w# ST s (DecodeAction s a)
-> (DecodeAction s a -> ST s (SlowPath s a)) -> ST s (SlowPath s a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs)
go_fast !ByteString
bs da :: DecodeAction s a
da@(ConsumeWord8 k :: Word# -> ST s (DecodeAction s a)
k) =
case Word8 -> ByteString -> DecodedToken Word
tryConsumeWord (ByteString -> Word8
BS.unsafeHead ByteString
bs) ByteString
bs of
DecodeFailure -> ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end ByteString
bs DecodeAction s a
da
DecodedToken sz :: Int
sz (W# w# :: Word#
w#) ->
case Word# -> Word# -> Int#
gtWord# Word#
w# 0xff## of
0# -> Word# -> ST s (DecodeAction s a)
k Word#
w# ST s (DecodeAction s a)
-> (DecodeAction s a -> ST s (SlowPath s a)) -> ST s (SlowPath s a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs)
_ -> ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end ByteString
bs DecodeAction s a
da
go_fast !ByteString
bs da :: DecodeAction s a
da@(ConsumeWord16 k :: Word# -> ST s (DecodeAction s a)
k) =
case Word8 -> ByteString -> DecodedToken Word
tryConsumeWord (ByteString -> Word8
BS.unsafeHead ByteString
bs) ByteString
bs of
DecodeFailure -> ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end ByteString
bs DecodeAction s a
da
DecodedToken sz :: Int
sz (W# w# :: Word#
w#) ->
case Word# -> Word# -> Int#
gtWord# Word#
w# 0xffff## of
0# -> Word# -> ST s (DecodeAction s a)
k Word#
w# ST s (DecodeAction s a)
-> (DecodeAction s a -> ST s (SlowPath s a)) -> ST s (SlowPath s a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs)
_ -> ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end ByteString
bs DecodeAction s a
da
go_fast !ByteString
bs da :: DecodeAction s a
da@(ConsumeWord32 k :: Word# -> ST s (DecodeAction s a)
k) =
case Word8 -> ByteString -> DecodedToken Word
tryConsumeWord (ByteString -> Word8
BS.unsafeHead ByteString
bs) ByteString
bs of
DecodeFailure -> ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end ByteString
bs DecodeAction s a
da
DecodedToken sz :: Int
sz (W# w# :: Word#
w#) ->
#if defined(ARCH_32bit)
Word# -> ST s (DecodeAction s a)
k Word#
w# ST s (DecodeAction s a)
-> (DecodeAction s a -> ST s (SlowPath s a)) -> ST s (SlowPath s a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs)
#else
case gtWord# w# 0xffffffff## of
0# -> k w# >>= go_fast (BS.unsafeDrop sz bs)
_ -> go_fast_end bs da
#endif
go_fast !ByteString
bs da :: DecodeAction s a
da@(ConsumeNegWord k :: Word# -> ST s (DecodeAction s a)
k) =
case Word8 -> ByteString -> DecodedToken Word
tryConsumeNegWord (ByteString -> Word8
BS.unsafeHead ByteString
bs) ByteString
bs of
DecodeFailure -> ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end ByteString
bs DecodeAction s a
da
DecodedToken sz :: Int
sz (W# w# :: Word#
w#) -> Word# -> ST s (DecodeAction s a)
k Word#
w# ST s (DecodeAction s a)
-> (DecodeAction s a -> ST s (SlowPath s a)) -> ST s (SlowPath s a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs)
go_fast !ByteString
bs da :: DecodeAction s a
da@(ConsumeInt k :: Int# -> ST s (DecodeAction s a)
k) =
case Word8 -> ByteString -> DecodedToken Int
tryConsumeInt (ByteString -> Word8
BS.unsafeHead ByteString
bs) ByteString
bs of
DecodeFailure -> ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end ByteString
bs DecodeAction s a
da
DecodedToken sz :: Int
sz (I# n# :: Int#
n#) -> Int# -> ST s (DecodeAction s a)
k Int#
n# ST s (DecodeAction s a)
-> (DecodeAction s a -> ST s (SlowPath s a)) -> ST s (SlowPath s a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs)
go_fast !ByteString
bs da :: DecodeAction s a
da@(ConsumeInt8 k :: Int# -> ST s (DecodeAction s a)
k) =
case Word8 -> ByteString -> DecodedToken Int
tryConsumeInt (ByteString -> Word8
BS.unsafeHead ByteString
bs) ByteString
bs of
DecodeFailure -> ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end ByteString
bs DecodeAction s a
da
DecodedToken sz :: Int
sz (I# n# :: Int#
n#) ->
case (Int#
n# Int# -> Int# -> Int#
># 0x7f#) Int# -> Int# -> Int#
`orI#` (Int#
n# Int# -> Int# -> Int#
<# -0x80#) of
0# -> Int# -> ST s (DecodeAction s a)
k Int#
n# ST s (DecodeAction s a)
-> (DecodeAction s a -> ST s (SlowPath s a)) -> ST s (SlowPath s a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs)
_ -> ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end ByteString
bs DecodeAction s a
da
go_fast !ByteString
bs da :: DecodeAction s a
da@(ConsumeInt16 k :: Int# -> ST s (DecodeAction s a)
k) =
case Word8 -> ByteString -> DecodedToken Int
tryConsumeInt (ByteString -> Word8
BS.unsafeHead ByteString
bs) ByteString
bs of
DecodeFailure -> ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end ByteString
bs DecodeAction s a
da
DecodedToken sz :: Int
sz (I# n# :: Int#
n#) ->
case (Int#
n# Int# -> Int# -> Int#
># 0x7fff#) Int# -> Int# -> Int#
`orI#` (Int#
n# Int# -> Int# -> Int#
<# -0x8000#) of
0# -> Int# -> ST s (DecodeAction s a)
k Int#
n# ST s (DecodeAction s a)
-> (DecodeAction s a -> ST s (SlowPath s a)) -> ST s (SlowPath s a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs)
_ -> ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end ByteString
bs DecodeAction s a
da
go_fast !ByteString
bs da :: DecodeAction s a
da@(ConsumeInt32 k :: Int# -> ST s (DecodeAction s a)
k) =
case Word8 -> ByteString -> DecodedToken Int
tryConsumeInt (ByteString -> Word8
BS.unsafeHead ByteString
bs) ByteString
bs of
DecodeFailure -> ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end ByteString
bs DecodeAction s a
da
DecodedToken sz :: Int
sz (I# n# :: Int#
n#) ->
#if defined(ARCH_32bit)
Int# -> ST s (DecodeAction s a)
k Int#
n# ST s (DecodeAction s a)
-> (DecodeAction s a -> ST s (SlowPath s a)) -> ST s (SlowPath s a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs)
#else
case (n# ># 0x7fffffff#) `orI#` (n# <# -0x80000000#) of
0# -> k n# >>= go_fast (BS.unsafeDrop sz bs)
_ -> go_fast_end bs da
#endif
go_fast !ByteString
bs da :: DecodeAction s a
da@(ConsumeListLen k :: Int# -> ST s (DecodeAction s a)
k) =
case Word8 -> ByteString -> DecodedToken Int
tryConsumeListLen (ByteString -> Word8
BS.unsafeHead ByteString
bs) ByteString
bs of
DecodeFailure -> ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end ByteString
bs DecodeAction s a
da
DecodedToken sz :: Int
sz (I# n# :: Int#
n#) -> Int# -> ST s (DecodeAction s a)
k Int#
n# ST s (DecodeAction s a)
-> (DecodeAction s a -> ST s (SlowPath s a)) -> ST s (SlowPath s a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs)
go_fast !ByteString
bs da :: DecodeAction s a
da@(ConsumeMapLen k :: Int# -> ST s (DecodeAction s a)
k) =
case Word8 -> ByteString -> DecodedToken Int
tryConsumeMapLen (ByteString -> Word8
BS.unsafeHead ByteString
bs) ByteString
bs of
DecodeFailure -> ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end ByteString
bs DecodeAction s a
da
DecodedToken sz :: Int
sz (I# n# :: Int#
n#) -> Int# -> ST s (DecodeAction s a)
k Int#
n# ST s (DecodeAction s a)
-> (DecodeAction s a -> ST s (SlowPath s a)) -> ST s (SlowPath s a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs)
go_fast !ByteString
bs da :: DecodeAction s a
da@(ConsumeTag k :: Word# -> ST s (DecodeAction s a)
k) =
case Word8 -> ByteString -> DecodedToken Word
tryConsumeTag (ByteString -> Word8
BS.unsafeHead ByteString
bs) ByteString
bs of
DecodeFailure -> ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end ByteString
bs DecodeAction s a
da
DecodedToken sz :: Int
sz (W# w# :: Word#
w#) -> Word# -> ST s (DecodeAction s a)
k Word#
w# ST s (DecodeAction s a)
-> (DecodeAction s a -> ST s (SlowPath s a)) -> ST s (SlowPath s a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs)
go_fast !ByteString
bs da :: DecodeAction s a
da@(ConsumeWordCanonical k :: Word# -> ST s (DecodeAction s a)
k) =
case Word8 -> ByteString -> DecodedToken Word
tryConsumeWord (ByteString -> Word8
BS.unsafeHead ByteString
bs) ByteString
bs of
DecodeFailure -> ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end ByteString
bs DecodeAction s a
da
DecodedToken sz :: Int
sz (W# w# :: Word#
w#)
| Int -> Word# -> Bool
isWordCanonical Int
sz Word#
w# -> Word# -> ST s (DecodeAction s a)
k Word#
w# ST s (DecodeAction s a)
-> (DecodeAction s a -> ST s (SlowPath s a)) -> ST s (SlowPath s a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs)
| Bool
otherwise -> ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end ByteString
bs DecodeAction s a
da
go_fast !ByteString
bs da :: DecodeAction s a
da@(ConsumeWord8Canonical k :: Word# -> ST s (DecodeAction s a)
k) =
case Word8 -> ByteString -> DecodedToken Word
tryConsumeWord (ByteString -> Word8
BS.unsafeHead ByteString
bs) ByteString
bs of
DecodeFailure -> ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end ByteString
bs DecodeAction s a
da
DecodedToken sz :: Int
sz (W# w# :: Word#
w#) ->
case Word# -> Word# -> Int#
gtWord# Word#
w# 0xff## of
0# | Int -> Word# -> Bool
isWordCanonical Int
sz Word#
w# -> Word# -> ST s (DecodeAction s a)
k Word#
w# ST s (DecodeAction s a)
-> (DecodeAction s a -> ST s (SlowPath s a)) -> ST s (SlowPath s a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs)
_ -> ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end ByteString
bs DecodeAction s a
da
go_fast !ByteString
bs da :: DecodeAction s a
da@(ConsumeWord16Canonical k :: Word# -> ST s (DecodeAction s a)
k) =
case Word8 -> ByteString -> DecodedToken Word
tryConsumeWord (ByteString -> Word8
BS.unsafeHead ByteString
bs) ByteString
bs of
DecodeFailure -> ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end ByteString
bs DecodeAction s a
da
DecodedToken sz :: Int
sz (W# w# :: Word#
w#) ->
case Word# -> Word# -> Int#
gtWord# Word#
w# 0xffff## of
0# | Int -> Word# -> Bool
isWordCanonical Int
sz Word#
w# -> Word# -> ST s (DecodeAction s a)
k Word#
w# ST s (DecodeAction s a)
-> (DecodeAction s a -> ST s (SlowPath s a)) -> ST s (SlowPath s a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs)
_ -> ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end ByteString
bs DecodeAction s a
da
go_fast !ByteString
bs da :: DecodeAction s a
da@(ConsumeWord32Canonical k :: Word# -> ST s (DecodeAction s a)
k) =
case Word8 -> ByteString -> DecodedToken Word
tryConsumeWord (ByteString -> Word8
BS.unsafeHead ByteString
bs) ByteString
bs of
DecodeFailure -> ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end ByteString
bs DecodeAction s a
da
DecodedToken sz :: Int
sz (W# w# :: Word#
w#) ->
case Word# -> Int#
w_out_of_range Word#
w# of
0# | Int -> Word# -> Bool
isWordCanonical Int
sz Word#
w# -> Word# -> ST s (DecodeAction s a)
k Word#
w# ST s (DecodeAction s a)
-> (DecodeAction s a -> ST s (SlowPath s a)) -> ST s (SlowPath s a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs)
_ -> ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end ByteString
bs DecodeAction s a
da
where
w_out_of_range :: Word# -> Int#
w_out_of_range :: Word# -> Int#
w_out_of_range _w# :: Word#
_w# =
#if defined(ARCH_32bit)
0#
#else
gtWord# _w# 0xffffffff##
#endif
go_fast !ByteString
bs da :: DecodeAction s a
da@(ConsumeNegWordCanonical k :: Word# -> ST s (DecodeAction s a)
k) =
case Word8 -> ByteString -> DecodedToken Word
tryConsumeNegWord (ByteString -> Word8
BS.unsafeHead ByteString
bs) ByteString
bs of
DecodeFailure -> ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end ByteString
bs DecodeAction s a
da
DecodedToken sz :: Int
sz (W# w# :: Word#
w#)
| Int -> Word# -> Bool
isWordCanonical Int
sz Word#
w# -> Word# -> ST s (DecodeAction s a)
k Word#
w# ST s (DecodeAction s a)
-> (DecodeAction s a -> ST s (SlowPath s a)) -> ST s (SlowPath s a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs)
| Bool
otherwise -> ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end ByteString
bs DecodeAction s a
da
go_fast !ByteString
bs da :: DecodeAction s a
da@(ConsumeIntCanonical k :: Int# -> ST s (DecodeAction s a)
k) =
case Word8 -> ByteString -> DecodedToken Int
tryConsumeInt (ByteString -> Word8
BS.unsafeHead ByteString
bs) ByteString
bs of
DecodeFailure -> ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end ByteString
bs DecodeAction s a
da
DecodedToken sz :: Int
sz (I# n# :: Int#
n#)
| Int -> Int# -> Bool
isIntCanonical Int
sz Int#
n# -> Int# -> ST s (DecodeAction s a)
k Int#
n# ST s (DecodeAction s a)
-> (DecodeAction s a -> ST s (SlowPath s a)) -> ST s (SlowPath s a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs)
| Bool
otherwise -> ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end ByteString
bs DecodeAction s a
da
go_fast !ByteString
bs da :: DecodeAction s a
da@(ConsumeInt8Canonical k :: Int# -> ST s (DecodeAction s a)
k) =
case Word8 -> ByteString -> DecodedToken Int
tryConsumeInt (ByteString -> Word8
BS.unsafeHead ByteString
bs) ByteString
bs of
DecodeFailure -> ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end ByteString
bs DecodeAction s a
da
DecodedToken sz :: Int
sz (I# n# :: Int#
n#) ->
case (Int#
n# Int# -> Int# -> Int#
># 0x7f#) Int# -> Int# -> Int#
`orI#` (Int#
n# Int# -> Int# -> Int#
<# -0x80#) of
0# | Int -> Int# -> Bool
isIntCanonical Int
sz Int#
n# -> Int# -> ST s (DecodeAction s a)
k Int#
n# ST s (DecodeAction s a)
-> (DecodeAction s a -> ST s (SlowPath s a)) -> ST s (SlowPath s a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs)
_ -> ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end ByteString
bs DecodeAction s a
da
go_fast !ByteString
bs da :: DecodeAction s a
da@(ConsumeInt16Canonical k :: Int# -> ST s (DecodeAction s a)
k) =
case Word8 -> ByteString -> DecodedToken Int
tryConsumeInt (ByteString -> Word8
BS.unsafeHead ByteString
bs) ByteString
bs of
DecodeFailure -> ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end ByteString
bs DecodeAction s a
da
DecodedToken sz :: Int
sz (I# n# :: Int#
n#) ->
case (Int#
n# Int# -> Int# -> Int#
># 0x7fff#) Int# -> Int# -> Int#
`orI#` (Int#
n# Int# -> Int# -> Int#
<# -0x8000#) of
0# | Int -> Int# -> Bool
isIntCanonical Int
sz Int#
n# -> Int# -> ST s (DecodeAction s a)
k Int#
n# ST s (DecodeAction s a)
-> (DecodeAction s a -> ST s (SlowPath s a)) -> ST s (SlowPath s a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs)
_ -> ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end ByteString
bs DecodeAction s a
da
go_fast !ByteString
bs da :: DecodeAction s a
da@(ConsumeInt32Canonical k :: Int# -> ST s (DecodeAction s a)
k) =
case Word8 -> ByteString -> DecodedToken Int
tryConsumeInt (ByteString -> Word8
BS.unsafeHead ByteString
bs) ByteString
bs of
DecodeFailure -> ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end ByteString
bs DecodeAction s a
da
DecodedToken sz :: Int
sz (I# n# :: Int#
n#) ->
case Int# -> Int#
n_out_of_range Int#
n# of
0# | Int -> Int# -> Bool
isIntCanonical Int
sz Int#
n# -> Int# -> ST s (DecodeAction s a)
k Int#
n# ST s (DecodeAction s a)
-> (DecodeAction s a -> ST s (SlowPath s a)) -> ST s (SlowPath s a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs)
_ -> ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end ByteString
bs DecodeAction s a
da
where
n_out_of_range :: Int# -> Int#
n_out_of_range :: Int# -> Int#
n_out_of_range _n# :: Int#
_n# =
#if defined(ARCH_32bit)
0#
#else
(_n# ># 0x7fffffff#) `orI#` (_n# <# -0x80000000#)
#endif
go_fast !ByteString
bs da :: DecodeAction s a
da@(ConsumeListLenCanonical k :: Int# -> ST s (DecodeAction s a)
k) =
case Word8 -> ByteString -> DecodedToken Int
tryConsumeListLen (ByteString -> Word8
BS.unsafeHead ByteString
bs) ByteString
bs of
DecodeFailure -> ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end ByteString
bs DecodeAction s a
da
DecodedToken sz :: Int
sz (I# n# :: Int#
n#)
| Int -> Word# -> Bool
isWordCanonical Int
sz (Int# -> Word#
int2Word# Int#
n#) -> Int# -> ST s (DecodeAction s a)
k Int#
n# ST s (DecodeAction s a)
-> (DecodeAction s a -> ST s (SlowPath s a)) -> ST s (SlowPath s a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs)
| Bool
otherwise -> ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end ByteString
bs DecodeAction s a
da
go_fast !ByteString
bs da :: DecodeAction s a
da@(ConsumeMapLenCanonical k :: Int# -> ST s (DecodeAction s a)
k) =
case Word8 -> ByteString -> DecodedToken Int
tryConsumeMapLen (ByteString -> Word8
BS.unsafeHead ByteString
bs) ByteString
bs of
DecodeFailure -> ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end ByteString
bs DecodeAction s a
da
DecodedToken sz :: Int
sz (I# n# :: Int#
n#)
| Int -> Word# -> Bool
isWordCanonical Int
sz (Int# -> Word#
int2Word# Int#
n#) -> Int# -> ST s (DecodeAction s a)
k Int#
n# ST s (DecodeAction s a)
-> (DecodeAction s a -> ST s (SlowPath s a)) -> ST s (SlowPath s a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs)
| Bool
otherwise -> ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end ByteString
bs DecodeAction s a
da
go_fast !ByteString
bs da :: DecodeAction s a
da@(ConsumeTagCanonical k :: Word# -> ST s (DecodeAction s a)
k) =
case Word8 -> ByteString -> DecodedToken Word
tryConsumeTag (ByteString -> Word8
BS.unsafeHead ByteString
bs) ByteString
bs of
DecodeFailure -> ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end ByteString
bs DecodeAction s a
da
DecodedToken sz :: Int
sz (W# w# :: Word#
w#)
| Int -> Word# -> Bool
isWordCanonical Int
sz Word#
w# -> Word# -> ST s (DecodeAction s a)
k Word#
w# ST s (DecodeAction s a)
-> (DecodeAction s a -> ST s (SlowPath s a)) -> ST s (SlowPath s a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs)
| Bool
otherwise -> ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end ByteString
bs DecodeAction s a
da
#if defined(ARCH_32bit)
go_fast !ByteString
bs da :: DecodeAction s a
da@(ConsumeWord64 k :: Word64# -> ST s (DecodeAction s a)
k) =
case Word8 -> ByteString -> DecodedToken Word64
tryConsumeWord64 (ByteString -> Word8
BS.unsafeHead ByteString
bs) ByteString
bs of
DecodeFailure -> ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end ByteString
bs DecodeAction s a
da
DecodedToken sz :: Int
sz (W64# w# :: Word64#
w#) -> Word64# -> ST s (DecodeAction s a)
k Word64#
w# ST s (DecodeAction s a)
-> (DecodeAction s a -> ST s (SlowPath s a)) -> ST s (SlowPath s a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs)
go_fast !ByteString
bs da :: DecodeAction s a
da@(ConsumeNegWord64 k :: Word64# -> ST s (DecodeAction s a)
k) =
case Word8 -> ByteString -> DecodedToken Word64
tryConsumeNegWord64 (ByteString -> Word8
BS.unsafeHead ByteString
bs) ByteString
bs of
DecodeFailure -> ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end ByteString
bs DecodeAction s a
da
DecodedToken sz :: Int
sz (W64# w# :: Word64#
w#) -> Word64# -> ST s (DecodeAction s a)
k Word64#
w# ST s (DecodeAction s a)
-> (DecodeAction s a -> ST s (SlowPath s a)) -> ST s (SlowPath s a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs)
go_fast !ByteString
bs da :: DecodeAction s a
da@(ConsumeInt64 k :: Int64# -> ST s (DecodeAction s a)
k) =
case Word8 -> ByteString -> DecodedToken ByteOffset
tryConsumeInt64 (ByteString -> Word8
BS.unsafeHead ByteString
bs) ByteString
bs of
DecodeFailure -> ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end ByteString
bs DecodeAction s a
da
DecodedToken sz :: Int
sz (I64# i# :: Int64#
i#) -> Int64# -> ST s (DecodeAction s a)
k Int64#
i# ST s (DecodeAction s a)
-> (DecodeAction s a -> ST s (SlowPath s a)) -> ST s (SlowPath s a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs)
go_fast !ByteString
bs da :: DecodeAction s a
da@(ConsumeListLen64 k :: Int64# -> ST s (DecodeAction s a)
k) =
case Word8 -> ByteString -> DecodedToken ByteOffset
tryConsumeListLen64 (ByteString -> Word8
BS.unsafeHead ByteString
bs) ByteString
bs of
DecodeFailure -> ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end ByteString
bs DecodeAction s a
da
DecodedToken sz :: Int
sz (I64# i# :: Int64#
i#) -> Int64# -> ST s (DecodeAction s a)
k Int64#
i# ST s (DecodeAction s a)
-> (DecodeAction s a -> ST s (SlowPath s a)) -> ST s (SlowPath s a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs)
go_fast !ByteString
bs da :: DecodeAction s a
da@(ConsumeMapLen64 k :: Int64# -> ST s (DecodeAction s a)
k) =
case Word8 -> ByteString -> DecodedToken ByteOffset
tryConsumeMapLen64 (ByteString -> Word8
BS.unsafeHead ByteString
bs) ByteString
bs of
DecodeFailure -> ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end ByteString
bs DecodeAction s a
da
DecodedToken sz :: Int
sz (I64# i# :: Int64#
i#) -> Int64# -> ST s (DecodeAction s a)
k Int64#
i# ST s (DecodeAction s a)
-> (DecodeAction s a -> ST s (SlowPath s a)) -> ST s (SlowPath s a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs)
go_fast !ByteString
bs da :: DecodeAction s a
da@(ConsumeTag64 k :: Word64# -> ST s (DecodeAction s a)
k) =
case Word8 -> ByteString -> DecodedToken Word64
tryConsumeTag64 (ByteString -> Word8
BS.unsafeHead ByteString
bs) ByteString
bs of
DecodeFailure -> ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end ByteString
bs DecodeAction s a
da
DecodedToken sz :: Int
sz (W64# w# :: Word64#
w#) -> Word64# -> ST s (DecodeAction s a)
k Word64#
w# ST s (DecodeAction s a)
-> (DecodeAction s a -> ST s (SlowPath s a)) -> ST s (SlowPath s a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs)
go_fast !ByteString
bs da :: DecodeAction s a
da@(ConsumeWord64Canonical k :: Word64# -> ST s (DecodeAction s a)
k) =
case Word8 -> ByteString -> DecodedToken Word64
tryConsumeWord64 (ByteString -> Word8
BS.unsafeHead ByteString
bs) ByteString
bs of
DecodeFailure -> ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end ByteString
bs DecodeAction s a
da
DecodedToken sz :: Int
sz (W64# w# :: Word64#
w#)
| Int -> Word64# -> Bool
isWord64Canonical Int
sz Word64#
w# -> Word64# -> ST s (DecodeAction s a)
k Word64#
w# ST s (DecodeAction s a)
-> (DecodeAction s a -> ST s (SlowPath s a)) -> ST s (SlowPath s a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs)
| Bool
otherwise -> ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end ByteString
bs DecodeAction s a
da
go_fast !ByteString
bs da :: DecodeAction s a
da@(ConsumeNegWord64Canonical k :: Word64# -> ST s (DecodeAction s a)
k) =
case Word8 -> ByteString -> DecodedToken Word64
tryConsumeNegWord64 (ByteString -> Word8
BS.unsafeHead ByteString
bs) ByteString
bs of
DecodeFailure -> ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end ByteString
bs DecodeAction s a
da
DecodedToken sz :: Int
sz (W64# w# :: Word64#
w#)
| Int -> Word64# -> Bool
isWord64Canonical Int
sz Word64#
w# -> Word64# -> ST s (DecodeAction s a)
k Word64#
w# ST s (DecodeAction s a)
-> (DecodeAction s a -> ST s (SlowPath s a)) -> ST s (SlowPath s a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs)
| Bool
otherwise -> ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end ByteString
bs DecodeAction s a
da
go_fast !ByteString
bs da :: DecodeAction s a
da@(ConsumeInt64Canonical k :: Int64# -> ST s (DecodeAction s a)
k) =
case Word8 -> ByteString -> DecodedToken ByteOffset
tryConsumeInt64 (ByteString -> Word8
BS.unsafeHead ByteString
bs) ByteString
bs of
DecodeFailure -> ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end ByteString
bs DecodeAction s a
da
DecodedToken sz :: Int
sz (I64# i# :: Int64#
i#)
| Int -> Int64# -> Bool
isInt64Canonical Int
sz Int64#
i# -> Int64# -> ST s (DecodeAction s a)
k Int64#
i# ST s (DecodeAction s a)
-> (DecodeAction s a -> ST s (SlowPath s a)) -> ST s (SlowPath s a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs)
| Bool
otherwise -> ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end ByteString
bs DecodeAction s a
da
go_fast !ByteString
bs da :: DecodeAction s a
da@(ConsumeListLen64Canonical k :: Int64# -> ST s (DecodeAction s a)
k) =
case Word8 -> ByteString -> DecodedToken ByteOffset
tryConsumeListLen64 (ByteString -> Word8
BS.unsafeHead ByteString
bs) ByteString
bs of
DecodeFailure -> ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end ByteString
bs DecodeAction s a
da
DecodedToken sz :: Int
sz (I64# i# :: Int64#
i#)
| Int -> Word64# -> Bool
isWord64Canonical Int
sz (Int64# -> Word64#
int64ToWord64# Int64#
i#) -> Int64# -> ST s (DecodeAction s a)
k Int64#
i# ST s (DecodeAction s a)
-> (DecodeAction s a -> ST s (SlowPath s a)) -> ST s (SlowPath s a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs)
| Bool
otherwise -> ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end ByteString
bs DecodeAction s a
da
go_fast !ByteString
bs da :: DecodeAction s a
da@(ConsumeMapLen64Canonical k :: Int64# -> ST s (DecodeAction s a)
k) =
case Word8 -> ByteString -> DecodedToken ByteOffset
tryConsumeMapLen64 (ByteString -> Word8
BS.unsafeHead ByteString
bs) ByteString
bs of
DecodeFailure -> ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end ByteString
bs DecodeAction s a
da
DecodedToken sz :: Int
sz (I64# i# :: Int64#
i#)
| Int -> Word64# -> Bool
isWord64Canonical Int
sz (Int64# -> Word64#
int64ToWord64# Int64#
i#) -> Int64# -> ST s (DecodeAction s a)
k Int64#
i# ST s (DecodeAction s a)
-> (DecodeAction s a -> ST s (SlowPath s a)) -> ST s (SlowPath s a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs)
| Bool
otherwise -> ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end ByteString
bs DecodeAction s a
da
go_fast !ByteString
bs da :: DecodeAction s a
da@(ConsumeTag64Canonical k :: Word64# -> ST s (DecodeAction s a)
k) =
case Word8 -> ByteString -> DecodedToken Word64
tryConsumeTag64 (ByteString -> Word8
BS.unsafeHead ByteString
bs) ByteString
bs of
DecodeFailure -> ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end ByteString
bs DecodeAction s a
da
DecodedToken sz :: Int
sz (W64# w# :: Word64#
w#)
| Int -> Word64# -> Bool
isWord64Canonical Int
sz Word64#
w# -> Word64# -> ST s (DecodeAction s a)
k Word64#
w# ST s (DecodeAction s a)
-> (DecodeAction s a -> ST s (SlowPath s a)) -> ST s (SlowPath s a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs)
| Bool
otherwise -> ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end ByteString
bs DecodeAction s a
da
#endif
go_fast !ByteString
bs da :: DecodeAction s a
da@(ConsumeInteger k :: Integer -> ST s (DecodeAction s a)
k) =
case Word8 -> ByteString -> DecodedToken (BigIntToken Integer)
tryConsumeInteger (ByteString -> Word8
BS.unsafeHead ByteString
bs) ByteString
bs of
DecodedToken sz :: Int
sz (BigIntToken _ n :: Integer
n) -> Integer -> ST s (DecodeAction s a)
k Integer
n ST s (DecodeAction s a)
-> (DecodeAction s a -> ST s (SlowPath s a)) -> ST s (SlowPath s a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs)
_ -> ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end ByteString
bs DecodeAction s a
da
go_fast !ByteString
bs da :: DecodeAction s a
da@(ConsumeFloat k :: Float# -> ST s (DecodeAction s a)
k) =
case Word8 -> ByteString -> DecodedToken Float
tryConsumeFloat (ByteString -> Word8
BS.unsafeHead ByteString
bs) ByteString
bs of
DecodeFailure -> ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end ByteString
bs DecodeAction s a
da
DecodedToken sz :: Int
sz (F# f# :: Float#
f#) -> Float# -> ST s (DecodeAction s a)
k Float#
f# ST s (DecodeAction s a)
-> (DecodeAction s a -> ST s (SlowPath s a)) -> ST s (SlowPath s a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs)
go_fast !ByteString
bs da :: DecodeAction s a
da@(ConsumeDouble k :: Double# -> ST s (DecodeAction s a)
k) =
case Word8 -> ByteString -> DecodedToken Double
tryConsumeDouble (ByteString -> Word8
BS.unsafeHead ByteString
bs) ByteString
bs of
DecodeFailure -> ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end ByteString
bs DecodeAction s a
da
DecodedToken sz :: Int
sz (D# f# :: Double#
f#) -> Double# -> ST s (DecodeAction s a)
k Double#
f# ST s (DecodeAction s a)
-> (DecodeAction s a -> ST s (SlowPath s a)) -> ST s (SlowPath s a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs)
go_fast !ByteString
bs da :: DecodeAction s a
da@(ConsumeBytes k :: ByteString -> ST s (DecodeAction s a)
k) =
case Word8 -> ByteString -> DecodedToken (LongToken ByteString)
tryConsumeBytes (ByteString -> Word8
BS.unsafeHead ByteString
bs) ByteString
bs of
DecodeFailure -> ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end ByteString
bs DecodeAction s a
da
DecodedToken sz :: Int
sz (Fits _ bstr :: ByteString
bstr) -> ByteString -> ST s (DecodeAction s a)
k ByteString
bstr ST s (DecodeAction s a)
-> (DecodeAction s a -> ST s (SlowPath s a)) -> ST s (SlowPath s a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs)
DecodedToken sz :: Int
sz (TooLong _ len :: Int
len) -> SlowPath s a -> ST s (SlowPath s a)
forall (m :: * -> *) a. Monad m => a -> m a
return (SlowPath s a -> ST s (SlowPath s a))
-> SlowPath s a -> ST s (SlowPath s a)
forall a b. (a -> b) -> a -> b
$! ByteString
-> (ByteString -> ST s (DecodeAction s a)) -> Int -> SlowPath s a
forall s a.
ByteString
-> (ByteString -> ST s (DecodeAction s a)) -> Int -> SlowPath s a
SlowConsumeTokenBytes
(Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs) ByteString -> ST s (DecodeAction s a)
k Int
len
go_fast !ByteString
bs da :: DecodeAction s a
da@(ConsumeByteArray k :: ByteArray -> ST s (DecodeAction s a)
k) =
case Word8 -> ByteString -> DecodedToken (LongToken ByteString)
tryConsumeBytes (ByteString -> Word8
BS.unsafeHead ByteString
bs) ByteString
bs of
DecodeFailure -> ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end ByteString
bs DecodeAction s a
da
DecodedToken sz :: Int
sz (Fits _ str :: ByteString
str) -> ByteArray -> ST s (DecodeAction s a)
k (ByteString -> ByteArray
BA.fromByteString ByteString
str) ST s (DecodeAction s a)
-> (DecodeAction s a -> ST s (SlowPath s a)) -> ST s (SlowPath s a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs)
DecodedToken sz :: Int
sz (TooLong _ len :: Int
len) -> SlowPath s a -> ST s (SlowPath s a)
forall (m :: * -> *) a. Monad m => a -> m a
return (SlowPath s a -> ST s (SlowPath s a))
-> SlowPath s a -> ST s (SlowPath s a)
forall a b. (a -> b) -> a -> b
$! ByteString
-> (ByteArray -> ST s (DecodeAction s a)) -> Int -> SlowPath s a
forall s a.
ByteString
-> (ByteArray -> ST s (DecodeAction s a)) -> Int -> SlowPath s a
SlowConsumeTokenByteArray
(Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs) ByteArray -> ST s (DecodeAction s a)
k Int
len
go_fast !ByteString
bs da :: DecodeAction s a
da@(ConsumeString k :: Text -> ST s (DecodeAction s a)
k) =
case Word8 -> ByteString -> DecodedToken (LongToken ByteString)
tryConsumeString (ByteString -> Word8
BS.unsafeHead ByteString
bs) ByteString
bs of
DecodeFailure -> ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end ByteString
bs DecodeAction s a
da
DecodedToken sz :: Int
sz (Fits _ str :: ByteString
str) -> case ByteString -> Either UnicodeException Text
T.decodeUtf8' ByteString
str of
Right t :: Text
t -> Text -> ST s (DecodeAction s a)
k Text
t ST s (DecodeAction s a)
-> (DecodeAction s a -> ST s (SlowPath s a)) -> ST s (SlowPath s a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs)
Left _e :: UnicodeException
_e -> SlowPath s a -> ST s (SlowPath s a)
forall (m :: * -> *) a. Monad m => a -> m a
return (SlowPath s a -> ST s (SlowPath s a))
-> SlowPath s a -> ST s (SlowPath s a)
forall a b. (a -> b) -> a -> b
$! ByteString -> String -> SlowPath s a
forall s a. ByteString -> String -> SlowPath s a
SlowFail ByteString
bs "invalid UTF8"
DecodedToken sz :: Int
sz (TooLong _ len :: Int
len) -> SlowPath s a -> ST s (SlowPath s a)
forall (m :: * -> *) a. Monad m => a -> m a
return (SlowPath s a -> ST s (SlowPath s a))
-> SlowPath s a -> ST s (SlowPath s a)
forall a b. (a -> b) -> a -> b
$! ByteString
-> (Text -> ST s (DecodeAction s a)) -> Int -> SlowPath s a
forall s a.
ByteString
-> (Text -> ST s (DecodeAction s a)) -> Int -> SlowPath s a
SlowConsumeTokenString
(Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs) Text -> ST s (DecodeAction s a)
k Int
len
go_fast !ByteString
bs da :: DecodeAction s a
da@(ConsumeUtf8ByteArray k :: ByteArray -> ST s (DecodeAction s a)
k) =
case Word8 -> ByteString -> DecodedToken (LongToken ByteString)
tryConsumeString (ByteString -> Word8
BS.unsafeHead ByteString
bs) ByteString
bs of
DecodeFailure -> ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end ByteString
bs DecodeAction s a
da
DecodedToken sz :: Int
sz (Fits _ str :: ByteString
str) -> ByteArray -> ST s (DecodeAction s a)
k (ByteString -> ByteArray
BA.fromByteString ByteString
str)
ST s (DecodeAction s a)
-> (DecodeAction s a -> ST s (SlowPath s a)) -> ST s (SlowPath s a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs)
DecodedToken sz :: Int
sz (TooLong _ len :: Int
len) -> SlowPath s a -> ST s (SlowPath s a)
forall (m :: * -> *) a. Monad m => a -> m a
return (SlowPath s a -> ST s (SlowPath s a))
-> SlowPath s a -> ST s (SlowPath s a)
forall a b. (a -> b) -> a -> b
$! ByteString
-> (ByteArray -> ST s (DecodeAction s a)) -> Int -> SlowPath s a
forall s a.
ByteString
-> (ByteArray -> ST s (DecodeAction s a)) -> Int -> SlowPath s a
SlowConsumeTokenUtf8ByteArray
(Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs) ByteArray -> ST s (DecodeAction s a)
k Int
len
go_fast !ByteString
bs da :: DecodeAction s a
da@(ConsumeBool k :: Bool -> ST s (DecodeAction s a)
k) =
case Word8 -> DecodedToken Bool
tryConsumeBool (ByteString -> Word8
BS.unsafeHead ByteString
bs) of
DecodeFailure -> ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end ByteString
bs DecodeAction s a
da
DecodedToken sz :: Int
sz b :: Bool
b -> Bool -> ST s (DecodeAction s a)
k Bool
b ST s (DecodeAction s a)
-> (DecodeAction s a -> ST s (SlowPath s a)) -> ST s (SlowPath s a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs)
go_fast !ByteString
bs da :: DecodeAction s a
da@(ConsumeSimple k :: Word# -> ST s (DecodeAction s a)
k) =
case Word8 -> ByteString -> DecodedToken Word
tryConsumeSimple (ByteString -> Word8
BS.unsafeHead ByteString
bs) ByteString
bs of
DecodeFailure -> ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end ByteString
bs DecodeAction s a
da
DecodedToken sz :: Int
sz (W# w# :: Word#
w#) -> Word# -> ST s (DecodeAction s a)
k Word#
w# ST s (DecodeAction s a)
-> (DecodeAction s a -> ST s (SlowPath s a)) -> ST s (SlowPath s a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs)
go_fast !ByteString
bs da :: DecodeAction s a
da@(ConsumeIntegerCanonical k :: Integer -> ST s (DecodeAction s a)
k) =
case Word8 -> ByteString -> DecodedToken (BigIntToken Integer)
tryConsumeInteger (ByteString -> Word8
BS.unsafeHead ByteString
bs) ByteString
bs of
DecodedToken sz :: Int
sz (BigIntToken True n :: Integer
n) -> Integer -> ST s (DecodeAction s a)
k Integer
n ST s (DecodeAction s a)
-> (DecodeAction s a -> ST s (SlowPath s a)) -> ST s (SlowPath s a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs)
_ -> ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end ByteString
bs DecodeAction s a
da
go_fast !ByteString
bs da :: DecodeAction s a
da@(ConsumeFloat16Canonical k :: Float# -> ST s (DecodeAction s a)
k) =
case Word8 -> ByteString -> DecodedToken Float
tryConsumeFloat (ByteString -> Word8
BS.unsafeHead ByteString
bs) ByteString
bs of
DecodeFailure -> ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end ByteString
bs DecodeAction s a
da
DecodedToken sz :: Int
sz f :: Float
f@(F# f# :: Float#
f#)
| Int -> ByteString -> Float -> Bool
isFloat16Canonical Int
sz ByteString
bs Float
f -> Float# -> ST s (DecodeAction s a)
k Float#
f# ST s (DecodeAction s a)
-> (DecodeAction s a -> ST s (SlowPath s a)) -> ST s (SlowPath s a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs)
| Bool
otherwise -> ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end ByteString
bs DecodeAction s a
da
go_fast !ByteString
bs da :: DecodeAction s a
da@(ConsumeFloatCanonical k :: Float# -> ST s (DecodeAction s a)
k) =
case Word8 -> ByteString -> DecodedToken Float
tryConsumeFloat (ByteString -> Word8
BS.unsafeHead ByteString
bs) ByteString
bs of
DecodeFailure -> ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end ByteString
bs DecodeAction s a
da
DecodedToken sz :: Int
sz f :: Float
f@(F# f# :: Float#
f#)
| Int -> ByteString -> Float -> Bool
isFloatCanonical Int
sz ByteString
bs Float
f -> Float# -> ST s (DecodeAction s a)
k Float#
f# ST s (DecodeAction s a)
-> (DecodeAction s a -> ST s (SlowPath s a)) -> ST s (SlowPath s a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs)
| Bool
otherwise -> ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end ByteString
bs DecodeAction s a
da
go_fast !ByteString
bs da :: DecodeAction s a
da@(ConsumeDoubleCanonical k :: Double# -> ST s (DecodeAction s a)
k) =
case Word8 -> ByteString -> DecodedToken Double
tryConsumeDouble (ByteString -> Word8
BS.unsafeHead ByteString
bs) ByteString
bs of
DecodeFailure -> ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end ByteString
bs DecodeAction s a
da
DecodedToken sz :: Int
sz f :: Double
f@(D# f# :: Double#
f#)
| Int -> ByteString -> Double -> Bool
isDoubleCanonical Int
sz ByteString
bs Double
f -> Double# -> ST s (DecodeAction s a)
k Double#
f# ST s (DecodeAction s a)
-> (DecodeAction s a -> ST s (SlowPath s a)) -> ST s (SlowPath s a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs)
| Bool
otherwise -> ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end ByteString
bs DecodeAction s a
da
go_fast !ByteString
bs da :: DecodeAction s a
da@(ConsumeBytesCanonical k :: ByteString -> ST s (DecodeAction s a)
k) =
case Word8 -> ByteString -> DecodedToken (LongToken ByteString)
tryConsumeBytes (ByteString -> Word8
BS.unsafeHead ByteString
bs) ByteString
bs of
DecodedToken sz :: Int
sz (Fits True bstr :: ByteString
bstr) -> ByteString -> ST s (DecodeAction s a)
k ByteString
bstr ST s (DecodeAction s a)
-> (DecodeAction s a -> ST s (SlowPath s a)) -> ST s (SlowPath s a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs)
DecodedToken sz :: Int
sz (TooLong True len :: Int
len) ->
SlowPath s a -> ST s (SlowPath s a)
forall (m :: * -> *) a. Monad m => a -> m a
return (SlowPath s a -> ST s (SlowPath s a))
-> SlowPath s a -> ST s (SlowPath s a)
forall a b. (a -> b) -> a -> b
$! ByteString
-> (ByteString -> ST s (DecodeAction s a)) -> Int -> SlowPath s a
forall s a.
ByteString
-> (ByteString -> ST s (DecodeAction s a)) -> Int -> SlowPath s a
SlowConsumeTokenBytes (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs) ByteString -> ST s (DecodeAction s a)
k Int
len
_ -> ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end ByteString
bs DecodeAction s a
da
go_fast !ByteString
bs da :: DecodeAction s a
da@(ConsumeByteArrayCanonical k :: ByteArray -> ST s (DecodeAction s a)
k) =
case Word8 -> ByteString -> DecodedToken (LongToken ByteString)
tryConsumeBytes (ByteString -> Word8
BS.unsafeHead ByteString
bs) ByteString
bs of
DecodedToken sz :: Int
sz (Fits True str :: ByteString
str) ->
ByteArray -> ST s (DecodeAction s a)
k (ByteString -> ByteArray
BA.fromByteString ByteString
str) ST s (DecodeAction s a)
-> (DecodeAction s a -> ST s (SlowPath s a)) -> ST s (SlowPath s a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs)
DecodedToken sz :: Int
sz (TooLong True len :: Int
len) ->
SlowPath s a -> ST s (SlowPath s a)
forall (m :: * -> *) a. Monad m => a -> m a
return (SlowPath s a -> ST s (SlowPath s a))
-> SlowPath s a -> ST s (SlowPath s a)
forall a b. (a -> b) -> a -> b
$! ByteString
-> (ByteArray -> ST s (DecodeAction s a)) -> Int -> SlowPath s a
forall s a.
ByteString
-> (ByteArray -> ST s (DecodeAction s a)) -> Int -> SlowPath s a
SlowConsumeTokenByteArray (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs) ByteArray -> ST s (DecodeAction s a)
k Int
len
_ -> ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end ByteString
bs DecodeAction s a
da
go_fast !ByteString
bs da :: DecodeAction s a
da@(ConsumeStringCanonical k :: Text -> ST s (DecodeAction s a)
k) =
case Word8 -> ByteString -> DecodedToken (LongToken ByteString)
tryConsumeString (ByteString -> Word8
BS.unsafeHead ByteString
bs) ByteString
bs of
DecodedToken sz :: Int
sz (Fits True str :: ByteString
str) -> case ByteString -> Either UnicodeException Text
T.decodeUtf8' ByteString
str of
Right t :: Text
t -> Text -> ST s (DecodeAction s a)
k Text
t ST s (DecodeAction s a)
-> (DecodeAction s a -> ST s (SlowPath s a)) -> ST s (SlowPath s a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs)
Left _e :: UnicodeException
_e -> SlowPath s a -> ST s (SlowPath s a)
forall (m :: * -> *) a. Monad m => a -> m a
return (SlowPath s a -> ST s (SlowPath s a))
-> SlowPath s a -> ST s (SlowPath s a)
forall a b. (a -> b) -> a -> b
$! ByteString -> String -> SlowPath s a
forall s a. ByteString -> String -> SlowPath s a
SlowFail ByteString
bs "invalid UTF8"
DecodedToken sz :: Int
sz (TooLong True len :: Int
len) ->
SlowPath s a -> ST s (SlowPath s a)
forall (m :: * -> *) a. Monad m => a -> m a
return (SlowPath s a -> ST s (SlowPath s a))
-> SlowPath s a -> ST s (SlowPath s a)
forall a b. (a -> b) -> a -> b
$! ByteString
-> (Text -> ST s (DecodeAction s a)) -> Int -> SlowPath s a
forall s a.
ByteString
-> (Text -> ST s (DecodeAction s a)) -> Int -> SlowPath s a
SlowConsumeTokenString (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs) Text -> ST s (DecodeAction s a)
k Int
len
_ -> ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end ByteString
bs DecodeAction s a
da
go_fast !ByteString
bs da :: DecodeAction s a
da@(ConsumeUtf8ByteArrayCanonical k :: ByteArray -> ST s (DecodeAction s a)
k) =
case Word8 -> ByteString -> DecodedToken (LongToken ByteString)
tryConsumeString (ByteString -> Word8
BS.unsafeHead ByteString
bs) ByteString
bs of
DecodedToken sz :: Int
sz (Fits True str :: ByteString
str) ->
ByteArray -> ST s (DecodeAction s a)
k (ByteString -> ByteArray
BA.fromByteString ByteString
str) ST s (DecodeAction s a)
-> (DecodeAction s a -> ST s (SlowPath s a)) -> ST s (SlowPath s a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs)
DecodedToken sz :: Int
sz (TooLong True len :: Int
len) ->
SlowPath s a -> ST s (SlowPath s a)
forall (m :: * -> *) a. Monad m => a -> m a
return (SlowPath s a -> ST s (SlowPath s a))
-> SlowPath s a -> ST s (SlowPath s a)
forall a b. (a -> b) -> a -> b
$! ByteString
-> (ByteArray -> ST s (DecodeAction s a)) -> Int -> SlowPath s a
forall s a.
ByteString
-> (ByteArray -> ST s (DecodeAction s a)) -> Int -> SlowPath s a
SlowConsumeTokenUtf8ByteArray (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs) ByteArray -> ST s (DecodeAction s a)
k Int
len
_ -> ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end ByteString
bs DecodeAction s a
da
go_fast !ByteString
bs da :: DecodeAction s a
da@(ConsumeSimpleCanonical k :: Word# -> ST s (DecodeAction s a)
k) =
case Word8 -> ByteString -> DecodedToken Word
tryConsumeSimple (ByteString -> Word8
BS.unsafeHead ByteString
bs) ByteString
bs of
DecodeFailure -> ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end ByteString
bs DecodeAction s a
da
DecodedToken sz :: Int
sz (W# w# :: Word#
w#)
| Int -> Word# -> Bool
isSimpleCanonical Int
sz Word#
w# -> Word# -> ST s (DecodeAction s a)
k Word#
w# ST s (DecodeAction s a)
-> (DecodeAction s a -> ST s (SlowPath s a)) -> ST s (SlowPath s a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs)
| Bool
otherwise -> ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end ByteString
bs DecodeAction s a
da
go_fast !ByteString
bs da :: DecodeAction s a
da@(ConsumeBytesIndef k :: ST s (DecodeAction s a)
k) =
case Word8 -> DecodedToken ()
tryConsumeBytesIndef (ByteString -> Word8
BS.unsafeHead ByteString
bs) of
DecodeFailure -> ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end ByteString
bs DecodeAction s a
da
DecodedToken sz :: Int
sz _ -> ST s (DecodeAction s a)
k ST s (DecodeAction s a)
-> (DecodeAction s a -> ST s (SlowPath s a)) -> ST s (SlowPath s a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs)
go_fast !ByteString
bs da :: DecodeAction s a
da@(ConsumeStringIndef k :: ST s (DecodeAction s a)
k) =
case Word8 -> DecodedToken ()
tryConsumeStringIndef (ByteString -> Word8
BS.unsafeHead ByteString
bs) of
DecodeFailure -> ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end ByteString
bs DecodeAction s a
da
DecodedToken sz :: Int
sz _ -> ST s (DecodeAction s a)
k ST s (DecodeAction s a)
-> (DecodeAction s a -> ST s (SlowPath s a)) -> ST s (SlowPath s a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs)
go_fast !ByteString
bs da :: DecodeAction s a
da@(ConsumeListLenIndef k :: ST s (DecodeAction s a)
k) =
case Word8 -> DecodedToken ()
tryConsumeListLenIndef (ByteString -> Word8
BS.unsafeHead ByteString
bs) of
DecodeFailure -> ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end ByteString
bs DecodeAction s a
da
DecodedToken sz :: Int
sz _ -> ST s (DecodeAction s a)
k ST s (DecodeAction s a)
-> (DecodeAction s a -> ST s (SlowPath s a)) -> ST s (SlowPath s a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs)
go_fast !ByteString
bs da :: DecodeAction s a
da@(ConsumeMapLenIndef k :: ST s (DecodeAction s a)
k) =
case Word8 -> DecodedToken ()
tryConsumeMapLenIndef (ByteString -> Word8
BS.unsafeHead ByteString
bs) of
DecodeFailure -> ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end ByteString
bs DecodeAction s a
da
DecodedToken sz :: Int
sz _ -> ST s (DecodeAction s a)
k ST s (DecodeAction s a)
-> (DecodeAction s a -> ST s (SlowPath s a)) -> ST s (SlowPath s a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs)
go_fast !ByteString
bs da :: DecodeAction s a
da@(ConsumeNull k :: ST s (DecodeAction s a)
k) =
case Word8 -> DecodedToken ()
tryConsumeNull (ByteString -> Word8
BS.unsafeHead ByteString
bs) of
DecodeFailure -> ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end ByteString
bs DecodeAction s a
da
DecodedToken sz :: Int
sz _ -> ST s (DecodeAction s a)
k ST s (DecodeAction s a)
-> (DecodeAction s a -> ST s (SlowPath s a)) -> ST s (SlowPath s a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs)
go_fast !ByteString
bs da :: DecodeAction s a
da@(ConsumeListLenOrIndef k :: Int# -> ST s (DecodeAction s a)
k) =
case Word8 -> ByteString -> DecodedToken Int
tryConsumeListLenOrIndef (ByteString -> Word8
BS.unsafeHead ByteString
bs) ByteString
bs of
DecodeFailure -> ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end ByteString
bs DecodeAction s a
da
DecodedToken sz :: Int
sz (I# n# :: Int#
n#) -> Int# -> ST s (DecodeAction s a)
k Int#
n# ST s (DecodeAction s a)
-> (DecodeAction s a -> ST s (SlowPath s a)) -> ST s (SlowPath s a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs)
go_fast !ByteString
bs da :: DecodeAction s a
da@(ConsumeMapLenOrIndef k :: Int# -> ST s (DecodeAction s a)
k) =
case Word8 -> ByteString -> DecodedToken Int
tryConsumeMapLenOrIndef (ByteString -> Word8
BS.unsafeHead ByteString
bs) ByteString
bs of
DecodeFailure -> ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end ByteString
bs DecodeAction s a
da
DecodedToken sz :: Int
sz (I# n# :: Int#
n#) -> Int# -> ST s (DecodeAction s a)
k Int#
n# ST s (DecodeAction s a)
-> (DecodeAction s a -> ST s (SlowPath s a)) -> ST s (SlowPath s a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs)
go_fast !ByteString
bs (ConsumeBreakOr k :: Bool -> ST s (DecodeAction s a)
k) =
case Word8 -> DecodedToken ()
tryConsumeBreakOr (ByteString -> Word8
BS.unsafeHead ByteString
bs) of
DecodeFailure -> Bool -> ST s (DecodeAction s a)
k Bool
False ST s (DecodeAction s a)
-> (DecodeAction s a -> ST s (SlowPath s a)) -> ST s (SlowPath s a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast ByteString
bs
DecodedToken sz :: Int
sz _ -> Bool -> ST s (DecodeAction s a)
k Bool
True ST s (DecodeAction s a)
-> (DecodeAction s a -> ST s (SlowPath s a)) -> ST s (SlowPath s a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs)
go_fast !ByteString
bs (PeekTokenType k :: TokenType -> ST s (DecodeAction s a)
k) =
let !hdr :: Word8
hdr = ByteString -> Word8
BS.unsafeHead ByteString
bs
!tkty :: TokenType
tkty = Array Word8 TokenType
decodeTokenTypeTable Array Word8 TokenType -> Int -> TokenType
forall (a :: * -> * -> *) e i.
(IArray a e, Ix i) =>
a i e -> Int -> e
`A.unsafeAt` Word8 -> Int
word8ToInt Word8
hdr
in TokenType -> ST s (DecodeAction s a)
k TokenType
tkty ST s (DecodeAction s a)
-> (DecodeAction s a -> ST s (SlowPath s a)) -> ST s (SlowPath s a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast ByteString
bs
go_fast !ByteString
bs (PeekAvailable k :: Int# -> ST s (DecodeAction s a)
k) = Int# -> ST s (DecodeAction s a)
k (case ByteString -> Int
BS.length ByteString
bs of I# len# :: Int#
len# -> Int#
len#) ST s (DecodeAction s a)
-> (DecodeAction s a -> ST s (SlowPath s a)) -> ST s (SlowPath s a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast ByteString
bs
go_fast !ByteString
bs da :: DecodeAction s a
da@PeekByteOffset{} = ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end ByteString
bs DecodeAction s a
da
go_fast !ByteString
bs da :: DecodeAction s a
da@D.Fail{} = ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end ByteString
bs DecodeAction s a
da
go_fast !ByteString
bs da :: DecodeAction s a
da@D.Done{} = ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end ByteString
bs DecodeAction s a
da
go_fast_end :: ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end :: ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end !ByteString
bs (D.Fail msg :: String
msg) = SlowPath s a -> ST s (SlowPath s a)
forall (m :: * -> *) a. Monad m => a -> m a
return (SlowPath s a -> ST s (SlowPath s a))
-> SlowPath s a -> ST s (SlowPath s a)
forall a b. (a -> b) -> a -> b
$! ByteString -> String -> SlowPath s a
forall s a. ByteString -> String -> SlowPath s a
SlowFail ByteString
bs String
msg
go_fast_end !ByteString
bs (D.Done x :: a
x) = SlowPath s a -> ST s (SlowPath s a)
forall (m :: * -> *) a. Monad m => a -> m a
return (SlowPath s a -> ST s (SlowPath s a))
-> SlowPath s a -> ST s (SlowPath s a)
forall a b. (a -> b) -> a -> b
$! ByteString -> a -> SlowPath s a
forall s a. ByteString -> a -> SlowPath s a
FastDone ByteString
bs a
x
go_fast_end !ByteString
bs (PeekAvailable k :: Int# -> ST s (DecodeAction s a)
k) = Int# -> ST s (DecodeAction s a)
k (case ByteString -> Int
BS.length ByteString
bs of I# len# :: Int#
len# -> Int#
len#) ST s (DecodeAction s a)
-> (DecodeAction s a -> ST s (SlowPath s a)) -> ST s (SlowPath s a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end ByteString
bs
go_fast_end !ByteString
bs (PeekByteOffset k :: Int64# -> ST s (DecodeAction s a)
k) = SlowPath s a -> ST s (SlowPath s a)
forall (m :: * -> *) a. Monad m => a -> m a
return (SlowPath s a -> ST s (SlowPath s a))
-> SlowPath s a -> ST s (SlowPath s a)
forall a b. (a -> b) -> a -> b
$! ByteString -> (Int64# -> ST s (DecodeAction s a)) -> SlowPath s a
forall s a.
ByteString -> (Int64# -> ST s (DecodeAction s a)) -> SlowPath s a
SlowPeekByteOffset ByteString
bs Int64# -> ST s (DecodeAction s a)
k
go_fast_end !ByteString
bs da :: DecodeAction s a
da | ByteString -> Bool
BS.null ByteString
bs = SlowPath s a -> ST s (SlowPath s a)
forall (m :: * -> *) a. Monad m => a -> m a
return (SlowPath s a -> ST s (SlowPath s a))
-> SlowPath s a -> ST s (SlowPath s a)
forall a b. (a -> b) -> a -> b
$! ByteString -> DecodeAction s a -> SlowPath s a
forall s a. ByteString -> DecodeAction s a -> SlowPath s a
SlowDecodeAction ByteString
bs DecodeAction s a
da
go_fast_end !ByteString
bs (ConsumeBreakOr k :: Bool -> ST s (DecodeAction s a)
k) =
case Word8 -> DecodedToken ()
tryConsumeBreakOr (ByteString -> Word8
BS.unsafeHead ByteString
bs) of
DecodeFailure -> Bool -> ST s (DecodeAction s a)
k Bool
False ST s (DecodeAction s a)
-> (DecodeAction s a -> ST s (SlowPath s a)) -> ST s (SlowPath s a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end ByteString
bs
DecodedToken sz :: Int
sz _ -> Bool -> ST s (DecodeAction s a)
k Bool
True ST s (DecodeAction s a)
-> (DecodeAction s a -> ST s (SlowPath s a)) -> ST s (SlowPath s a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs)
go_fast_end !ByteString
bs (PeekTokenType k :: TokenType -> ST s (DecodeAction s a)
k) =
let !hdr :: Word8
hdr = ByteString -> Word8
BS.unsafeHead ByteString
bs
!tkty :: TokenType
tkty = Array Word8 TokenType
decodeTokenTypeTable Array Word8 TokenType -> Int -> TokenType
forall (a :: * -> * -> *) e i.
(IArray a e, Ix i) =>
a i e -> Int -> e
`A.unsafeAt` Word8 -> Int
word8ToInt Word8
hdr
in TokenType -> ST s (DecodeAction s a)
k TokenType
tkty ST s (DecodeAction s a)
-> (DecodeAction s a -> ST s (SlowPath s a)) -> ST s (SlowPath s a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end ByteString
bs
go_fast_end !ByteString
bs da :: DecodeAction s a
da
| let !hdr :: Word8
hdr = ByteString -> Word8
BS.unsafeHead ByteString
bs
, ByteString -> Int
BS.length ByteString
bs Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
< Word8 -> Int
tokenSize Word8
hdr
= SlowPath s a -> ST s (SlowPath s a)
forall (m :: * -> *) a. Monad m => a -> m a
return (SlowPath s a -> ST s (SlowPath s a))
-> SlowPath s a -> ST s (SlowPath s a)
forall a b. (a -> b) -> a -> b
$! ByteString -> DecodeAction s a -> SlowPath s a
forall s a. ByteString -> DecodeAction s a -> SlowPath s a
SlowDecodeAction ByteString
bs DecodeAction s a
da
go_fast_end !ByteString
bs (ConsumeWord k :: Word# -> ST s (DecodeAction s a)
k) =
case Word8 -> ByteString -> DecodedToken Word
tryConsumeWord (ByteString -> Word8
BS.unsafeHead ByteString
bs) ByteString
bs of
DecodeFailure -> SlowPath s a -> ST s (SlowPath s a)
forall (m :: * -> *) a. Monad m => a -> m a
return (SlowPath s a -> ST s (SlowPath s a))
-> SlowPath s a -> ST s (SlowPath s a)
forall a b. (a -> b) -> a -> b
$! ByteString -> String -> SlowPath s a
forall s a. ByteString -> String -> SlowPath s a
SlowFail ByteString
bs "expected word"
DecodedToken sz :: Int
sz (W# w# :: Word#
w#) -> Word# -> ST s (DecodeAction s a)
k Word#
w# ST s (DecodeAction s a)
-> (DecodeAction s a -> ST s (SlowPath s a)) -> ST s (SlowPath s a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs)
go_fast_end !ByteString
bs (ConsumeWord8 k :: Word# -> ST s (DecodeAction s a)
k) =
case Word8 -> ByteString -> DecodedToken Word
tryConsumeWord (ByteString -> Word8
BS.unsafeHead ByteString
bs) ByteString
bs of
DecodeFailure -> SlowPath s a -> ST s (SlowPath s a)
forall (m :: * -> *) a. Monad m => a -> m a
return (SlowPath s a -> ST s (SlowPath s a))
-> SlowPath s a -> ST s (SlowPath s a)
forall a b. (a -> b) -> a -> b
$! ByteString -> String -> SlowPath s a
forall s a. ByteString -> String -> SlowPath s a
SlowFail ByteString
bs "expected word8"
DecodedToken sz :: Int
sz (W# w# :: Word#
w#) ->
case Word# -> Word# -> Int#
gtWord# Word#
w# 0xff## of
0# -> Word# -> ST s (DecodeAction s a)
k Word#
w# ST s (DecodeAction s a)
-> (DecodeAction s a -> ST s (SlowPath s a)) -> ST s (SlowPath s a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs)
_ -> SlowPath s a -> ST s (SlowPath s a)
forall (m :: * -> *) a. Monad m => a -> m a
return (SlowPath s a -> ST s (SlowPath s a))
-> SlowPath s a -> ST s (SlowPath s a)
forall a b. (a -> b) -> a -> b
$! ByteString -> String -> SlowPath s a
forall s a. ByteString -> String -> SlowPath s a
SlowFail ByteString
bs "expected word8"
go_fast_end !ByteString
bs (ConsumeWord16 k :: Word# -> ST s (DecodeAction s a)
k) =
case Word8 -> ByteString -> DecodedToken Word
tryConsumeWord (ByteString -> Word8
BS.unsafeHead ByteString
bs) ByteString
bs of
DecodeFailure -> SlowPath s a -> ST s (SlowPath s a)
forall (m :: * -> *) a. Monad m => a -> m a
return (SlowPath s a -> ST s (SlowPath s a))
-> SlowPath s a -> ST s (SlowPath s a)
forall a b. (a -> b) -> a -> b
$! ByteString -> String -> SlowPath s a
forall s a. ByteString -> String -> SlowPath s a
SlowFail ByteString
bs "expected word16"
DecodedToken sz :: Int
sz (W# w# :: Word#
w#) ->
case Word# -> Word# -> Int#
gtWord# Word#
w# 0xffff## of
0# -> Word# -> ST s (DecodeAction s a)
k Word#
w# ST s (DecodeAction s a)
-> (DecodeAction s a -> ST s (SlowPath s a)) -> ST s (SlowPath s a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs)
_ -> SlowPath s a -> ST s (SlowPath s a)
forall (m :: * -> *) a. Monad m => a -> m a
return (SlowPath s a -> ST s (SlowPath s a))
-> SlowPath s a -> ST s (SlowPath s a)
forall a b. (a -> b) -> a -> b
$! ByteString -> String -> SlowPath s a
forall s a. ByteString -> String -> SlowPath s a
SlowFail ByteString
bs "expected word16"
go_fast_end !ByteString
bs (ConsumeWord32 k :: Word# -> ST s (DecodeAction s a)
k) =
case Word8 -> ByteString -> DecodedToken Word
tryConsumeWord (ByteString -> Word8
BS.unsafeHead ByteString
bs) ByteString
bs of
DecodeFailure -> SlowPath s a -> ST s (SlowPath s a)
forall (m :: * -> *) a. Monad m => a -> m a
return (SlowPath s a -> ST s (SlowPath s a))
-> SlowPath s a -> ST s (SlowPath s a)
forall a b. (a -> b) -> a -> b
$! ByteString -> String -> SlowPath s a
forall s a. ByteString -> String -> SlowPath s a
SlowFail ByteString
bs "expected word32"
DecodedToken sz :: Int
sz (W# w# :: Word#
w#) ->
#if defined(ARCH_32bit)
Word# -> ST s (DecodeAction s a)
k Word#
w# ST s (DecodeAction s a)
-> (DecodeAction s a -> ST s (SlowPath s a)) -> ST s (SlowPath s a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs)
#else
case gtWord# w# 0xffffffff## of
0# -> k w# >>= go_fast_end (BS.unsafeDrop sz bs)
_ -> return $! SlowFail bs "expected word32"
#endif
go_fast_end !ByteString
bs (ConsumeNegWord k :: Word# -> ST s (DecodeAction s a)
k) =
case Word8 -> ByteString -> DecodedToken Word
tryConsumeNegWord (ByteString -> Word8
BS.unsafeHead ByteString
bs) ByteString
bs of
DecodeFailure -> SlowPath s a -> ST s (SlowPath s a)
forall (m :: * -> *) a. Monad m => a -> m a
return (SlowPath s a -> ST s (SlowPath s a))
-> SlowPath s a -> ST s (SlowPath s a)
forall a b. (a -> b) -> a -> b
$! ByteString -> String -> SlowPath s a
forall s a. ByteString -> String -> SlowPath s a
SlowFail ByteString
bs "expected negative int"
DecodedToken sz :: Int
sz (W# w# :: Word#
w#) -> Word# -> ST s (DecodeAction s a)
k Word#
w# ST s (DecodeAction s a)
-> (DecodeAction s a -> ST s (SlowPath s a)) -> ST s (SlowPath s a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs)
go_fast_end !ByteString
bs (ConsumeInt k :: Int# -> ST s (DecodeAction s a)
k) =
case Word8 -> ByteString -> DecodedToken Int
tryConsumeInt (ByteString -> Word8
BS.unsafeHead ByteString
bs) ByteString
bs of
DecodeFailure -> SlowPath s a -> ST s (SlowPath s a)
forall (m :: * -> *) a. Monad m => a -> m a
return (SlowPath s a -> ST s (SlowPath s a))
-> SlowPath s a -> ST s (SlowPath s a)
forall a b. (a -> b) -> a -> b
$! ByteString -> String -> SlowPath s a
forall s a. ByteString -> String -> SlowPath s a
SlowFail ByteString
bs "expected int"
DecodedToken sz :: Int
sz (I# n# :: Int#
n#) -> Int# -> ST s (DecodeAction s a)
k Int#
n# ST s (DecodeAction s a)
-> (DecodeAction s a -> ST s (SlowPath s a)) -> ST s (SlowPath s a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs)
go_fast_end !ByteString
bs (ConsumeInt8 k :: Int# -> ST s (DecodeAction s a)
k) =
case Word8 -> ByteString -> DecodedToken Int
tryConsumeInt (ByteString -> Word8
BS.unsafeHead ByteString
bs) ByteString
bs of
DecodeFailure -> SlowPath s a -> ST s (SlowPath s a)
forall (m :: * -> *) a. Monad m => a -> m a
return (SlowPath s a -> ST s (SlowPath s a))
-> SlowPath s a -> ST s (SlowPath s a)
forall a b. (a -> b) -> a -> b
$! ByteString -> String -> SlowPath s a
forall s a. ByteString -> String -> SlowPath s a
SlowFail ByteString
bs "expected int8"
DecodedToken sz :: Int
sz (I# n# :: Int#
n#) ->
case (Int#
n# Int# -> Int# -> Int#
># 0x7f#) Int# -> Int# -> Int#
`orI#` (Int#
n# Int# -> Int# -> Int#
<# -0x80#) of
0# -> Int# -> ST s (DecodeAction s a)
k Int#
n# ST s (DecodeAction s a)
-> (DecodeAction s a -> ST s (SlowPath s a)) -> ST s (SlowPath s a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs)
_ -> SlowPath s a -> ST s (SlowPath s a)
forall (m :: * -> *) a. Monad m => a -> m a
return (SlowPath s a -> ST s (SlowPath s a))
-> SlowPath s a -> ST s (SlowPath s a)
forall a b. (a -> b) -> a -> b
$! ByteString -> String -> SlowPath s a
forall s a. ByteString -> String -> SlowPath s a
SlowFail ByteString
bs "expected int8"
go_fast_end !ByteString
bs (ConsumeInt16 k :: Int# -> ST s (DecodeAction s a)
k) =
case Word8 -> ByteString -> DecodedToken Int
tryConsumeInt (ByteString -> Word8
BS.unsafeHead ByteString
bs) ByteString
bs of
DecodeFailure -> SlowPath s a -> ST s (SlowPath s a)
forall (m :: * -> *) a. Monad m => a -> m a
return (SlowPath s a -> ST s (SlowPath s a))
-> SlowPath s a -> ST s (SlowPath s a)
forall a b. (a -> b) -> a -> b
$! ByteString -> String -> SlowPath s a
forall s a. ByteString -> String -> SlowPath s a
SlowFail ByteString
bs "expected int16"
DecodedToken sz :: Int
sz (I# n# :: Int#
n#) ->
case (Int#
n# Int# -> Int# -> Int#
># 0x7fff#) Int# -> Int# -> Int#
`orI#` (Int#
n# Int# -> Int# -> Int#
<# -0x8000#) of
0# -> Int# -> ST s (DecodeAction s a)
k Int#
n# ST s (DecodeAction s a)
-> (DecodeAction s a -> ST s (SlowPath s a)) -> ST s (SlowPath s a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs)
_ -> SlowPath s a -> ST s (SlowPath s a)
forall (m :: * -> *) a. Monad m => a -> m a
return (SlowPath s a -> ST s (SlowPath s a))
-> SlowPath s a -> ST s (SlowPath s a)
forall a b. (a -> b) -> a -> b
$! ByteString -> String -> SlowPath s a
forall s a. ByteString -> String -> SlowPath s a
SlowFail ByteString
bs "expected int16"
go_fast_end !ByteString
bs (ConsumeInt32 k :: Int# -> ST s (DecodeAction s a)
k) =
case Word8 -> ByteString -> DecodedToken Int
tryConsumeInt (ByteString -> Word8
BS.unsafeHead ByteString
bs) ByteString
bs of
DecodeFailure -> SlowPath s a -> ST s (SlowPath s a)
forall (m :: * -> *) a. Monad m => a -> m a
return (SlowPath s a -> ST s (SlowPath s a))
-> SlowPath s a -> ST s (SlowPath s a)
forall a b. (a -> b) -> a -> b
$! ByteString -> String -> SlowPath s a
forall s a. ByteString -> String -> SlowPath s a
SlowFail ByteString
bs "expected int32"
DecodedToken sz :: Int
sz (I# n# :: Int#
n#) ->
#if defined(ARCH_32bit)
Int# -> ST s (DecodeAction s a)
k Int#
n# ST s (DecodeAction s a)
-> (DecodeAction s a -> ST s (SlowPath s a)) -> ST s (SlowPath s a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs)
#else
case (n# ># 0x7fffffff#) `orI#` (n# <# -0x80000000#) of
0# -> k n# >>= go_fast_end (BS.unsafeDrop sz bs)
_ -> return $! SlowFail bs "expected int32"
#endif
go_fast_end !ByteString
bs (ConsumeListLen k :: Int# -> ST s (DecodeAction s a)
k) =
case Word8 -> ByteString -> DecodedToken Int
tryConsumeListLen (ByteString -> Word8
BS.unsafeHead ByteString
bs) ByteString
bs of
DecodeFailure -> SlowPath s a -> ST s (SlowPath s a)
forall (m :: * -> *) a. Monad m => a -> m a
return (SlowPath s a -> ST s (SlowPath s a))
-> SlowPath s a -> ST s (SlowPath s a)
forall a b. (a -> b) -> a -> b
$! ByteString -> String -> SlowPath s a
forall s a. ByteString -> String -> SlowPath s a
SlowFail ByteString
bs "expected list len"
DecodedToken sz :: Int
sz (I# n# :: Int#
n#) -> Int# -> ST s (DecodeAction s a)
k Int#
n# ST s (DecodeAction s a)
-> (DecodeAction s a -> ST s (SlowPath s a)) -> ST s (SlowPath s a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs)
go_fast_end !ByteString
bs (ConsumeMapLen k :: Int# -> ST s (DecodeAction s a)
k) =
case Word8 -> ByteString -> DecodedToken Int
tryConsumeMapLen (ByteString -> Word8
BS.unsafeHead ByteString
bs) ByteString
bs of
DecodeFailure -> SlowPath s a -> ST s (SlowPath s a)
forall (m :: * -> *) a. Monad m => a -> m a
return (SlowPath s a -> ST s (SlowPath s a))
-> SlowPath s a -> ST s (SlowPath s a)
forall a b. (a -> b) -> a -> b
$! ByteString -> String -> SlowPath s a
forall s a. ByteString -> String -> SlowPath s a
SlowFail ByteString
bs "expected map len"
DecodedToken sz :: Int
sz (I# n# :: Int#
n#) -> Int# -> ST s (DecodeAction s a)
k Int#
n# ST s (DecodeAction s a)
-> (DecodeAction s a -> ST s (SlowPath s a)) -> ST s (SlowPath s a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs)
go_fast_end !ByteString
bs (ConsumeTag k :: Word# -> ST s (DecodeAction s a)
k) =
case Word8 -> ByteString -> DecodedToken Word
tryConsumeTag (ByteString -> Word8
BS.unsafeHead ByteString
bs) ByteString
bs of
DecodeFailure -> SlowPath s a -> ST s (SlowPath s a)
forall (m :: * -> *) a. Monad m => a -> m a
return (SlowPath s a -> ST s (SlowPath s a))
-> SlowPath s a -> ST s (SlowPath s a)
forall a b. (a -> b) -> a -> b
$! ByteString -> String -> SlowPath s a
forall s a. ByteString -> String -> SlowPath s a
SlowFail ByteString
bs "expected tag"
DecodedToken sz :: Int
sz (W# w# :: Word#
w#) -> Word# -> ST s (DecodeAction s a)
k Word#
w# ST s (DecodeAction s a)
-> (DecodeAction s a -> ST s (SlowPath s a)) -> ST s (SlowPath s a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs)
go_fast_end !ByteString
bs (ConsumeWordCanonical k :: Word# -> ST s (DecodeAction s a)
k) =
case Word8 -> ByteString -> DecodedToken Word
tryConsumeWord (ByteString -> Word8
BS.unsafeHead ByteString
bs) ByteString
bs of
DecodeFailure -> SlowPath s a -> ST s (SlowPath s a)
forall (m :: * -> *) a. Monad m => a -> m a
return (SlowPath s a -> ST s (SlowPath s a))
-> SlowPath s a -> ST s (SlowPath s a)
forall a b. (a -> b) -> a -> b
$! ByteString -> String -> SlowPath s a
forall s a. ByteString -> String -> SlowPath s a
SlowFail ByteString
bs "expected word"
DecodedToken sz :: Int
sz (W# w# :: Word#
w#)
| Int -> Word# -> Bool
isWordCanonical Int
sz Word#
w# -> Word# -> ST s (DecodeAction s a)
k Word#
w# ST s (DecodeAction s a)
-> (DecodeAction s a -> ST s (SlowPath s a)) -> ST s (SlowPath s a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs)
| Bool
otherwise -> SlowPath s a -> ST s (SlowPath s a)
forall (m :: * -> *) a. Monad m => a -> m a
return (SlowPath s a -> ST s (SlowPath s a))
-> SlowPath s a -> ST s (SlowPath s a)
forall a b. (a -> b) -> a -> b
$! ByteString -> String -> SlowPath s a
forall s a. ByteString -> String -> SlowPath s a
SlowFail ByteString
bs "non-canonical word"
go_fast_end !ByteString
bs (ConsumeWord8Canonical k :: Word# -> ST s (DecodeAction s a)
k) =
case Word8 -> ByteString -> DecodedToken Word
tryConsumeWord (ByteString -> Word8
BS.unsafeHead ByteString
bs) ByteString
bs of
DecodeFailure -> SlowPath s a -> ST s (SlowPath s a)
forall (m :: * -> *) a. Monad m => a -> m a
return (SlowPath s a -> ST s (SlowPath s a))
-> SlowPath s a -> ST s (SlowPath s a)
forall a b. (a -> b) -> a -> b
$! ByteString -> String -> SlowPath s a
forall s a. ByteString -> String -> SlowPath s a
SlowFail ByteString
bs "expected word8"
DecodedToken sz :: Int
sz (W# w# :: Word#
w#) -> case Word# -> Word# -> Int#
gtWord# Word#
w# 0xff## of
0# | Int -> Word# -> Bool
isWordCanonical Int
sz Word#
w# -> Word# -> ST s (DecodeAction s a)
k Word#
w# ST s (DecodeAction s a)
-> (DecodeAction s a -> ST s (SlowPath s a)) -> ST s (SlowPath s a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs)
| Bool
otherwise -> SlowPath s a -> ST s (SlowPath s a)
forall (m :: * -> *) a. Monad m => a -> m a
return (SlowPath s a -> ST s (SlowPath s a))
-> SlowPath s a -> ST s (SlowPath s a)
forall a b. (a -> b) -> a -> b
$! ByteString -> String -> SlowPath s a
forall s a. ByteString -> String -> SlowPath s a
SlowFail ByteString
bs "non-canonical word8"
_ -> SlowPath s a -> ST s (SlowPath s a)
forall (m :: * -> *) a. Monad m => a -> m a
return (SlowPath s a -> ST s (SlowPath s a))
-> SlowPath s a -> ST s (SlowPath s a)
forall a b. (a -> b) -> a -> b
$! ByteString -> String -> SlowPath s a
forall s a. ByteString -> String -> SlowPath s a
SlowFail ByteString
bs "expected word8"
go_fast_end !ByteString
bs (ConsumeWord16Canonical k :: Word# -> ST s (DecodeAction s a)
k) =
case Word8 -> ByteString -> DecodedToken Word
tryConsumeWord (ByteString -> Word8
BS.unsafeHead ByteString
bs) ByteString
bs of
DecodeFailure -> SlowPath s a -> ST s (SlowPath s a)
forall (m :: * -> *) a. Monad m => a -> m a
return (SlowPath s a -> ST s (SlowPath s a))
-> SlowPath s a -> ST s (SlowPath s a)
forall a b. (a -> b) -> a -> b
$! ByteString -> String -> SlowPath s a
forall s a. ByteString -> String -> SlowPath s a
SlowFail ByteString
bs "expected word16"
DecodedToken sz :: Int
sz (W# w# :: Word#
w#) -> case Word# -> Word# -> Int#
gtWord# Word#
w# 0xffff## of
0# | Int -> Word# -> Bool
isWordCanonical Int
sz Word#
w# -> Word# -> ST s (DecodeAction s a)
k Word#
w# ST s (DecodeAction s a)
-> (DecodeAction s a -> ST s (SlowPath s a)) -> ST s (SlowPath s a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs)
| Bool
otherwise -> SlowPath s a -> ST s (SlowPath s a)
forall (m :: * -> *) a. Monad m => a -> m a
return (SlowPath s a -> ST s (SlowPath s a))
-> SlowPath s a -> ST s (SlowPath s a)
forall a b. (a -> b) -> a -> b
$! ByteString -> String -> SlowPath s a
forall s a. ByteString -> String -> SlowPath s a
SlowFail ByteString
bs "non-canonical word16"
_ -> SlowPath s a -> ST s (SlowPath s a)
forall (m :: * -> *) a. Monad m => a -> m a
return (SlowPath s a -> ST s (SlowPath s a))
-> SlowPath s a -> ST s (SlowPath s a)
forall a b. (a -> b) -> a -> b
$! ByteString -> String -> SlowPath s a
forall s a. ByteString -> String -> SlowPath s a
SlowFail ByteString
bs "expected word16"
go_fast_end !ByteString
bs (ConsumeWord32Canonical k :: Word# -> ST s (DecodeAction s a)
k) =
case Word8 -> ByteString -> DecodedToken Word
tryConsumeWord (ByteString -> Word8
BS.unsafeHead ByteString
bs) ByteString
bs of
DecodeFailure -> SlowPath s a -> ST s (SlowPath s a)
forall (m :: * -> *) a. Monad m => a -> m a
return (SlowPath s a -> ST s (SlowPath s a))
-> SlowPath s a -> ST s (SlowPath s a)
forall a b. (a -> b) -> a -> b
$! ByteString -> String -> SlowPath s a
forall s a. ByteString -> String -> SlowPath s a
SlowFail ByteString
bs "expected word32"
DecodedToken sz :: Int
sz (W# w# :: Word#
w#) -> case Word# -> Int#
w_out_of_range Word#
w# of
0# | Int -> Word# -> Bool
isWordCanonical Int
sz Word#
w# -> Word# -> ST s (DecodeAction s a)
k Word#
w# ST s (DecodeAction s a)
-> (DecodeAction s a -> ST s (SlowPath s a)) -> ST s (SlowPath s a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs)
| Bool
otherwise -> SlowPath s a -> ST s (SlowPath s a)
forall (m :: * -> *) a. Monad m => a -> m a
return (SlowPath s a -> ST s (SlowPath s a))
-> SlowPath s a -> ST s (SlowPath s a)
forall a b. (a -> b) -> a -> b
$! ByteString -> String -> SlowPath s a
forall s a. ByteString -> String -> SlowPath s a
SlowFail ByteString
bs "non-canonical word32"
_ -> SlowPath s a -> ST s (SlowPath s a)
forall (m :: * -> *) a. Monad m => a -> m a
return (SlowPath s a -> ST s (SlowPath s a))
-> SlowPath s a -> ST s (SlowPath s a)
forall a b. (a -> b) -> a -> b
$! ByteString -> String -> SlowPath s a
forall s a. ByteString -> String -> SlowPath s a
SlowFail ByteString
bs "expected word32"
where
w_out_of_range :: Word# -> Int#
w_out_of_range :: Word# -> Int#
w_out_of_range _w# :: Word#
_w# =
#if defined(ARCH_32bit)
0#
#else
gtWord# _w# 0xffffffff##
#endif
go_fast_end !ByteString
bs (ConsumeNegWordCanonical k :: Word# -> ST s (DecodeAction s a)
k) =
case Word8 -> ByteString -> DecodedToken Word
tryConsumeNegWord (ByteString -> Word8
BS.unsafeHead ByteString
bs) ByteString
bs of
DecodeFailure -> SlowPath s a -> ST s (SlowPath s a)
forall (m :: * -> *) a. Monad m => a -> m a
return (SlowPath s a -> ST s (SlowPath s a))
-> SlowPath s a -> ST s (SlowPath s a)
forall a b. (a -> b) -> a -> b
$! ByteString -> String -> SlowPath s a
forall s a. ByteString -> String -> SlowPath s a
SlowFail ByteString
bs "expected negative int"
DecodedToken sz :: Int
sz (W# w# :: Word#
w#)
| Int -> Word# -> Bool
isWordCanonical Int
sz Word#
w# -> Word# -> ST s (DecodeAction s a)
k Word#
w# ST s (DecodeAction s a)
-> (DecodeAction s a -> ST s (SlowPath s a)) -> ST s (SlowPath s a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs)
| Bool
otherwise -> SlowPath s a -> ST s (SlowPath s a)
forall (m :: * -> *) a. Monad m => a -> m a
return (SlowPath s a -> ST s (SlowPath s a))
-> SlowPath s a -> ST s (SlowPath s a)
forall a b. (a -> b) -> a -> b
$! ByteString -> String -> SlowPath s a
forall s a. ByteString -> String -> SlowPath s a
SlowFail ByteString
bs "non-canonical negative int"
go_fast_end !ByteString
bs (ConsumeIntCanonical k :: Int# -> ST s (DecodeAction s a)
k) =
case Word8 -> ByteString -> DecodedToken Int
tryConsumeInt (ByteString -> Word8
BS.unsafeHead ByteString
bs) ByteString
bs of
DecodeFailure -> SlowPath s a -> ST s (SlowPath s a)
forall (m :: * -> *) a. Monad m => a -> m a
return (SlowPath s a -> ST s (SlowPath s a))
-> SlowPath s a -> ST s (SlowPath s a)
forall a b. (a -> b) -> a -> b
$! ByteString -> String -> SlowPath s a
forall s a. ByteString -> String -> SlowPath s a
SlowFail ByteString
bs "expected int"
DecodedToken sz :: Int
sz (I# n# :: Int#
n#)
| Int -> Int# -> Bool
isIntCanonical Int
sz Int#
n# -> Int# -> ST s (DecodeAction s a)
k Int#
n# ST s (DecodeAction s a)
-> (DecodeAction s a -> ST s (SlowPath s a)) -> ST s (SlowPath s a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs)
| Bool
otherwise -> SlowPath s a -> ST s (SlowPath s a)
forall (m :: * -> *) a. Monad m => a -> m a
return (SlowPath s a -> ST s (SlowPath s a))
-> SlowPath s a -> ST s (SlowPath s a)
forall a b. (a -> b) -> a -> b
$! ByteString -> String -> SlowPath s a
forall s a. ByteString -> String -> SlowPath s a
SlowFail ByteString
bs "non-canonical int"
go_fast_end !ByteString
bs (ConsumeInt8Canonical k :: Int# -> ST s (DecodeAction s a)
k) =
case Word8 -> ByteString -> DecodedToken Int
tryConsumeInt (ByteString -> Word8
BS.unsafeHead ByteString
bs) ByteString
bs of
DecodeFailure -> SlowPath s a -> ST s (SlowPath s a)
forall (m :: * -> *) a. Monad m => a -> m a
return (SlowPath s a -> ST s (SlowPath s a))
-> SlowPath s a -> ST s (SlowPath s a)
forall a b. (a -> b) -> a -> b
$! ByteString -> String -> SlowPath s a
forall s a. ByteString -> String -> SlowPath s a
SlowFail ByteString
bs "expected int8"
DecodedToken sz :: Int
sz (I# n# :: Int#
n#) ->
case (Int#
n# Int# -> Int# -> Int#
># 0x7f#) Int# -> Int# -> Int#
`orI#` (Int#
n# Int# -> Int# -> Int#
<# -0x80#) of
0# | Int -> Int# -> Bool
isIntCanonical Int
sz Int#
n# -> Int# -> ST s (DecodeAction s a)
k Int#
n# ST s (DecodeAction s a)
-> (DecodeAction s a -> ST s (SlowPath s a)) -> ST s (SlowPath s a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs)
| Bool
otherwise -> SlowPath s a -> ST s (SlowPath s a)
forall (m :: * -> *) a. Monad m => a -> m a
return (SlowPath s a -> ST s (SlowPath s a))
-> SlowPath s a -> ST s (SlowPath s a)
forall a b. (a -> b) -> a -> b
$! ByteString -> String -> SlowPath s a
forall s a. ByteString -> String -> SlowPath s a
SlowFail ByteString
bs "non-canonical int8"
_ -> SlowPath s a -> ST s (SlowPath s a)
forall (m :: * -> *) a. Monad m => a -> m a
return (SlowPath s a -> ST s (SlowPath s a))
-> SlowPath s a -> ST s (SlowPath s a)
forall a b. (a -> b) -> a -> b
$! ByteString -> String -> SlowPath s a
forall s a. ByteString -> String -> SlowPath s a
SlowFail ByteString
bs "expected int8"
go_fast_end !ByteString
bs (ConsumeInt16Canonical k :: Int# -> ST s (DecodeAction s a)
k) =
case Word8 -> ByteString -> DecodedToken Int
tryConsumeInt (ByteString -> Word8
BS.unsafeHead ByteString
bs) ByteString
bs of
DecodeFailure -> SlowPath s a -> ST s (SlowPath s a)
forall (m :: * -> *) a. Monad m => a -> m a
return (SlowPath s a -> ST s (SlowPath s a))
-> SlowPath s a -> ST s (SlowPath s a)
forall a b. (a -> b) -> a -> b
$! ByteString -> String -> SlowPath s a
forall s a. ByteString -> String -> SlowPath s a
SlowFail ByteString
bs "expected int16"
DecodedToken sz :: Int
sz (I# n# :: Int#
n#) ->
case (Int#
n# Int# -> Int# -> Int#
># 0x7fff#) Int# -> Int# -> Int#
`orI#` (Int#
n# Int# -> Int# -> Int#
<# -0x8000#) of
0# | Int -> Int# -> Bool
isIntCanonical Int
sz Int#
n# -> Int# -> ST s (DecodeAction s a)
k Int#
n# ST s (DecodeAction s a)
-> (DecodeAction s a -> ST s (SlowPath s a)) -> ST s (SlowPath s a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs)
| Bool
otherwise -> SlowPath s a -> ST s (SlowPath s a)
forall (m :: * -> *) a. Monad m => a -> m a
return (SlowPath s a -> ST s (SlowPath s a))
-> SlowPath s a -> ST s (SlowPath s a)
forall a b. (a -> b) -> a -> b
$! ByteString -> String -> SlowPath s a
forall s a. ByteString -> String -> SlowPath s a
SlowFail ByteString
bs "non-canonical int16"
_ -> SlowPath s a -> ST s (SlowPath s a)
forall (m :: * -> *) a. Monad m => a -> m a
return (SlowPath s a -> ST s (SlowPath s a))
-> SlowPath s a -> ST s (SlowPath s a)
forall a b. (a -> b) -> a -> b
$! ByteString -> String -> SlowPath s a
forall s a. ByteString -> String -> SlowPath s a
SlowFail ByteString
bs "expected int16"
go_fast_end !ByteString
bs (ConsumeInt32Canonical k :: Int# -> ST s (DecodeAction s a)
k) =
case Word8 -> ByteString -> DecodedToken Int
tryConsumeInt (ByteString -> Word8
BS.unsafeHead ByteString
bs) ByteString
bs of
DecodeFailure -> SlowPath s a -> ST s (SlowPath s a)
forall (m :: * -> *) a. Monad m => a -> m a
return (SlowPath s a -> ST s (SlowPath s a))
-> SlowPath s a -> ST s (SlowPath s a)
forall a b. (a -> b) -> a -> b
$! ByteString -> String -> SlowPath s a
forall s a. ByteString -> String -> SlowPath s a
SlowFail ByteString
bs "expected int32"
DecodedToken sz :: Int
sz (I# n# :: Int#
n#) ->
case Int# -> Int#
n_out_of_range Int#
n# of
0# | Int -> Int# -> Bool
isIntCanonical Int
sz Int#
n# -> Int# -> ST s (DecodeAction s a)
k Int#
n# ST s (DecodeAction s a)
-> (DecodeAction s a -> ST s (SlowPath s a)) -> ST s (SlowPath s a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs)
| Bool
otherwise -> SlowPath s a -> ST s (SlowPath s a)
forall (m :: * -> *) a. Monad m => a -> m a
return (SlowPath s a -> ST s (SlowPath s a))
-> SlowPath s a -> ST s (SlowPath s a)
forall a b. (a -> b) -> a -> b
$! ByteString -> String -> SlowPath s a
forall s a. ByteString -> String -> SlowPath s a
SlowFail ByteString
bs "non-canonical int32"
_ -> SlowPath s a -> ST s (SlowPath s a)
forall (m :: * -> *) a. Monad m => a -> m a
return (SlowPath s a -> ST s (SlowPath s a))
-> SlowPath s a -> ST s (SlowPath s a)
forall a b. (a -> b) -> a -> b
$! ByteString -> String -> SlowPath s a
forall s a. ByteString -> String -> SlowPath s a
SlowFail ByteString
bs "expected int32"
where
n_out_of_range :: Int# -> Int#
n_out_of_range :: Int# -> Int#
n_out_of_range _n# :: Int#
_n# =
#if defined(ARCH_32bit)
0#
#else
(_n# ># 0x7fffffff#) `orI#` (_n# <# -0x80000000#)
#endif
go_fast_end !ByteString
bs (ConsumeListLenCanonical k :: Int# -> ST s (DecodeAction s a)
k) =
case Word8 -> ByteString -> DecodedToken Int
tryConsumeListLen (ByteString -> Word8
BS.unsafeHead ByteString
bs) ByteString
bs of
DecodeFailure -> SlowPath s a -> ST s (SlowPath s a)
forall (m :: * -> *) a. Monad m => a -> m a
return (SlowPath s a -> ST s (SlowPath s a))
-> SlowPath s a -> ST s (SlowPath s a)
forall a b. (a -> b) -> a -> b
$! ByteString -> String -> SlowPath s a
forall s a. ByteString -> String -> SlowPath s a
SlowFail ByteString
bs "expected list len"
DecodedToken sz :: Int
sz (I# n# :: Int#
n#)
| Int -> Word# -> Bool
isWordCanonical Int
sz (Int# -> Word#
int2Word# Int#
n#) -> Int# -> ST s (DecodeAction s a)
k Int#
n# ST s (DecodeAction s a)
-> (DecodeAction s a -> ST s (SlowPath s a)) -> ST s (SlowPath s a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs)
| Bool
otherwise -> SlowPath s a -> ST s (SlowPath s a)
forall (m :: * -> *) a. Monad m => a -> m a
return (SlowPath s a -> ST s (SlowPath s a))
-> SlowPath s a -> ST s (SlowPath s a)
forall a b. (a -> b) -> a -> b
$! ByteString -> String -> SlowPath s a
forall s a. ByteString -> String -> SlowPath s a
SlowFail ByteString
bs "non-canonical list len"
go_fast_end !ByteString
bs (ConsumeMapLenCanonical k :: Int# -> ST s (DecodeAction s a)
k) =
case Word8 -> ByteString -> DecodedToken Int
tryConsumeMapLen (ByteString -> Word8
BS.unsafeHead ByteString
bs) ByteString
bs of
DecodeFailure -> SlowPath s a -> ST s (SlowPath s a)
forall (m :: * -> *) a. Monad m => a -> m a
return (SlowPath s a -> ST s (SlowPath s a))
-> SlowPath s a -> ST s (SlowPath s a)
forall a b. (a -> b) -> a -> b
$! ByteString -> String -> SlowPath s a
forall s a. ByteString -> String -> SlowPath s a
SlowFail ByteString
bs "expected map len"
DecodedToken sz :: Int
sz (I# n# :: Int#
n#)
| Int -> Word# -> Bool
isWordCanonical Int
sz (Int# -> Word#
int2Word# Int#
n#) -> Int# -> ST s (DecodeAction s a)
k Int#
n# ST s (DecodeAction s a)
-> (DecodeAction s a -> ST s (SlowPath s a)) -> ST s (SlowPath s a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs)
| Bool
otherwise -> SlowPath s a -> ST s (SlowPath s a)
forall (m :: * -> *) a. Monad m => a -> m a
return (SlowPath s a -> ST s (SlowPath s a))
-> SlowPath s a -> ST s (SlowPath s a)
forall a b. (a -> b) -> a -> b
$! ByteString -> String -> SlowPath s a
forall s a. ByteString -> String -> SlowPath s a
SlowFail ByteString
bs "non-canonical map len"
go_fast_end !ByteString
bs (ConsumeTagCanonical k :: Word# -> ST s (DecodeAction s a)
k) =
case Word8 -> ByteString -> DecodedToken Word
tryConsumeTag (ByteString -> Word8
BS.unsafeHead ByteString
bs) ByteString
bs of
DecodeFailure -> SlowPath s a -> ST s (SlowPath s a)
forall (m :: * -> *) a. Monad m => a -> m a
return (SlowPath s a -> ST s (SlowPath s a))
-> SlowPath s a -> ST s (SlowPath s a)
forall a b. (a -> b) -> a -> b
$! ByteString -> String -> SlowPath s a
forall s a. ByteString -> String -> SlowPath s a
SlowFail ByteString
bs "expected tag"
DecodedToken sz :: Int
sz (W# w# :: Word#
w#)
| Int -> Word# -> Bool
isWordCanonical Int
sz Word#
w# -> Word# -> ST s (DecodeAction s a)
k Word#
w# ST s (DecodeAction s a)
-> (DecodeAction s a -> ST s (SlowPath s a)) -> ST s (SlowPath s a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs)
| Bool
otherwise -> SlowPath s a -> ST s (SlowPath s a)
forall (m :: * -> *) a. Monad m => a -> m a
return (SlowPath s a -> ST s (SlowPath s a))
-> SlowPath s a -> ST s (SlowPath s a)
forall a b. (a -> b) -> a -> b
$! ByteString -> String -> SlowPath s a
forall s a. ByteString -> String -> SlowPath s a
SlowFail ByteString
bs "non-canonical tag"
#if defined(ARCH_32bit)
go_fast_end !ByteString
bs (ConsumeWord64 k :: Word64# -> ST s (DecodeAction s a)
k) =
case Word8 -> ByteString -> DecodedToken Word64
tryConsumeWord64 (ByteString -> Word8
BS.unsafeHead ByteString
bs) ByteString
bs of
DecodeFailure -> SlowPath s a -> ST s (SlowPath s a)
forall (m :: * -> *) a. Monad m => a -> m a
return (SlowPath s a -> ST s (SlowPath s a))
-> SlowPath s a -> ST s (SlowPath s a)
forall a b. (a -> b) -> a -> b
$! ByteString -> String -> SlowPath s a
forall s a. ByteString -> String -> SlowPath s a
SlowFail ByteString
bs "expected word64"
DecodedToken sz :: Int
sz (W64# w# :: Word64#
w#) -> Word64# -> ST s (DecodeAction s a)
k Word64#
w# ST s (DecodeAction s a)
-> (DecodeAction s a -> ST s (SlowPath s a)) -> ST s (SlowPath s a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs)
go_fast_end !ByteString
bs (ConsumeNegWord64 k :: Word64# -> ST s (DecodeAction s a)
k) =
case Word8 -> ByteString -> DecodedToken Word64
tryConsumeNegWord64 (ByteString -> Word8
BS.unsafeHead ByteString
bs) ByteString
bs of
DecodeFailure -> SlowPath s a -> ST s (SlowPath s a)
forall (m :: * -> *) a. Monad m => a -> m a
return (SlowPath s a -> ST s (SlowPath s a))
-> SlowPath s a -> ST s (SlowPath s a)
forall a b. (a -> b) -> a -> b
$! ByteString -> String -> SlowPath s a
forall s a. ByteString -> String -> SlowPath s a
SlowFail ByteString
bs "expected negative int"
DecodedToken sz :: Int
sz (W64# w# :: Word64#
w#) -> Word64# -> ST s (DecodeAction s a)
k Word64#
w# ST s (DecodeAction s a)
-> (DecodeAction s a -> ST s (SlowPath s a)) -> ST s (SlowPath s a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs)
go_fast_end !ByteString
bs (ConsumeInt64 k :: Int64# -> ST s (DecodeAction s a)
k) =
case Word8 -> ByteString -> DecodedToken ByteOffset
tryConsumeInt64 (ByteString -> Word8
BS.unsafeHead ByteString
bs) ByteString
bs of
DecodeFailure -> SlowPath s a -> ST s (SlowPath s a)
forall (m :: * -> *) a. Monad m => a -> m a
return (SlowPath s a -> ST s (SlowPath s a))
-> SlowPath s a -> ST s (SlowPath s a)
forall a b. (a -> b) -> a -> b
$! ByteString -> String -> SlowPath s a
forall s a. ByteString -> String -> SlowPath s a
SlowFail ByteString
bs "expected int64"
DecodedToken sz :: Int
sz (I64# i# :: Int64#
i#) -> Int64# -> ST s (DecodeAction s a)
k Int64#
i# ST s (DecodeAction s a)
-> (DecodeAction s a -> ST s (SlowPath s a)) -> ST s (SlowPath s a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs)
go_fast_end !ByteString
bs (ConsumeListLen64 k :: Int64# -> ST s (DecodeAction s a)
k) =
case Word8 -> ByteString -> DecodedToken ByteOffset
tryConsumeListLen64 (ByteString -> Word8
BS.unsafeHead ByteString
bs) ByteString
bs of
DecodeFailure -> SlowPath s a -> ST s (SlowPath s a)
forall (m :: * -> *) a. Monad m => a -> m a
return (SlowPath s a -> ST s (SlowPath s a))
-> SlowPath s a -> ST s (SlowPath s a)
forall a b. (a -> b) -> a -> b
$! ByteString -> String -> SlowPath s a
forall s a. ByteString -> String -> SlowPath s a
SlowFail ByteString
bs "expected list len 64"
DecodedToken sz :: Int
sz (I64# i# :: Int64#
i#) -> Int64# -> ST s (DecodeAction s a)
k Int64#
i# ST s (DecodeAction s a)
-> (DecodeAction s a -> ST s (SlowPath s a)) -> ST s (SlowPath s a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs)
go_fast_end !ByteString
bs (ConsumeMapLen64 k :: Int64# -> ST s (DecodeAction s a)
k) =
case Word8 -> ByteString -> DecodedToken ByteOffset
tryConsumeMapLen64 (ByteString -> Word8
BS.unsafeHead ByteString
bs) ByteString
bs of
DecodeFailure -> SlowPath s a -> ST s (SlowPath s a)
forall (m :: * -> *) a. Monad m => a -> m a
return (SlowPath s a -> ST s (SlowPath s a))
-> SlowPath s a -> ST s (SlowPath s a)
forall a b. (a -> b) -> a -> b
$! ByteString -> String -> SlowPath s a
forall s a. ByteString -> String -> SlowPath s a
SlowFail ByteString
bs "expected map len 64"
DecodedToken sz :: Int
sz (I64# i# :: Int64#
i#) -> Int64# -> ST s (DecodeAction s a)
k Int64#
i# ST s (DecodeAction s a)
-> (DecodeAction s a -> ST s (SlowPath s a)) -> ST s (SlowPath s a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs)
go_fast_end !ByteString
bs (ConsumeTag64 k :: Word64# -> ST s (DecodeAction s a)
k) =
case Word8 -> ByteString -> DecodedToken Word64
tryConsumeTag64 (ByteString -> Word8
BS.unsafeHead ByteString
bs) ByteString
bs of
DecodeFailure -> SlowPath s a -> ST s (SlowPath s a)
forall (m :: * -> *) a. Monad m => a -> m a
return (SlowPath s a -> ST s (SlowPath s a))
-> SlowPath s a -> ST s (SlowPath s a)
forall a b. (a -> b) -> a -> b
$! ByteString -> String -> SlowPath s a
forall s a. ByteString -> String -> SlowPath s a
SlowFail ByteString
bs "expected tag64"
DecodedToken sz :: Int
sz (W64# w# :: Word64#
w#) -> Word64# -> ST s (DecodeAction s a)
k Word64#
w# ST s (DecodeAction s a)
-> (DecodeAction s a -> ST s (SlowPath s a)) -> ST s (SlowPath s a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs)
go_fast_end !ByteString
bs (ConsumeWord64Canonical k :: Word64# -> ST s (DecodeAction s a)
k) =
case Word8 -> ByteString -> DecodedToken Word64
tryConsumeWord64 (ByteString -> Word8
BS.unsafeHead ByteString
bs) ByteString
bs of
DecodeFailure -> SlowPath s a -> ST s (SlowPath s a)
forall (m :: * -> *) a. Monad m => a -> m a
return (SlowPath s a -> ST s (SlowPath s a))
-> SlowPath s a -> ST s (SlowPath s a)
forall a b. (a -> b) -> a -> b
$! ByteString -> String -> SlowPath s a
forall s a. ByteString -> String -> SlowPath s a
SlowFail ByteString
bs "expected word64"
DecodedToken sz :: Int
sz (W64# w# :: Word64#
w#)
| Int -> Word64# -> Bool
isWord64Canonical Int
sz Word64#
w# -> Word64# -> ST s (DecodeAction s a)
k Word64#
w# ST s (DecodeAction s a)
-> (DecodeAction s a -> ST s (SlowPath s a)) -> ST s (SlowPath s a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs)
| Bool
otherwise -> SlowPath s a -> ST s (SlowPath s a)
forall (m :: * -> *) a. Monad m => a -> m a
return (SlowPath s a -> ST s (SlowPath s a))
-> SlowPath s a -> ST s (SlowPath s a)
forall a b. (a -> b) -> a -> b
$! ByteString -> String -> SlowPath s a
forall s a. ByteString -> String -> SlowPath s a
SlowFail ByteString
bs "non-canonical word64"
go_fast_end !ByteString
bs (ConsumeNegWord64Canonical k :: Word64# -> ST s (DecodeAction s a)
k) =
case Word8 -> ByteString -> DecodedToken Word64
tryConsumeNegWord64 (ByteString -> Word8
BS.unsafeHead ByteString
bs) ByteString
bs of
DecodeFailure -> SlowPath s a -> ST s (SlowPath s a)
forall (m :: * -> *) a. Monad m => a -> m a
return (SlowPath s a -> ST s (SlowPath s a))
-> SlowPath s a -> ST s (SlowPath s a)
forall a b. (a -> b) -> a -> b
$! ByteString -> String -> SlowPath s a
forall s a. ByteString -> String -> SlowPath s a
SlowFail ByteString
bs "expected negative int"
DecodedToken sz :: Int
sz (W64# w# :: Word64#
w#)
| Int -> Word64# -> Bool
isWord64Canonical Int
sz Word64#
w# -> Word64# -> ST s (DecodeAction s a)
k Word64#
w# ST s (DecodeAction s a)
-> (DecodeAction s a -> ST s (SlowPath s a)) -> ST s (SlowPath s a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs)
| Bool
otherwise -> SlowPath s a -> ST s (SlowPath s a)
forall (m :: * -> *) a. Monad m => a -> m a
return (SlowPath s a -> ST s (SlowPath s a))
-> SlowPath s a -> ST s (SlowPath s a)
forall a b. (a -> b) -> a -> b
$! ByteString -> String -> SlowPath s a
forall s a. ByteString -> String -> SlowPath s a
SlowFail ByteString
bs "non-canonical negative int"
go_fast_end !ByteString
bs (ConsumeInt64Canonical k :: Int64# -> ST s (DecodeAction s a)
k) =
case Word8 -> ByteString -> DecodedToken ByteOffset
tryConsumeInt64 (ByteString -> Word8
BS.unsafeHead ByteString
bs) ByteString
bs of
DecodeFailure -> SlowPath s a -> ST s (SlowPath s a)
forall (m :: * -> *) a. Monad m => a -> m a
return (SlowPath s a -> ST s (SlowPath s a))
-> SlowPath s a -> ST s (SlowPath s a)
forall a b. (a -> b) -> a -> b
$! ByteString -> String -> SlowPath s a
forall s a. ByteString -> String -> SlowPath s a
SlowFail ByteString
bs "expected int64"
DecodedToken sz :: Int
sz (I64# i# :: Int64#
i#)
| Int -> Int64# -> Bool
isInt64Canonical Int
sz Int64#
i# -> Int64# -> ST s (DecodeAction s a)
k Int64#
i# ST s (DecodeAction s a)
-> (DecodeAction s a -> ST s (SlowPath s a)) -> ST s (SlowPath s a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs)
| Bool
otherwise -> SlowPath s a -> ST s (SlowPath s a)
forall (m :: * -> *) a. Monad m => a -> m a
return (SlowPath s a -> ST s (SlowPath s a))
-> SlowPath s a -> ST s (SlowPath s a)
forall a b. (a -> b) -> a -> b
$! ByteString -> String -> SlowPath s a
forall s a. ByteString -> String -> SlowPath s a
SlowFail ByteString
bs "non-canonical int64"
go_fast_end !ByteString
bs (ConsumeListLen64Canonical k :: Int64# -> ST s (DecodeAction s a)
k) =
case Word8 -> ByteString -> DecodedToken ByteOffset
tryConsumeListLen64 (ByteString -> Word8
BS.unsafeHead ByteString
bs) ByteString
bs of
DecodeFailure -> SlowPath s a -> ST s (SlowPath s a)
forall (m :: * -> *) a. Monad m => a -> m a
return (SlowPath s a -> ST s (SlowPath s a))
-> SlowPath s a -> ST s (SlowPath s a)
forall a b. (a -> b) -> a -> b
$! ByteString -> String -> SlowPath s a
forall s a. ByteString -> String -> SlowPath s a
SlowFail ByteString
bs "expected list len 64"
DecodedToken sz :: Int
sz (I64# i# :: Int64#
i#)
| Int -> Word64# -> Bool
isWord64Canonical Int
sz (Int64# -> Word64#
int64ToWord64# Int64#
i#) ->
Int64# -> ST s (DecodeAction s a)
k Int64#
i# ST s (DecodeAction s a)
-> (DecodeAction s a -> ST s (SlowPath s a)) -> ST s (SlowPath s a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs)
| Bool
otherwise ->
SlowPath s a -> ST s (SlowPath s a)
forall (m :: * -> *) a. Monad m => a -> m a
return (SlowPath s a -> ST s (SlowPath s a))
-> SlowPath s a -> ST s (SlowPath s a)
forall a b. (a -> b) -> a -> b
$! ByteString -> String -> SlowPath s a
forall s a. ByteString -> String -> SlowPath s a
SlowFail ByteString
bs "non-canonical list len 64"
go_fast_end !ByteString
bs (ConsumeMapLen64Canonical k :: Int64# -> ST s (DecodeAction s a)
k) =
case Word8 -> ByteString -> DecodedToken ByteOffset
tryConsumeMapLen64 (ByteString -> Word8
BS.unsafeHead ByteString
bs) ByteString
bs of
DecodeFailure -> SlowPath s a -> ST s (SlowPath s a)
forall (m :: * -> *) a. Monad m => a -> m a
return (SlowPath s a -> ST s (SlowPath s a))
-> SlowPath s a -> ST s (SlowPath s a)
forall a b. (a -> b) -> a -> b
$! ByteString -> String -> SlowPath s a
forall s a. ByteString -> String -> SlowPath s a
SlowFail ByteString
bs "expected map len 64"
DecodedToken sz :: Int
sz (I64# i# :: Int64#
i#)
| Int -> Word64# -> Bool
isWord64Canonical Int
sz (Int64# -> Word64#
int64ToWord64# Int64#
i#) ->
Int64# -> ST s (DecodeAction s a)
k Int64#
i# ST s (DecodeAction s a)
-> (DecodeAction s a -> ST s (SlowPath s a)) -> ST s (SlowPath s a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs)
| Bool
otherwise ->
SlowPath s a -> ST s (SlowPath s a)
forall (m :: * -> *) a. Monad m => a -> m a
return (SlowPath s a -> ST s (SlowPath s a))
-> SlowPath s a -> ST s (SlowPath s a)
forall a b. (a -> b) -> a -> b
$! ByteString -> String -> SlowPath s a
forall s a. ByteString -> String -> SlowPath s a
SlowFail ByteString
bs "non-canonical map len 64"
go_fast_end !ByteString
bs (ConsumeTag64Canonical k :: Word64# -> ST s (DecodeAction s a)
k) =
case Word8 -> ByteString -> DecodedToken Word64
tryConsumeTag64 (ByteString -> Word8
BS.unsafeHead ByteString
bs) ByteString
bs of
DecodeFailure -> SlowPath s a -> ST s (SlowPath s a)
forall (m :: * -> *) a. Monad m => a -> m a
return (SlowPath s a -> ST s (SlowPath s a))
-> SlowPath s a -> ST s (SlowPath s a)
forall a b. (a -> b) -> a -> b
$! ByteString -> String -> SlowPath s a
forall s a. ByteString -> String -> SlowPath s a
SlowFail ByteString
bs "expected tag64"
DecodedToken sz :: Int
sz (W64# w# :: Word64#
w#)
| Int -> Word64# -> Bool
isWord64Canonical Int
sz Word64#
w# -> Word64# -> ST s (DecodeAction s a)
k Word64#
w# ST s (DecodeAction s a)
-> (DecodeAction s a -> ST s (SlowPath s a)) -> ST s (SlowPath s a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs)
| Bool
otherwise -> SlowPath s a -> ST s (SlowPath s a)
forall (m :: * -> *) a. Monad m => a -> m a
return (SlowPath s a -> ST s (SlowPath s a))
-> SlowPath s a -> ST s (SlowPath s a)
forall a b. (a -> b) -> a -> b
$! ByteString -> String -> SlowPath s a
forall s a. ByteString -> String -> SlowPath s a
SlowFail ByteString
bs "non-canonical tag64"
#endif
go_fast_end !ByteString
bs (ConsumeInteger k :: Integer -> ST s (DecodeAction s a)
k) =
case Word8 -> ByteString -> DecodedToken (BigIntToken Integer)
tryConsumeInteger (ByteString -> Word8
BS.unsafeHead ByteString
bs) ByteString
bs of
DecodeFailure -> SlowPath s a -> ST s (SlowPath s a)
forall (m :: * -> *) a. Monad m => a -> m a
return (SlowPath s a -> ST s (SlowPath s a))
-> SlowPath s a -> ST s (SlowPath s a)
forall a b. (a -> b) -> a -> b
$! ByteString -> String -> SlowPath s a
forall s a. ByteString -> String -> SlowPath s a
SlowFail ByteString
bs "expected integer"
DecodedToken sz :: Int
sz (BigIntToken _ n :: Integer
n) -> Integer -> ST s (DecodeAction s a)
k Integer
n ST s (DecodeAction s a)
-> (DecodeAction s a -> ST s (SlowPath s a)) -> ST s (SlowPath s a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs)
DecodedToken sz :: Int
sz (BigUIntNeedBody _ len :: Int
len) -> SlowPath s a -> ST s (SlowPath s a)
forall (m :: * -> *) a. Monad m => a -> m a
return (SlowPath s a -> ST s (SlowPath s a))
-> SlowPath s a -> ST s (SlowPath s a)
forall a b. (a -> b) -> a -> b
$! ByteString
-> (ByteString -> ST s (DecodeAction s a)) -> Int -> SlowPath s a
forall s a.
ByteString
-> (ByteString -> ST s (DecodeAction s a)) -> Int -> SlowPath s a
SlowConsumeTokenBytes (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs) ((Integer -> ST s (DecodeAction s a))
-> ByteString -> ST s (DecodeAction s a)
forall s a.
(Integer -> ST s (DecodeAction s a))
-> ByteString -> ST s (DecodeAction s a)
adjustContBigUIntNeedBody Integer -> ST s (DecodeAction s a)
k) Int
len
DecodedToken sz :: Int
sz (BigNIntNeedBody _ len :: Int
len) -> SlowPath s a -> ST s (SlowPath s a)
forall (m :: * -> *) a. Monad m => a -> m a
return (SlowPath s a -> ST s (SlowPath s a))
-> SlowPath s a -> ST s (SlowPath s a)
forall a b. (a -> b) -> a -> b
$! ByteString
-> (ByteString -> ST s (DecodeAction s a)) -> Int -> SlowPath s a
forall s a.
ByteString
-> (ByteString -> ST s (DecodeAction s a)) -> Int -> SlowPath s a
SlowConsumeTokenBytes (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs) ((Integer -> ST s (DecodeAction s a))
-> ByteString -> ST s (DecodeAction s a)
forall s a.
(Integer -> ST s (DecodeAction s a))
-> ByteString -> ST s (DecodeAction s a)
adjustContBigNIntNeedBody Integer -> ST s (DecodeAction s a)
k) Int
len
DecodedToken sz :: Int
sz BigUIntNeedHeader -> SlowPath s a -> ST s (SlowPath s a)
forall (m :: * -> *) a. Monad m => a -> m a
return (SlowPath s a -> ST s (SlowPath s a))
-> SlowPath s a -> ST s (SlowPath s a)
forall a b. (a -> b) -> a -> b
$! ByteString -> DecodeAction s a -> SlowPath s a
forall s a. ByteString -> DecodeAction s a -> SlowPath s a
SlowDecodeAction (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs) ((Integer -> ST s (DecodeAction s a)) -> DecodeAction s a
forall s a.
(Integer -> ST s (DecodeAction s a)) -> DecodeAction s a
adjustContBigUIntNeedHeader Integer -> ST s (DecodeAction s a)
k)
DecodedToken sz :: Int
sz BigNIntNeedHeader -> SlowPath s a -> ST s (SlowPath s a)
forall (m :: * -> *) a. Monad m => a -> m a
return (SlowPath s a -> ST s (SlowPath s a))
-> SlowPath s a -> ST s (SlowPath s a)
forall a b. (a -> b) -> a -> b
$! ByteString -> DecodeAction s a -> SlowPath s a
forall s a. ByteString -> DecodeAction s a -> SlowPath s a
SlowDecodeAction (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs) ((Integer -> ST s (DecodeAction s a)) -> DecodeAction s a
forall s a.
(Integer -> ST s (DecodeAction s a)) -> DecodeAction s a
adjustContBigNIntNeedHeader Integer -> ST s (DecodeAction s a)
k)
go_fast_end !ByteString
bs (ConsumeFloat k :: Float# -> ST s (DecodeAction s a)
k) =
case Word8 -> ByteString -> DecodedToken Float
tryConsumeFloat (ByteString -> Word8
BS.unsafeHead ByteString
bs) ByteString
bs of
DecodeFailure -> SlowPath s a -> ST s (SlowPath s a)
forall (m :: * -> *) a. Monad m => a -> m a
return (SlowPath s a -> ST s (SlowPath s a))
-> SlowPath s a -> ST s (SlowPath s a)
forall a b. (a -> b) -> a -> b
$! ByteString -> String -> SlowPath s a
forall s a. ByteString -> String -> SlowPath s a
SlowFail ByteString
bs "expected float"
DecodedToken sz :: Int
sz (F# f# :: Float#
f#) -> Float# -> ST s (DecodeAction s a)
k Float#
f# ST s (DecodeAction s a)
-> (DecodeAction s a -> ST s (SlowPath s a)) -> ST s (SlowPath s a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs)
go_fast_end !ByteString
bs (ConsumeDouble k :: Double# -> ST s (DecodeAction s a)
k) =
case Word8 -> ByteString -> DecodedToken Double
tryConsumeDouble (ByteString -> Word8
BS.unsafeHead ByteString
bs) ByteString
bs of
DecodeFailure -> SlowPath s a -> ST s (SlowPath s a)
forall (m :: * -> *) a. Monad m => a -> m a
return (SlowPath s a -> ST s (SlowPath s a))
-> SlowPath s a -> ST s (SlowPath s a)
forall a b. (a -> b) -> a -> b
$! ByteString -> String -> SlowPath s a
forall s a. ByteString -> String -> SlowPath s a
SlowFail ByteString
bs "expected double"
DecodedToken sz :: Int
sz (D# f# :: Double#
f#) -> Double# -> ST s (DecodeAction s a)
k Double#
f# ST s (DecodeAction s a)
-> (DecodeAction s a -> ST s (SlowPath s a)) -> ST s (SlowPath s a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs)
go_fast_end !ByteString
bs (ConsumeBytes k :: ByteString -> ST s (DecodeAction s a)
k) =
case Word8 -> ByteString -> DecodedToken (LongToken ByteString)
tryConsumeBytes (ByteString -> Word8
BS.unsafeHead ByteString
bs) ByteString
bs of
DecodeFailure -> SlowPath s a -> ST s (SlowPath s a)
forall (m :: * -> *) a. Monad m => a -> m a
return (SlowPath s a -> ST s (SlowPath s a))
-> SlowPath s a -> ST s (SlowPath s a)
forall a b. (a -> b) -> a -> b
$! ByteString -> String -> SlowPath s a
forall s a. ByteString -> String -> SlowPath s a
SlowFail ByteString
bs "expected bytes"
DecodedToken sz :: Int
sz (Fits _ bstr :: ByteString
bstr) -> ByteString -> ST s (DecodeAction s a)
k ByteString
bstr ST s (DecodeAction s a)
-> (DecodeAction s a -> ST s (SlowPath s a)) -> ST s (SlowPath s a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs)
DecodedToken sz :: Int
sz (TooLong _ len :: Int
len) -> SlowPath s a -> ST s (SlowPath s a)
forall (m :: * -> *) a. Monad m => a -> m a
return (SlowPath s a -> ST s (SlowPath s a))
-> SlowPath s a -> ST s (SlowPath s a)
forall a b. (a -> b) -> a -> b
$! ByteString
-> (ByteString -> ST s (DecodeAction s a)) -> Int -> SlowPath s a
forall s a.
ByteString
-> (ByteString -> ST s (DecodeAction s a)) -> Int -> SlowPath s a
SlowConsumeTokenBytes
(Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs) ByteString -> ST s (DecodeAction s a)
k Int
len
go_fast_end !ByteString
bs (ConsumeByteArray k :: ByteArray -> ST s (DecodeAction s a)
k) =
case Word8 -> ByteString -> DecodedToken (LongToken ByteString)
tryConsumeBytes (ByteString -> Word8
BS.unsafeHead ByteString
bs) ByteString
bs of
DecodeFailure -> SlowPath s a -> ST s (SlowPath s a)
forall (m :: * -> *) a. Monad m => a -> m a
return (SlowPath s a -> ST s (SlowPath s a))
-> SlowPath s a -> ST s (SlowPath s a)
forall a b. (a -> b) -> a -> b
$! ByteString -> String -> SlowPath s a
forall s a. ByteString -> String -> SlowPath s a
SlowFail ByteString
bs "expected string"
DecodedToken sz :: Int
sz (Fits _ str :: ByteString
str) -> (ByteArray -> ST s (DecodeAction s a)
k (ByteArray -> ST s (DecodeAction s a))
-> ByteArray -> ST s (DecodeAction s a)
forall a b. (a -> b) -> a -> b
$! ByteString -> ByteArray
BA.fromByteString ByteString
str)
ST s (DecodeAction s a)
-> (DecodeAction s a -> ST s (SlowPath s a)) -> ST s (SlowPath s a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs)
DecodedToken sz :: Int
sz (TooLong _ len :: Int
len) -> SlowPath s a -> ST s (SlowPath s a)
forall (m :: * -> *) a. Monad m => a -> m a
return (SlowPath s a -> ST s (SlowPath s a))
-> SlowPath s a -> ST s (SlowPath s a)
forall a b. (a -> b) -> a -> b
$! ByteString
-> (ByteArray -> ST s (DecodeAction s a)) -> Int -> SlowPath s a
forall s a.
ByteString
-> (ByteArray -> ST s (DecodeAction s a)) -> Int -> SlowPath s a
SlowConsumeTokenByteArray
(Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs) ByteArray -> ST s (DecodeAction s a)
k Int
len
go_fast_end !ByteString
bs (ConsumeString k :: Text -> ST s (DecodeAction s a)
k) =
case Word8 -> ByteString -> DecodedToken (LongToken ByteString)
tryConsumeString (ByteString -> Word8
BS.unsafeHead ByteString
bs) ByteString
bs of
DecodeFailure -> SlowPath s a -> ST s (SlowPath s a)
forall (m :: * -> *) a. Monad m => a -> m a
return (SlowPath s a -> ST s (SlowPath s a))
-> SlowPath s a -> ST s (SlowPath s a)
forall a b. (a -> b) -> a -> b
$! ByteString -> String -> SlowPath s a
forall s a. ByteString -> String -> SlowPath s a
SlowFail ByteString
bs "expected string"
DecodedToken sz :: Int
sz (Fits _ str :: ByteString
str) -> case ByteString -> Either UnicodeException Text
T.decodeUtf8' ByteString
str of
Right t :: Text
t -> Text -> ST s (DecodeAction s a)
k Text
t ST s (DecodeAction s a)
-> (DecodeAction s a -> ST s (SlowPath s a)) -> ST s (SlowPath s a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs)
Left _e :: UnicodeException
_e -> SlowPath s a -> ST s (SlowPath s a)
forall (m :: * -> *) a. Monad m => a -> m a
return (SlowPath s a -> ST s (SlowPath s a))
-> SlowPath s a -> ST s (SlowPath s a)
forall a b. (a -> b) -> a -> b
$! ByteString -> String -> SlowPath s a
forall s a. ByteString -> String -> SlowPath s a
SlowFail ByteString
bs "invalid UTF8"
DecodedToken sz :: Int
sz (TooLong _ len :: Int
len) -> SlowPath s a -> ST s (SlowPath s a)
forall (m :: * -> *) a. Monad m => a -> m a
return (SlowPath s a -> ST s (SlowPath s a))
-> SlowPath s a -> ST s (SlowPath s a)
forall a b. (a -> b) -> a -> b
$! ByteString
-> (Text -> ST s (DecodeAction s a)) -> Int -> SlowPath s a
forall s a.
ByteString
-> (Text -> ST s (DecodeAction s a)) -> Int -> SlowPath s a
SlowConsumeTokenString
(Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs) Text -> ST s (DecodeAction s a)
k Int
len
go_fast_end !ByteString
bs (ConsumeUtf8ByteArray k :: ByteArray -> ST s (DecodeAction s a)
k) =
case Word8 -> ByteString -> DecodedToken (LongToken ByteString)
tryConsumeString (ByteString -> Word8
BS.unsafeHead ByteString
bs) ByteString
bs of
DecodeFailure -> SlowPath s a -> ST s (SlowPath s a)
forall (m :: * -> *) a. Monad m => a -> m a
return (SlowPath s a -> ST s (SlowPath s a))
-> SlowPath s a -> ST s (SlowPath s a)
forall a b. (a -> b) -> a -> b
$! ByteString -> String -> SlowPath s a
forall s a. ByteString -> String -> SlowPath s a
SlowFail ByteString
bs "expected string"
DecodedToken sz :: Int
sz (Fits _ str :: ByteString
str) -> (ByteArray -> ST s (DecodeAction s a)
k (ByteArray -> ST s (DecodeAction s a))
-> ByteArray -> ST s (DecodeAction s a)
forall a b. (a -> b) -> a -> b
$! ByteString -> ByteArray
BA.fromByteString ByteString
str)
ST s (DecodeAction s a)
-> (DecodeAction s a -> ST s (SlowPath s a)) -> ST s (SlowPath s a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs)
DecodedToken sz :: Int
sz (TooLong _ len :: Int
len) -> SlowPath s a -> ST s (SlowPath s a)
forall (m :: * -> *) a. Monad m => a -> m a
return (SlowPath s a -> ST s (SlowPath s a))
-> SlowPath s a -> ST s (SlowPath s a)
forall a b. (a -> b) -> a -> b
$! ByteString
-> (ByteArray -> ST s (DecodeAction s a)) -> Int -> SlowPath s a
forall s a.
ByteString
-> (ByteArray -> ST s (DecodeAction s a)) -> Int -> SlowPath s a
SlowConsumeTokenUtf8ByteArray
(Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs) ByteArray -> ST s (DecodeAction s a)
k Int
len
go_fast_end !ByteString
bs (ConsumeBool k :: Bool -> ST s (DecodeAction s a)
k) =
case Word8 -> DecodedToken Bool
tryConsumeBool (ByteString -> Word8
BS.unsafeHead ByteString
bs) of
DecodeFailure -> SlowPath s a -> ST s (SlowPath s a)
forall (m :: * -> *) a. Monad m => a -> m a
return (SlowPath s a -> ST s (SlowPath s a))
-> SlowPath s a -> ST s (SlowPath s a)
forall a b. (a -> b) -> a -> b
$! ByteString -> String -> SlowPath s a
forall s a. ByteString -> String -> SlowPath s a
SlowFail ByteString
bs "expected bool"
DecodedToken sz :: Int
sz b :: Bool
b -> Bool -> ST s (DecodeAction s a)
k Bool
b ST s (DecodeAction s a)
-> (DecodeAction s a -> ST s (SlowPath s a)) -> ST s (SlowPath s a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs)
go_fast_end !ByteString
bs (ConsumeSimple k :: Word# -> ST s (DecodeAction s a)
k) =
case Word8 -> ByteString -> DecodedToken Word
tryConsumeSimple (ByteString -> Word8
BS.unsafeHead ByteString
bs) ByteString
bs of
DecodeFailure -> SlowPath s a -> ST s (SlowPath s a)
forall (m :: * -> *) a. Monad m => a -> m a
return (SlowPath s a -> ST s (SlowPath s a))
-> SlowPath s a -> ST s (SlowPath s a)
forall a b. (a -> b) -> a -> b
$! ByteString -> String -> SlowPath s a
forall s a. ByteString -> String -> SlowPath s a
SlowFail ByteString
bs "expected simple"
DecodedToken sz :: Int
sz (W# w# :: Word#
w#) -> Word# -> ST s (DecodeAction s a)
k Word#
w# ST s (DecodeAction s a)
-> (DecodeAction s a -> ST s (SlowPath s a)) -> ST s (SlowPath s a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs)
go_fast_end !ByteString
bs (ConsumeIntegerCanonical k :: Integer -> ST s (DecodeAction s a)
k) =
case Word8 -> ByteString -> DecodedToken (BigIntToken Integer)
tryConsumeInteger (ByteString -> Word8
BS.unsafeHead ByteString
bs) ByteString
bs of
DecodeFailure -> SlowPath s a -> ST s (SlowPath s a)
forall (m :: * -> *) a. Monad m => a -> m a
return (SlowPath s a -> ST s (SlowPath s a))
-> SlowPath s a -> ST s (SlowPath s a)
forall a b. (a -> b) -> a -> b
$! ByteString -> String -> SlowPath s a
forall s a. ByteString -> String -> SlowPath s a
SlowFail ByteString
bs "expected integer"
DecodedToken sz :: Int
sz (BigIntToken True n :: Integer
n) -> Integer -> ST s (DecodeAction s a)
k Integer
n ST s (DecodeAction s a)
-> (DecodeAction s a -> ST s (SlowPath s a)) -> ST s (SlowPath s a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs)
DecodedToken sz :: Int
sz (BigUIntNeedBody True len :: Int
len) -> SlowPath s a -> ST s (SlowPath s a)
forall (m :: * -> *) a. Monad m => a -> m a
return (SlowPath s a -> ST s (SlowPath s a))
-> SlowPath s a -> ST s (SlowPath s a)
forall a b. (a -> b) -> a -> b
$! ByteString
-> (ByteString -> ST s (DecodeAction s a)) -> Int -> SlowPath s a
forall s a.
ByteString
-> (ByteString -> ST s (DecodeAction s a)) -> Int -> SlowPath s a
SlowConsumeTokenBytes
(Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs) ((Integer -> ST s (DecodeAction s a))
-> ByteString -> ST s (DecodeAction s a)
forall s a.
(Integer -> ST s (DecodeAction s a))
-> ByteString -> ST s (DecodeAction s a)
adjustContCanonicalBigUIntNeedBody Integer -> ST s (DecodeAction s a)
k) Int
len
DecodedToken sz :: Int
sz (BigNIntNeedBody True len :: Int
len) -> SlowPath s a -> ST s (SlowPath s a)
forall (m :: * -> *) a. Monad m => a -> m a
return (SlowPath s a -> ST s (SlowPath s a))
-> SlowPath s a -> ST s (SlowPath s a)
forall a b. (a -> b) -> a -> b
$! ByteString
-> (ByteString -> ST s (DecodeAction s a)) -> Int -> SlowPath s a
forall s a.
ByteString
-> (ByteString -> ST s (DecodeAction s a)) -> Int -> SlowPath s a
SlowConsumeTokenBytes
(Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs) ((Integer -> ST s (DecodeAction s a))
-> ByteString -> ST s (DecodeAction s a)
forall s a.
(Integer -> ST s (DecodeAction s a))
-> ByteString -> ST s (DecodeAction s a)
adjustContCanonicalBigNIntNeedBody Integer -> ST s (DecodeAction s a)
k) Int
len
DecodedToken sz :: Int
sz BigUIntNeedHeader -> SlowPath s a -> ST s (SlowPath s a)
forall (m :: * -> *) a. Monad m => a -> m a
return (SlowPath s a -> ST s (SlowPath s a))
-> SlowPath s a -> ST s (SlowPath s a)
forall a b. (a -> b) -> a -> b
$! ByteString -> DecodeAction s a -> SlowPath s a
forall s a. ByteString -> DecodeAction s a -> SlowPath s a
SlowDecodeAction
(Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs) ((Integer -> ST s (DecodeAction s a)) -> DecodeAction s a
forall s a.
(Integer -> ST s (DecodeAction s a)) -> DecodeAction s a
adjustContCanonicalBigUIntNeedHeader Integer -> ST s (DecodeAction s a)
k)
DecodedToken sz :: Int
sz BigNIntNeedHeader -> SlowPath s a -> ST s (SlowPath s a)
forall (m :: * -> *) a. Monad m => a -> m a
return (SlowPath s a -> ST s (SlowPath s a))
-> SlowPath s a -> ST s (SlowPath s a)
forall a b. (a -> b) -> a -> b
$! ByteString -> DecodeAction s a -> SlowPath s a
forall s a. ByteString -> DecodeAction s a -> SlowPath s a
SlowDecodeAction
(Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs) ((Integer -> ST s (DecodeAction s a)) -> DecodeAction s a
forall s a.
(Integer -> ST s (DecodeAction s a)) -> DecodeAction s a
adjustContCanonicalBigNIntNeedHeader Integer -> ST s (DecodeAction s a)
k)
_ -> SlowPath s a -> ST s (SlowPath s a)
forall (m :: * -> *) a. Monad m => a -> m a
return (SlowPath s a -> ST s (SlowPath s a))
-> SlowPath s a -> ST s (SlowPath s a)
forall a b. (a -> b) -> a -> b
$! ByteString -> String -> SlowPath s a
forall s a. ByteString -> String -> SlowPath s a
SlowFail ByteString
bs "non-canonical integer"
go_fast_end !ByteString
bs (ConsumeFloat16Canonical k :: Float# -> ST s (DecodeAction s a)
k) =
case Word8 -> ByteString -> DecodedToken Float
tryConsumeFloat (ByteString -> Word8
BS.unsafeHead ByteString
bs) ByteString
bs of
DecodeFailure -> SlowPath s a -> ST s (SlowPath s a)
forall (m :: * -> *) a. Monad m => a -> m a
return (SlowPath s a -> ST s (SlowPath s a))
-> SlowPath s a -> ST s (SlowPath s a)
forall a b. (a -> b) -> a -> b
$! ByteString -> String -> SlowPath s a
forall s a. ByteString -> String -> SlowPath s a
SlowFail ByteString
bs "expected float"
DecodedToken sz :: Int
sz f :: Float
f@(F# f# :: Float#
f#)
| Int -> ByteString -> Float -> Bool
isFloat16Canonical Int
sz ByteString
bs Float
f -> Float# -> ST s (DecodeAction s a)
k Float#
f# ST s (DecodeAction s a)
-> (DecodeAction s a -> ST s (SlowPath s a)) -> ST s (SlowPath s a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs)
| Bool
otherwise -> SlowPath s a -> ST s (SlowPath s a)
forall (m :: * -> *) a. Monad m => a -> m a
return (SlowPath s a -> ST s (SlowPath s a))
-> SlowPath s a -> ST s (SlowPath s a)
forall a b. (a -> b) -> a -> b
$! ByteString -> String -> SlowPath s a
forall s a. ByteString -> String -> SlowPath s a
SlowFail ByteString
bs "non-canonical float16"
go_fast_end !ByteString
bs (ConsumeFloatCanonical k :: Float# -> ST s (DecodeAction s a)
k) =
case Word8 -> ByteString -> DecodedToken Float
tryConsumeFloat (ByteString -> Word8
BS.unsafeHead ByteString
bs) ByteString
bs of
DecodeFailure -> SlowPath s a -> ST s (SlowPath s a)
forall (m :: * -> *) a. Monad m => a -> m a
return (SlowPath s a -> ST s (SlowPath s a))
-> SlowPath s a -> ST s (SlowPath s a)
forall a b. (a -> b) -> a -> b
$! ByteString -> String -> SlowPath s a
forall s a. ByteString -> String -> SlowPath s a
SlowFail ByteString
bs "expected float"
DecodedToken sz :: Int
sz f :: Float
f@(F# f# :: Float#
f#)
| Int -> ByteString -> Float -> Bool
isFloatCanonical Int
sz ByteString
bs Float
f -> Float# -> ST s (DecodeAction s a)
k Float#
f# ST s (DecodeAction s a)
-> (DecodeAction s a -> ST s (SlowPath s a)) -> ST s (SlowPath s a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs)
| Bool
otherwise -> SlowPath s a -> ST s (SlowPath s a)
forall (m :: * -> *) a. Monad m => a -> m a
return (SlowPath s a -> ST s (SlowPath s a))
-> SlowPath s a -> ST s (SlowPath s a)
forall a b. (a -> b) -> a -> b
$! ByteString -> String -> SlowPath s a
forall s a. ByteString -> String -> SlowPath s a
SlowFail ByteString
bs "non-canonical float"
go_fast_end !ByteString
bs (ConsumeDoubleCanonical k :: Double# -> ST s (DecodeAction s a)
k) =
case Word8 -> ByteString -> DecodedToken Double
tryConsumeDouble (ByteString -> Word8
BS.unsafeHead ByteString
bs) ByteString
bs of
DecodeFailure -> SlowPath s a -> ST s (SlowPath s a)
forall (m :: * -> *) a. Monad m => a -> m a
return (SlowPath s a -> ST s (SlowPath s a))
-> SlowPath s a -> ST s (SlowPath s a)
forall a b. (a -> b) -> a -> b
$! ByteString -> String -> SlowPath s a
forall s a. ByteString -> String -> SlowPath s a
SlowFail ByteString
bs "expected double"
DecodedToken sz :: Int
sz f :: Double
f@(D# f# :: Double#
f#)
| Int -> ByteString -> Double -> Bool
isDoubleCanonical Int
sz ByteString
bs Double
f -> Double# -> ST s (DecodeAction s a)
k Double#
f# ST s (DecodeAction s a)
-> (DecodeAction s a -> ST s (SlowPath s a)) -> ST s (SlowPath s a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs)
| Bool
otherwise -> SlowPath s a -> ST s (SlowPath s a)
forall (m :: * -> *) a. Monad m => a -> m a
return (SlowPath s a -> ST s (SlowPath s a))
-> SlowPath s a -> ST s (SlowPath s a)
forall a b. (a -> b) -> a -> b
$! ByteString -> String -> SlowPath s a
forall s a. ByteString -> String -> SlowPath s a
SlowFail ByteString
bs "non-canonical double"
go_fast_end !ByteString
bs (ConsumeBytesCanonical k :: ByteString -> ST s (DecodeAction s a)
k) =
case Word8 -> ByteString -> DecodedToken (LongToken ByteString)
tryConsumeBytes (ByteString -> Word8
BS.unsafeHead ByteString
bs) ByteString
bs of
DecodeFailure -> SlowPath s a -> ST s (SlowPath s a)
forall (m :: * -> *) a. Monad m => a -> m a
return (SlowPath s a -> ST s (SlowPath s a))
-> SlowPath s a -> ST s (SlowPath s a)
forall a b. (a -> b) -> a -> b
$! ByteString -> String -> SlowPath s a
forall s a. ByteString -> String -> SlowPath s a
SlowFail ByteString
bs "expected bytes"
DecodedToken sz :: Int
sz token :: LongToken ByteString
token -> case LongToken ByteString
token of
Fits True bstr :: ByteString
bstr -> ByteString -> ST s (DecodeAction s a)
k ByteString
bstr ST s (DecodeAction s a)
-> (DecodeAction s a -> ST s (SlowPath s a)) -> ST s (SlowPath s a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs)
TooLong True len :: Int
len -> SlowPath s a -> ST s (SlowPath s a)
forall (m :: * -> *) a. Monad m => a -> m a
return (SlowPath s a -> ST s (SlowPath s a))
-> SlowPath s a -> ST s (SlowPath s a)
forall a b. (a -> b) -> a -> b
$! ByteString
-> (ByteString -> ST s (DecodeAction s a)) -> Int -> SlowPath s a
forall s a.
ByteString
-> (ByteString -> ST s (DecodeAction s a)) -> Int -> SlowPath s a
SlowConsumeTokenBytes (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs) ByteString -> ST s (DecodeAction s a)
k Int
len
_ -> SlowPath s a -> ST s (SlowPath s a)
forall (m :: * -> *) a. Monad m => a -> m a
return (SlowPath s a -> ST s (SlowPath s a))
-> SlowPath s a -> ST s (SlowPath s a)
forall a b. (a -> b) -> a -> b
$! ByteString -> String -> SlowPath s a
forall s a. ByteString -> String -> SlowPath s a
SlowFail ByteString
bs "non-canonical length prefix"
go_fast_end !ByteString
bs (ConsumeByteArrayCanonical k :: ByteArray -> ST s (DecodeAction s a)
k) =
case Word8 -> ByteString -> DecodedToken (LongToken ByteString)
tryConsumeBytes (ByteString -> Word8
BS.unsafeHead ByteString
bs) ByteString
bs of
DecodeFailure -> SlowPath s a -> ST s (SlowPath s a)
forall (m :: * -> *) a. Monad m => a -> m a
return (SlowPath s a -> ST s (SlowPath s a))
-> SlowPath s a -> ST s (SlowPath s a)
forall a b. (a -> b) -> a -> b
$! ByteString -> String -> SlowPath s a
forall s a. ByteString -> String -> SlowPath s a
SlowFail ByteString
bs "expected string"
DecodedToken sz :: Int
sz token :: LongToken ByteString
token -> case LongToken ByteString
token of
Fits True str :: ByteString
str ->
(ByteArray -> ST s (DecodeAction s a)
k (ByteArray -> ST s (DecodeAction s a))
-> ByteArray -> ST s (DecodeAction s a)
forall a b. (a -> b) -> a -> b
$! ByteString -> ByteArray
BA.fromByteString ByteString
str) ST s (DecodeAction s a)
-> (DecodeAction s a -> ST s (SlowPath s a)) -> ST s (SlowPath s a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs)
TooLong True len :: Int
len ->
SlowPath s a -> ST s (SlowPath s a)
forall (m :: * -> *) a. Monad m => a -> m a
return (SlowPath s a -> ST s (SlowPath s a))
-> SlowPath s a -> ST s (SlowPath s a)
forall a b. (a -> b) -> a -> b
$! ByteString
-> (ByteArray -> ST s (DecodeAction s a)) -> Int -> SlowPath s a
forall s a.
ByteString
-> (ByteArray -> ST s (DecodeAction s a)) -> Int -> SlowPath s a
SlowConsumeTokenByteArray (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs) ByteArray -> ST s (DecodeAction s a)
k Int
len
_ -> SlowPath s a -> ST s (SlowPath s a)
forall (m :: * -> *) a. Monad m => a -> m a
return (SlowPath s a -> ST s (SlowPath s a))
-> SlowPath s a -> ST s (SlowPath s a)
forall a b. (a -> b) -> a -> b
$! ByteString -> String -> SlowPath s a
forall s a. ByteString -> String -> SlowPath s a
SlowFail ByteString
bs "non-canonical length prefix"
go_fast_end !ByteString
bs (ConsumeStringCanonical k :: Text -> ST s (DecodeAction s a)
k) =
case Word8 -> ByteString -> DecodedToken (LongToken ByteString)
tryConsumeString (ByteString -> Word8
BS.unsafeHead ByteString
bs) ByteString
bs of
DecodeFailure -> SlowPath s a -> ST s (SlowPath s a)
forall (m :: * -> *) a. Monad m => a -> m a
return (SlowPath s a -> ST s (SlowPath s a))
-> SlowPath s a -> ST s (SlowPath s a)
forall a b. (a -> b) -> a -> b
$! ByteString -> String -> SlowPath s a
forall s a. ByteString -> String -> SlowPath s a
SlowFail ByteString
bs "expected string"
DecodedToken sz :: Int
sz token :: LongToken ByteString
token -> case LongToken ByteString
token of
Fits True str :: ByteString
str -> case ByteString -> Either UnicodeException Text
T.decodeUtf8' ByteString
str of
Right t :: Text
t -> Text -> ST s (DecodeAction s a)
k Text
t ST s (DecodeAction s a)
-> (DecodeAction s a -> ST s (SlowPath s a)) -> ST s (SlowPath s a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs)
Left _e :: UnicodeException
_e -> SlowPath s a -> ST s (SlowPath s a)
forall (m :: * -> *) a. Monad m => a -> m a
return (SlowPath s a -> ST s (SlowPath s a))
-> SlowPath s a -> ST s (SlowPath s a)
forall a b. (a -> b) -> a -> b
$! ByteString -> String -> SlowPath s a
forall s a. ByteString -> String -> SlowPath s a
SlowFail ByteString
bs "invalid UTF8"
TooLong True len :: Int
len -> SlowPath s a -> ST s (SlowPath s a)
forall (m :: * -> *) a. Monad m => a -> m a
return (SlowPath s a -> ST s (SlowPath s a))
-> SlowPath s a -> ST s (SlowPath s a)
forall a b. (a -> b) -> a -> b
$! ByteString
-> (Text -> ST s (DecodeAction s a)) -> Int -> SlowPath s a
forall s a.
ByteString
-> (Text -> ST s (DecodeAction s a)) -> Int -> SlowPath s a
SlowConsumeTokenString (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs) Text -> ST s (DecodeAction s a)
k Int
len
_ -> SlowPath s a -> ST s (SlowPath s a)
forall (m :: * -> *) a. Monad m => a -> m a
return (SlowPath s a -> ST s (SlowPath s a))
-> SlowPath s a -> ST s (SlowPath s a)
forall a b. (a -> b) -> a -> b
$! ByteString -> String -> SlowPath s a
forall s a. ByteString -> String -> SlowPath s a
SlowFail ByteString
bs "non-canonical length prefix"
go_fast_end !ByteString
bs (ConsumeUtf8ByteArrayCanonical k :: ByteArray -> ST s (DecodeAction s a)
k) =
case Word8 -> ByteString -> DecodedToken (LongToken ByteString)
tryConsumeString (ByteString -> Word8
BS.unsafeHead ByteString
bs) ByteString
bs of
DecodeFailure -> SlowPath s a -> ST s (SlowPath s a)
forall (m :: * -> *) a. Monad m => a -> m a
return (SlowPath s a -> ST s (SlowPath s a))
-> SlowPath s a -> ST s (SlowPath s a)
forall a b. (a -> b) -> a -> b
$! ByteString -> String -> SlowPath s a
forall s a. ByteString -> String -> SlowPath s a
SlowFail ByteString
bs "expected string"
DecodedToken sz :: Int
sz token :: LongToken ByteString
token -> case LongToken ByteString
token of
Fits True str :: ByteString
str ->
(ByteArray -> ST s (DecodeAction s a)
k (ByteArray -> ST s (DecodeAction s a))
-> ByteArray -> ST s (DecodeAction s a)
forall a b. (a -> b) -> a -> b
$! ByteString -> ByteArray
BA.fromByteString ByteString
str) ST s (DecodeAction s a)
-> (DecodeAction s a -> ST s (SlowPath s a)) -> ST s (SlowPath s a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs)
TooLong True len :: Int
len ->
SlowPath s a -> ST s (SlowPath s a)
forall (m :: * -> *) a. Monad m => a -> m a
return (SlowPath s a -> ST s (SlowPath s a))
-> SlowPath s a -> ST s (SlowPath s a)
forall a b. (a -> b) -> a -> b
$! ByteString
-> (ByteArray -> ST s (DecodeAction s a)) -> Int -> SlowPath s a
forall s a.
ByteString
-> (ByteArray -> ST s (DecodeAction s a)) -> Int -> SlowPath s a
SlowConsumeTokenUtf8ByteArray (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs) ByteArray -> ST s (DecodeAction s a)
k Int
len
_ ->
SlowPath s a -> ST s (SlowPath s a)
forall (m :: * -> *) a. Monad m => a -> m a
return (SlowPath s a -> ST s (SlowPath s a))
-> SlowPath s a -> ST s (SlowPath s a)
forall a b. (a -> b) -> a -> b
$! ByteString -> String -> SlowPath s a
forall s a. ByteString -> String -> SlowPath s a
SlowFail ByteString
bs "non-canonical length prefix"
go_fast_end !ByteString
bs (ConsumeSimpleCanonical k :: Word# -> ST s (DecodeAction s a)
k) =
case Word8 -> ByteString -> DecodedToken Word
tryConsumeSimple (ByteString -> Word8
BS.unsafeHead ByteString
bs) ByteString
bs of
DecodeFailure -> SlowPath s a -> ST s (SlowPath s a)
forall (m :: * -> *) a. Monad m => a -> m a
return (SlowPath s a -> ST s (SlowPath s a))
-> SlowPath s a -> ST s (SlowPath s a)
forall a b. (a -> b) -> a -> b
$! ByteString -> String -> SlowPath s a
forall s a. ByteString -> String -> SlowPath s a
SlowFail ByteString
bs "expected simple"
DecodedToken sz :: Int
sz (W# w# :: Word#
w#)
| Int -> Word# -> Bool
isSimpleCanonical Int
sz Word#
w# -> Word# -> ST s (DecodeAction s a)
k Word#
w# ST s (DecodeAction s a)
-> (DecodeAction s a -> ST s (SlowPath s a)) -> ST s (SlowPath s a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs)
| Bool
otherwise -> SlowPath s a -> ST s (SlowPath s a)
forall (m :: * -> *) a. Monad m => a -> m a
return (SlowPath s a -> ST s (SlowPath s a))
-> SlowPath s a -> ST s (SlowPath s a)
forall a b. (a -> b) -> a -> b
$! ByteString -> String -> SlowPath s a
forall s a. ByteString -> String -> SlowPath s a
SlowFail ByteString
bs "non-canonical simple"
go_fast_end !ByteString
bs (ConsumeBytesIndef k :: ST s (DecodeAction s a)
k) =
case Word8 -> DecodedToken ()
tryConsumeBytesIndef (ByteString -> Word8
BS.unsafeHead ByteString
bs) of
DecodeFailure -> SlowPath s a -> ST s (SlowPath s a)
forall (m :: * -> *) a. Monad m => a -> m a
return (SlowPath s a -> ST s (SlowPath s a))
-> SlowPath s a -> ST s (SlowPath s a)
forall a b. (a -> b) -> a -> b
$! ByteString -> String -> SlowPath s a
forall s a. ByteString -> String -> SlowPath s a
SlowFail ByteString
bs "expected bytes start"
DecodedToken sz :: Int
sz _ -> ST s (DecodeAction s a)
k ST s (DecodeAction s a)
-> (DecodeAction s a -> ST s (SlowPath s a)) -> ST s (SlowPath s a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs)
go_fast_end !ByteString
bs (ConsumeStringIndef k :: ST s (DecodeAction s a)
k) =
case Word8 -> DecodedToken ()
tryConsumeStringIndef (ByteString -> Word8
BS.unsafeHead ByteString
bs) of
DecodeFailure -> SlowPath s a -> ST s (SlowPath s a)
forall (m :: * -> *) a. Monad m => a -> m a
return (SlowPath s a -> ST s (SlowPath s a))
-> SlowPath s a -> ST s (SlowPath s a)
forall a b. (a -> b) -> a -> b
$! ByteString -> String -> SlowPath s a
forall s a. ByteString -> String -> SlowPath s a
SlowFail ByteString
bs "expected string start"
DecodedToken sz :: Int
sz _ -> ST s (DecodeAction s a)
k ST s (DecodeAction s a)
-> (DecodeAction s a -> ST s (SlowPath s a)) -> ST s (SlowPath s a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs)
go_fast_end !ByteString
bs (ConsumeListLenIndef k :: ST s (DecodeAction s a)
k) =
case Word8 -> DecodedToken ()
tryConsumeListLenIndef (ByteString -> Word8
BS.unsafeHead ByteString
bs) of
DecodeFailure -> SlowPath s a -> ST s (SlowPath s a)
forall (m :: * -> *) a. Monad m => a -> m a
return (SlowPath s a -> ST s (SlowPath s a))
-> SlowPath s a -> ST s (SlowPath s a)
forall a b. (a -> b) -> a -> b
$! ByteString -> String -> SlowPath s a
forall s a. ByteString -> String -> SlowPath s a
SlowFail ByteString
bs "expected list start"
DecodedToken sz :: Int
sz _ -> ST s (DecodeAction s a)
k ST s (DecodeAction s a)
-> (DecodeAction s a -> ST s (SlowPath s a)) -> ST s (SlowPath s a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs)
go_fast_end !ByteString
bs (ConsumeMapLenIndef k :: ST s (DecodeAction s a)
k) =
case Word8 -> DecodedToken ()
tryConsumeMapLenIndef (ByteString -> Word8
BS.unsafeHead ByteString
bs) of
DecodeFailure -> SlowPath s a -> ST s (SlowPath s a)
forall (m :: * -> *) a. Monad m => a -> m a
return (SlowPath s a -> ST s (SlowPath s a))
-> SlowPath s a -> ST s (SlowPath s a)
forall a b. (a -> b) -> a -> b
$! ByteString -> String -> SlowPath s a
forall s a. ByteString -> String -> SlowPath s a
SlowFail ByteString
bs "expected map start"
DecodedToken sz :: Int
sz _ -> ST s (DecodeAction s a)
k ST s (DecodeAction s a)
-> (DecodeAction s a -> ST s (SlowPath s a)) -> ST s (SlowPath s a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs)
go_fast_end !ByteString
bs (ConsumeNull k :: ST s (DecodeAction s a)
k) =
case Word8 -> DecodedToken ()
tryConsumeNull (ByteString -> Word8
BS.unsafeHead ByteString
bs) of
DecodeFailure -> SlowPath s a -> ST s (SlowPath s a)
forall (m :: * -> *) a. Monad m => a -> m a
return (SlowPath s a -> ST s (SlowPath s a))
-> SlowPath s a -> ST s (SlowPath s a)
forall a b. (a -> b) -> a -> b
$! ByteString -> String -> SlowPath s a
forall s a. ByteString -> String -> SlowPath s a
SlowFail ByteString
bs "expected null"
DecodedToken sz :: Int
sz _ -> ST s (DecodeAction s a)
k ST s (DecodeAction s a)
-> (DecodeAction s a -> ST s (SlowPath s a)) -> ST s (SlowPath s a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs)
go_fast_end !ByteString
bs (ConsumeListLenOrIndef k :: Int# -> ST s (DecodeAction s a)
k) =
case Word8 -> ByteString -> DecodedToken Int
tryConsumeListLenOrIndef (ByteString -> Word8
BS.unsafeHead ByteString
bs) ByteString
bs of
DecodeFailure -> SlowPath s a -> ST s (SlowPath s a)
forall (m :: * -> *) a. Monad m => a -> m a
return (SlowPath s a -> ST s (SlowPath s a))
-> SlowPath s a -> ST s (SlowPath s a)
forall a b. (a -> b) -> a -> b
$! ByteString -> String -> SlowPath s a
forall s a. ByteString -> String -> SlowPath s a
SlowFail ByteString
bs "expected list len or indef"
DecodedToken sz :: Int
sz (I# n# :: Int#
n#) -> Int# -> ST s (DecodeAction s a)
k Int#
n# ST s (DecodeAction s a)
-> (DecodeAction s a -> ST s (SlowPath s a)) -> ST s (SlowPath s a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs)
go_fast_end !ByteString
bs (ConsumeMapLenOrIndef k :: Int# -> ST s (DecodeAction s a)
k) =
case Word8 -> ByteString -> DecodedToken Int
tryConsumeMapLenOrIndef (ByteString -> Word8
BS.unsafeHead ByteString
bs) ByteString
bs of
DecodeFailure -> SlowPath s a -> ST s (SlowPath s a)
forall (m :: * -> *) a. Monad m => a -> m a
return (SlowPath s a -> ST s (SlowPath s a))
-> SlowPath s a -> ST s (SlowPath s a)
forall a b. (a -> b) -> a -> b
$! ByteString -> String -> SlowPath s a
forall s a. ByteString -> String -> SlowPath s a
SlowFail ByteString
bs "expected map len or indef"
DecodedToken sz :: Int
sz (I# n# :: Int#
n#) -> Int# -> ST s (DecodeAction s a)
k Int#
n# ST s (DecodeAction s a)
-> (DecodeAction s a -> ST s (SlowPath s a)) -> ST s (SlowPath s a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end (Int -> ByteString -> ByteString
BS.unsafeDrop Int
sz ByteString
bs)
go_slow :: DecodeAction s a -> ByteString -> ByteOffset
-> IncrementalDecoder s (ByteString, ByteOffset, a)
go_slow :: DecodeAction s a
-> ByteString
-> ByteOffset
-> IncrementalDecoder s (ByteString, ByteOffset, a)
go_slow da :: DecodeAction s a
da bs :: ByteString
bs !ByteOffset
offset = do
SlowPath s a
slowpath <- ST s (SlowPath s a) -> IncrementalDecoder s (SlowPath s a)
forall s a. ST s a -> IncrementalDecoder s a
lift (ST s (SlowPath s a) -> IncrementalDecoder s (SlowPath s a))
-> ST s (SlowPath s a) -> IncrementalDecoder s (SlowPath s a)
forall a b. (a -> b) -> a -> b
$ ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast ByteString
bs DecodeAction s a
da
case SlowPath s a
slowpath of
FastDone bs' :: ByteString
bs' x :: a
x -> (ByteString, ByteOffset, a)
-> IncrementalDecoder s (ByteString, ByteOffset, a)
forall (m :: * -> *) a. Monad m => a -> m a
return (ByteString
bs', ByteOffset
offset', a
x)
where
!offset' :: ByteOffset
offset' = ByteOffset
offset ByteOffset -> ByteOffset -> ByteOffset
forall a. Num a => a -> a -> a
+ Int -> ByteOffset
intToInt64 (ByteString -> Int
BS.length ByteString
bs Int -> Int -> Int
forall a. Num a => a -> a -> a
- ByteString -> Int
BS.length ByteString
bs')
SlowConsumeTokenBytes bs' :: ByteString
bs' k :: ByteString -> ST s (DecodeAction s a)
k len :: Int
len -> do
(bstr :: ByteString
bstr, bs'' :: ByteString
bs'') <- Int
-> ByteString
-> ByteOffset
-> IncrementalDecoder s (ByteString, ByteString)
forall s.
Int
-> ByteString
-> ByteOffset
-> IncrementalDecoder s (ByteString, ByteString)
getTokenVarLen Int
len ByteString
bs' ByteOffset
offset'
ST s (DecodeAction s a) -> IncrementalDecoder s (DecodeAction s a)
forall s a. ST s a -> IncrementalDecoder s a
lift (ByteString -> ST s (DecodeAction s a)
k ByteString
bstr) IncrementalDecoder s (DecodeAction s a)
-> (DecodeAction s a
-> IncrementalDecoder s (ByteString, ByteOffset, a))
-> IncrementalDecoder s (ByteString, ByteOffset, a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \daz :: DecodeAction s a
daz -> DecodeAction s a
-> ByteString
-> ByteOffset
-> IncrementalDecoder s (ByteString, ByteOffset, a)
forall s a.
DecodeAction s a
-> ByteString
-> ByteOffset
-> IncrementalDecoder s (ByteString, ByteOffset, a)
go_slow DecodeAction s a
daz ByteString
bs'' (ByteOffset
offset' ByteOffset -> ByteOffset -> ByteOffset
forall a. Num a => a -> a -> a
+ Int -> ByteOffset
intToInt64 Int
len)
where
!offset' :: ByteOffset
offset' = ByteOffset
offset ByteOffset -> ByteOffset -> ByteOffset
forall a. Num a => a -> a -> a
+ Int -> ByteOffset
intToInt64 (ByteString -> Int
BS.length ByteString
bs Int -> Int -> Int
forall a. Num a => a -> a -> a
- ByteString -> Int
BS.length ByteString
bs')
SlowConsumeTokenByteArray bs' :: ByteString
bs' k :: ByteArray -> ST s (DecodeAction s a)
k len :: Int
len -> do
(bstr :: ByteString
bstr, bs'' :: ByteString
bs'') <- Int
-> ByteString
-> ByteOffset
-> IncrementalDecoder s (ByteString, ByteString)
forall s.
Int
-> ByteString
-> ByteOffset
-> IncrementalDecoder s (ByteString, ByteString)
getTokenVarLen Int
len ByteString
bs' ByteOffset
offset'
let !str :: ByteArray
str = ByteString -> ByteArray
BA.fromByteString ByteString
bstr
ST s (DecodeAction s a) -> IncrementalDecoder s (DecodeAction s a)
forall s a. ST s a -> IncrementalDecoder s a
lift (ByteArray -> ST s (DecodeAction s a)
k ByteArray
str) IncrementalDecoder s (DecodeAction s a)
-> (DecodeAction s a
-> IncrementalDecoder s (ByteString, ByteOffset, a))
-> IncrementalDecoder s (ByteString, ByteOffset, a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \daz :: DecodeAction s a
daz -> DecodeAction s a
-> ByteString
-> ByteOffset
-> IncrementalDecoder s (ByteString, ByteOffset, a)
forall s a.
DecodeAction s a
-> ByteString
-> ByteOffset
-> IncrementalDecoder s (ByteString, ByteOffset, a)
go_slow DecodeAction s a
daz ByteString
bs'' (ByteOffset
offset' ByteOffset -> ByteOffset -> ByteOffset
forall a. Num a => a -> a -> a
+ Int -> ByteOffset
intToInt64 Int
len)
where
!offset' :: ByteOffset
offset' = ByteOffset
offset ByteOffset -> ByteOffset -> ByteOffset
forall a. Num a => a -> a -> a
+ Int -> ByteOffset
intToInt64 (ByteString -> Int
BS.length ByteString
bs Int -> Int -> Int
forall a. Num a => a -> a -> a
- ByteString -> Int
BS.length ByteString
bs')
SlowConsumeTokenString bs' :: ByteString
bs' k :: Text -> ST s (DecodeAction s a)
k len :: Int
len -> do
(bstr :: ByteString
bstr, bs'' :: ByteString
bs'') <- Int
-> ByteString
-> ByteOffset
-> IncrementalDecoder s (ByteString, ByteString)
forall s.
Int
-> ByteString
-> ByteOffset
-> IncrementalDecoder s (ByteString, ByteString)
getTokenVarLen Int
len ByteString
bs' ByteOffset
offset'
case ByteString -> Either UnicodeException Text
T.decodeUtf8' ByteString
bstr of
Right str :: Text
str -> ST s (DecodeAction s a) -> IncrementalDecoder s (DecodeAction s a)
forall s a. ST s a -> IncrementalDecoder s a
lift (Text -> ST s (DecodeAction s a)
k Text
str) IncrementalDecoder s (DecodeAction s a)
-> (DecodeAction s a
-> IncrementalDecoder s (ByteString, ByteOffset, a))
-> IncrementalDecoder s (ByteString, ByteOffset, a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \daz :: DecodeAction s a
daz ->
DecodeAction s a
-> ByteString
-> ByteOffset
-> IncrementalDecoder s (ByteString, ByteOffset, a)
forall s a.
DecodeAction s a
-> ByteString
-> ByteOffset
-> IncrementalDecoder s (ByteString, ByteOffset, a)
go_slow DecodeAction s a
daz ByteString
bs'' (ByteOffset
offset' ByteOffset -> ByteOffset -> ByteOffset
forall a. Num a => a -> a -> a
+ Int -> ByteOffset
intToInt64 Int
len)
Left _e :: UnicodeException
_e -> ByteString
-> ByteOffset
-> String
-> IncrementalDecoder s (ByteString, ByteOffset, a)
forall s a.
ByteString -> ByteOffset -> String -> IncrementalDecoder s a
decodeFail ByteString
bs' ByteOffset
offset' "invalid UTF8"
where
!offset' :: ByteOffset
offset' = ByteOffset
offset ByteOffset -> ByteOffset -> ByteOffset
forall a. Num a => a -> a -> a
+ Int -> ByteOffset
intToInt64 (ByteString -> Int
BS.length ByteString
bs Int -> Int -> Int
forall a. Num a => a -> a -> a
- ByteString -> Int
BS.length ByteString
bs')
SlowConsumeTokenUtf8ByteArray bs' :: ByteString
bs' k :: ByteArray -> ST s (DecodeAction s a)
k len :: Int
len -> do
(bstr :: ByteString
bstr, bs'' :: ByteString
bs'') <- Int
-> ByteString
-> ByteOffset
-> IncrementalDecoder s (ByteString, ByteString)
forall s.
Int
-> ByteString
-> ByteOffset
-> IncrementalDecoder s (ByteString, ByteString)
getTokenVarLen Int
len ByteString
bs' ByteOffset
offset'
let !str :: ByteArray
str = ByteString -> ByteArray
BA.fromByteString ByteString
bstr
ST s (DecodeAction s a) -> IncrementalDecoder s (DecodeAction s a)
forall s a. ST s a -> IncrementalDecoder s a
lift (ByteArray -> ST s (DecodeAction s a)
k ByteArray
str) IncrementalDecoder s (DecodeAction s a)
-> (DecodeAction s a
-> IncrementalDecoder s (ByteString, ByteOffset, a))
-> IncrementalDecoder s (ByteString, ByteOffset, a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \daz :: DecodeAction s a
daz -> DecodeAction s a
-> ByteString
-> ByteOffset
-> IncrementalDecoder s (ByteString, ByteOffset, a)
forall s a.
DecodeAction s a
-> ByteString
-> ByteOffset
-> IncrementalDecoder s (ByteString, ByteOffset, a)
go_slow DecodeAction s a
daz ByteString
bs'' (ByteOffset
offset' ByteOffset -> ByteOffset -> ByteOffset
forall a. Num a => a -> a -> a
+ Int -> ByteOffset
intToInt64 Int
len)
where
!offset' :: ByteOffset
offset' = ByteOffset
offset ByteOffset -> ByteOffset -> ByteOffset
forall a. Num a => a -> a -> a
+ Int -> ByteOffset
intToInt64 (ByteString -> Int
BS.length ByteString
bs Int -> Int -> Int
forall a. Num a => a -> a -> a
- ByteString -> Int
BS.length ByteString
bs')
SlowDecodeAction bs' :: ByteString
bs' da' :: DecodeAction s a
da' | ByteString -> Bool
BS.null ByteString
bs' -> do
Maybe ByteString
mbs <- IncrementalDecoder s (Maybe ByteString)
forall s. IncrementalDecoder s (Maybe ByteString)
needChunk
case Maybe ByteString
mbs of
Nothing -> ByteString
-> ByteOffset
-> String
-> IncrementalDecoder s (ByteString, ByteOffset, a)
forall s a.
ByteString -> ByteOffset -> String -> IncrementalDecoder s a
decodeFail ByteString
bs' ByteOffset
offset' "end of input"
Just bs'' :: ByteString
bs'' -> DecodeAction s a
-> ByteString
-> ByteOffset
-> IncrementalDecoder s (ByteString, ByteOffset, a)
forall s a.
DecodeAction s a
-> ByteString
-> ByteOffset
-> IncrementalDecoder s (ByteString, ByteOffset, a)
go_slow DecodeAction s a
da' ByteString
bs'' ByteOffset
offset'
where
!offset' :: ByteOffset
offset' = ByteOffset
offset ByteOffset -> ByteOffset -> ByteOffset
forall a. Num a => a -> a -> a
+ Int -> ByteOffset
intToInt64 (ByteString -> Int
BS.length ByteString
bs Int -> Int -> Int
forall a. Num a => a -> a -> a
- ByteString -> Int
BS.length ByteString
bs')
SlowDecodeAction bs' :: ByteString
bs' da' :: DecodeAction s a
da' ->
Bool
-> IncrementalDecoder s (ByteString, ByteOffset, a)
-> IncrementalDecoder s (ByteString, ByteOffset, a)
forall a. (?callStack::CallStack) => Bool -> a -> a
assert (ByteString -> Int
BS.length ByteString
bs' Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
< Word8 -> Int
tokenSize (ByteString -> Word8
BS.head ByteString
bs')) (IncrementalDecoder s (ByteString, ByteOffset, a)
-> IncrementalDecoder s (ByteString, ByteOffset, a))
-> IncrementalDecoder s (ByteString, ByteOffset, a)
-> IncrementalDecoder s (ByteString, ByteOffset, a)
forall a b. (a -> b) -> a -> b
$
DecodeAction s a
-> ByteString
-> ByteOffset
-> IncrementalDecoder s (ByteString, ByteOffset, a)
forall s a.
DecodeAction s a
-> ByteString
-> ByteOffset
-> IncrementalDecoder s (ByteString, ByteOffset, a)
go_slow_fixup DecodeAction s a
da' ByteString
bs' ByteOffset
offset'
where
!offset' :: ByteOffset
offset' = ByteOffset
offset ByteOffset -> ByteOffset -> ByteOffset
forall a. Num a => a -> a -> a
+ Int -> ByteOffset
intToInt64 (ByteString -> Int
BS.length ByteString
bs Int -> Int -> Int
forall a. Num a => a -> a -> a
- ByteString -> Int
BS.length ByteString
bs')
SlowPeekByteOffset bs' :: ByteString
bs' k :: Int64# -> ST s (DecodeAction s a)
k ->
ST s (DecodeAction s a) -> IncrementalDecoder s (DecodeAction s a)
forall s a. ST s a -> IncrementalDecoder s a
lift (Int64# -> ST s (DecodeAction s a)
k Int64#
off#) IncrementalDecoder s (DecodeAction s a)
-> (DecodeAction s a
-> IncrementalDecoder s (ByteString, ByteOffset, a))
-> IncrementalDecoder s (ByteString, ByteOffset, a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \daz :: DecodeAction s a
daz -> DecodeAction s a
-> ByteString
-> ByteOffset
-> IncrementalDecoder s (ByteString, ByteOffset, a)
forall s a.
DecodeAction s a
-> ByteString
-> ByteOffset
-> IncrementalDecoder s (ByteString, ByteOffset, a)
go_slow DecodeAction s a
daz ByteString
bs' ByteOffset
offset'
where
!offset' :: ByteOffset
offset'@(I64# off# :: Int64#
off#) = ByteOffset
offset ByteOffset -> ByteOffset -> ByteOffset
forall a. Num a => a -> a -> a
+ Int -> ByteOffset
intToInt64 (ByteString -> Int
BS.length ByteString
bs Int -> Int -> Int
forall a. Num a => a -> a -> a
- ByteString -> Int
BS.length ByteString
bs')
SlowFail bs' :: ByteString
bs' msg :: String
msg -> ByteString
-> ByteOffset
-> String
-> IncrementalDecoder s (ByteString, ByteOffset, a)
forall s a.
ByteString -> ByteOffset -> String -> IncrementalDecoder s a
decodeFail ByteString
bs' ByteOffset
offset' String
msg
where
!offset' :: ByteOffset
offset' = ByteOffset
offset ByteOffset -> ByteOffset -> ByteOffset
forall a. Num a => a -> a -> a
+ Int -> ByteOffset
intToInt64 (ByteString -> Int
BS.length ByteString
bs Int -> Int -> Int
forall a. Num a => a -> a -> a
- ByteString -> Int
BS.length ByteString
bs')
go_slow_fixup :: DecodeAction s a -> ByteString -> ByteOffset
-> IncrementalDecoder s (ByteString, ByteOffset, a)
go_slow_fixup :: DecodeAction s a
-> ByteString
-> ByteOffset
-> IncrementalDecoder s (ByteString, ByteOffset, a)
go_slow_fixup da :: DecodeAction s a
da !ByteString
bs !ByteOffset
offset = do
let !hdr :: Word8
hdr = ByteString -> Word8
BS.head ByteString
bs
!sz :: Int
sz = Word8 -> Int
tokenSize Word8
hdr
Maybe ByteString
mbs <- IncrementalDecoder s (Maybe ByteString)
forall s. IncrementalDecoder s (Maybe ByteString)
needChunk
case Maybe ByteString
mbs of
Nothing -> ByteString
-> ByteOffset
-> String
-> IncrementalDecoder s (ByteString, ByteOffset, a)
forall s a.
ByteString -> ByteOffset -> String -> IncrementalDecoder s a
decodeFail ByteString
bs ByteOffset
offset "end of input"
Just bs' :: ByteString
bs'
| ByteString -> Int
BS.length ByteString
bs Int -> Int -> Int
forall a. Num a => a -> a -> a
+ ByteString -> Int
BS.length ByteString
bs' Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
>= Int
sz
-> DecodeAction s a
-> Int
-> ByteString
-> ByteString
-> ByteOffset
-> IncrementalDecoder s (ByteString, ByteOffset, a)
forall s a.
DecodeAction s a
-> Int
-> ByteString
-> ByteString
-> ByteOffset
-> IncrementalDecoder s (ByteString, ByteOffset, a)
go_slow_overlapped DecodeAction s a
da Int
sz ByteString
bs ByteString
bs' ByteOffset
offset
| Bool
otherwise
-> DecodeAction s a
-> ByteString
-> ByteOffset
-> IncrementalDecoder s (ByteString, ByteOffset, a)
forall s a.
DecodeAction s a
-> ByteString
-> ByteOffset
-> IncrementalDecoder s (ByteString, ByteOffset, a)
go_slow_fixup DecodeAction s a
da (ByteString
bs ByteString -> ByteString -> ByteString
forall a. Semigroup a => a -> a -> a
<> ByteString
bs') ByteOffset
offset
go_slow_overlapped :: DecodeAction s a -> Int -> ByteString -> ByteString
-> ByteOffset
-> IncrementalDecoder s (ByteString, ByteOffset, a)
go_slow_overlapped :: DecodeAction s a
-> Int
-> ByteString
-> ByteString
-> ByteOffset
-> IncrementalDecoder s (ByteString, ByteOffset, a)
go_slow_overlapped da :: DecodeAction s a
da sz :: Int
sz bs_cur :: ByteString
bs_cur bs_next :: ByteString
bs_next !ByteOffset
offset =
Bool
-> IncrementalDecoder s (ByteString, ByteOffset, a)
-> IncrementalDecoder s (ByteString, ByteOffset, a)
forall a. (?callStack::CallStack) => Bool -> a -> a
assert (ByteString -> Int
BS.length ByteString
bs_cur Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
< Int
sz) (IncrementalDecoder s (ByteString, ByteOffset, a)
-> IncrementalDecoder s (ByteString, ByteOffset, a))
-> IncrementalDecoder s (ByteString, ByteOffset, a)
-> IncrementalDecoder s (ByteString, ByteOffset, a)
forall a b. (a -> b) -> a -> b
$
Bool
-> IncrementalDecoder s (ByteString, ByteOffset, a)
-> IncrementalDecoder s (ByteString, ByteOffset, a)
forall a. (?callStack::CallStack) => Bool -> a -> a
assert (ByteString -> Int
BS.length ByteString
bs_cur Int -> Int -> Int
forall a. Num a => a -> a -> a
+ ByteString -> Int
BS.length ByteString
bs_next Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
>= Int
sz) (IncrementalDecoder s (ByteString, ByteOffset, a)
-> IncrementalDecoder s (ByteString, ByteOffset, a))
-> IncrementalDecoder s (ByteString, ByteOffset, a)
-> IncrementalDecoder s (ByteString, ByteOffset, a)
forall a b. (a -> b) -> a -> b
$
let bs_tok :: ByteString
bs_tok = ByteString
bs_cur ByteString -> ByteString -> ByteString
forall a. Semigroup a => a -> a -> a
<> Int -> ByteString -> ByteString
BS.unsafeTake (Int
sz Int -> Int -> Int
forall a. Num a => a -> a -> a
- ByteString -> Int
BS.length ByteString
bs_cur) ByteString
bs_next
bs' :: ByteString
bs' = Int -> ByteString -> ByteString
BS.unsafeDrop (Int
sz Int -> Int -> Int
forall a. Num a => a -> a -> a
- ByteString -> Int
BS.length ByteString
bs_cur) ByteString
bs_next
offset' :: ByteOffset
offset' = ByteOffset
offset ByteOffset -> ByteOffset -> ByteOffset
forall a. Num a => a -> a -> a
+ Int -> ByteOffset
intToInt64 Int
sz in
Bool
-> IncrementalDecoder s (ByteString, ByteOffset, a)
-> IncrementalDecoder s (ByteString, ByteOffset, a)
forall a. (?callStack::CallStack) => Bool -> a -> a
assert (ByteString -> Int
BS.length ByteString
bs_tok Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
sz) (IncrementalDecoder s (ByteString, ByteOffset, a)
-> IncrementalDecoder s (ByteString, ByteOffset, a))
-> IncrementalDecoder s (ByteString, ByteOffset, a)
-> IncrementalDecoder s (ByteString, ByteOffset, a)
forall a b. (a -> b) -> a -> b
$
Bool
-> IncrementalDecoder s (ByteString, ByteOffset, a)
-> IncrementalDecoder s (ByteString, ByteOffset, a)
forall a. (?callStack::CallStack) => Bool -> a -> a
assert (ByteString -> Int
BS.length ByteString
bs_cur Int -> Int -> Int
forall a. Num a => a -> a -> a
+ ByteString -> Int
BS.length ByteString
bs_next Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
sz Int -> Int -> Int
forall a. Num a => a -> a -> a
+ ByteString -> Int
BS.length ByteString
bs') (IncrementalDecoder s (ByteString, ByteOffset, a)
-> IncrementalDecoder s (ByteString, ByteOffset, a))
-> IncrementalDecoder s (ByteString, ByteOffset, a)
-> IncrementalDecoder s (ByteString, ByteOffset, a)
forall a b. (a -> b) -> a -> b
$ do
SlowPath s a
slowpath <- ST s (SlowPath s a) -> IncrementalDecoder s (SlowPath s a)
forall s a. ST s a -> IncrementalDecoder s a
lift (ST s (SlowPath s a) -> IncrementalDecoder s (SlowPath s a))
-> ST s (SlowPath s a) -> IncrementalDecoder s (SlowPath s a)
forall a b. (a -> b) -> a -> b
$ ByteString -> DecodeAction s a -> ST s (SlowPath s a)
forall s a. ByteString -> DecodeAction s a -> ST s (SlowPath s a)
go_fast_end ByteString
bs_tok DecodeAction s a
da
case SlowPath s a
slowpath of
SlowDecodeAction bs_empty :: ByteString
bs_empty da' :: DecodeAction s a
da' ->
Bool
-> IncrementalDecoder s (ByteString, ByteOffset, a)
-> IncrementalDecoder s (ByteString, ByteOffset, a)
forall a. (?callStack::CallStack) => Bool -> a -> a
assert (ByteString -> Bool
BS.null ByteString
bs_empty) (IncrementalDecoder s (ByteString, ByteOffset, a)
-> IncrementalDecoder s (ByteString, ByteOffset, a))
-> IncrementalDecoder s (ByteString, ByteOffset, a)
-> IncrementalDecoder s (ByteString, ByteOffset, a)
forall a b. (a -> b) -> a -> b
$
DecodeAction s a
-> ByteString
-> ByteOffset
-> IncrementalDecoder s (ByteString, ByteOffset, a)
forall s a.
DecodeAction s a
-> ByteString
-> ByteOffset
-> IncrementalDecoder s (ByteString, ByteOffset, a)
go_slow DecodeAction s a
da' ByteString
bs' ByteOffset
offset'
FastDone bs_empty :: ByteString
bs_empty x :: a
x ->
Bool
-> IncrementalDecoder s (ByteString, ByteOffset, a)
-> IncrementalDecoder s (ByteString, ByteOffset, a)
forall a. (?callStack::CallStack) => Bool -> a -> a
assert (ByteString -> Bool
BS.null ByteString
bs_empty) (IncrementalDecoder s (ByteString, ByteOffset, a)
-> IncrementalDecoder s (ByteString, ByteOffset, a))
-> IncrementalDecoder s (ByteString, ByteOffset, a)
-> IncrementalDecoder s (ByteString, ByteOffset, a)
forall a b. (a -> b) -> a -> b
$
(ByteString, ByteOffset, a)
-> IncrementalDecoder s (ByteString, ByteOffset, a)
forall (m :: * -> *) a. Monad m => a -> m a
return (ByteString
bs', ByteOffset
offset', a
x)
SlowConsumeTokenBytes bs_empty :: ByteString
bs_empty k :: ByteString -> ST s (DecodeAction s a)
k len :: Int
len ->
Bool
-> IncrementalDecoder s (ByteString, ByteOffset, a)
-> IncrementalDecoder s (ByteString, ByteOffset, a)
forall a. (?callStack::CallStack) => Bool -> a -> a
assert (ByteString -> Bool
BS.null ByteString
bs_empty) (IncrementalDecoder s (ByteString, ByteOffset, a)
-> IncrementalDecoder s (ByteString, ByteOffset, a))
-> IncrementalDecoder s (ByteString, ByteOffset, a)
-> IncrementalDecoder s (ByteString, ByteOffset, a)
forall a b. (a -> b) -> a -> b
$ do
(bstr :: ByteString
bstr, bs'' :: ByteString
bs'') <- ByteString
-> ByteOffset
-> Int
-> IncrementalDecoder s (ByteString, ByteString)
forall s.
ByteString
-> ByteOffset
-> Int
-> IncrementalDecoder s (ByteString, ByteString)
getTokenShortOrVarLen ByteString
bs' ByteOffset
offset' Int
len
ST s (DecodeAction s a) -> IncrementalDecoder s (DecodeAction s a)
forall s a. ST s a -> IncrementalDecoder s a
lift (ByteString -> ST s (DecodeAction s a)
k ByteString
bstr) IncrementalDecoder s (DecodeAction s a)
-> (DecodeAction s a
-> IncrementalDecoder s (ByteString, ByteOffset, a))
-> IncrementalDecoder s (ByteString, ByteOffset, a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \daz :: DecodeAction s a
daz -> DecodeAction s a
-> ByteString
-> ByteOffset
-> IncrementalDecoder s (ByteString, ByteOffset, a)
forall s a.
DecodeAction s a
-> ByteString
-> ByteOffset
-> IncrementalDecoder s (ByteString, ByteOffset, a)
go_slow DecodeAction s a
daz ByteString
bs'' (ByteOffset
offset' ByteOffset -> ByteOffset -> ByteOffset
forall a. Num a => a -> a -> a
+ Int -> ByteOffset
intToInt64 Int
len)
SlowConsumeTokenByteArray bs_empty :: ByteString
bs_empty k :: ByteArray -> ST s (DecodeAction s a)
k len :: Int
len ->
Bool
-> IncrementalDecoder s (ByteString, ByteOffset, a)
-> IncrementalDecoder s (ByteString, ByteOffset, a)
forall a. (?callStack::CallStack) => Bool -> a -> a
assert (ByteString -> Bool
BS.null ByteString
bs_empty) (IncrementalDecoder s (ByteString, ByteOffset, a)
-> IncrementalDecoder s (ByteString, ByteOffset, a))
-> IncrementalDecoder s (ByteString, ByteOffset, a)
-> IncrementalDecoder s (ByteString, ByteOffset, a)
forall a b. (a -> b) -> a -> b
$ do
(bstr :: ByteString
bstr, bs'' :: ByteString
bs'') <- ByteString
-> ByteOffset
-> Int
-> IncrementalDecoder s (ByteString, ByteString)
forall s.
ByteString
-> ByteOffset
-> Int
-> IncrementalDecoder s (ByteString, ByteString)
getTokenShortOrVarLen ByteString
bs' ByteOffset
offset' Int
len
let !ba :: ByteArray
ba = ByteString -> ByteArray
BA.fromByteString ByteString
bstr
ST s (DecodeAction s a) -> IncrementalDecoder s (DecodeAction s a)
forall s a. ST s a -> IncrementalDecoder s a
lift (ByteArray -> ST s (DecodeAction s a)
k ByteArray
ba) IncrementalDecoder s (DecodeAction s a)
-> (DecodeAction s a
-> IncrementalDecoder s (ByteString, ByteOffset, a))
-> IncrementalDecoder s (ByteString, ByteOffset, a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \daz :: DecodeAction s a
daz -> DecodeAction s a
-> ByteString
-> ByteOffset
-> IncrementalDecoder s (ByteString, ByteOffset, a)
forall s a.
DecodeAction s a
-> ByteString
-> ByteOffset
-> IncrementalDecoder s (ByteString, ByteOffset, a)
go_slow DecodeAction s a
daz ByteString
bs'' (ByteOffset
offset' ByteOffset -> ByteOffset -> ByteOffset
forall a. Num a => a -> a -> a
+ Int -> ByteOffset
intToInt64 Int
len)
SlowConsumeTokenString bs_empty :: ByteString
bs_empty k :: Text -> ST s (DecodeAction s a)
k len :: Int
len ->
Bool
-> IncrementalDecoder s (ByteString, ByteOffset, a)
-> IncrementalDecoder s (ByteString, ByteOffset, a)
forall a. (?callStack::CallStack) => Bool -> a -> a
assert (ByteString -> Bool
BS.null ByteString
bs_empty) (IncrementalDecoder s (ByteString, ByteOffset, a)
-> IncrementalDecoder s (ByteString, ByteOffset, a))
-> IncrementalDecoder s (ByteString, ByteOffset, a)
-> IncrementalDecoder s (ByteString, ByteOffset, a)
forall a b. (a -> b) -> a -> b
$ do
(bstr :: ByteString
bstr, bs'' :: ByteString
bs'') <- ByteString
-> ByteOffset
-> Int
-> IncrementalDecoder s (ByteString, ByteString)
forall s.
ByteString
-> ByteOffset
-> Int
-> IncrementalDecoder s (ByteString, ByteString)
getTokenShortOrVarLen ByteString
bs' ByteOffset
offset' Int
len
case ByteString -> Either UnicodeException Text
T.decodeUtf8' ByteString
bstr of
Right str :: Text
str -> ST s (DecodeAction s a) -> IncrementalDecoder s (DecodeAction s a)
forall s a. ST s a -> IncrementalDecoder s a
lift (Text -> ST s (DecodeAction s a)
k Text
str) IncrementalDecoder s (DecodeAction s a)
-> (DecodeAction s a
-> IncrementalDecoder s (ByteString, ByteOffset, a))
-> IncrementalDecoder s (ByteString, ByteOffset, a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \daz :: DecodeAction s a
daz ->
DecodeAction s a
-> ByteString
-> ByteOffset
-> IncrementalDecoder s (ByteString, ByteOffset, a)
forall s a.
DecodeAction s a
-> ByteString
-> ByteOffset
-> IncrementalDecoder s (ByteString, ByteOffset, a)
go_slow DecodeAction s a
daz ByteString
bs'' (ByteOffset
offset' ByteOffset -> ByteOffset -> ByteOffset
forall a. Num a => a -> a -> a
+ Int -> ByteOffset
intToInt64 Int
len)
Left _e :: UnicodeException
_e -> ByteString
-> ByteOffset
-> String
-> IncrementalDecoder s (ByteString, ByteOffset, a)
forall s a.
ByteString -> ByteOffset -> String -> IncrementalDecoder s a
decodeFail ByteString
bs' ByteOffset
offset' "invalid UTF8"
SlowConsumeTokenUtf8ByteArray bs_empty :: ByteString
bs_empty k :: ByteArray -> ST s (DecodeAction s a)
k len :: Int
len ->
Bool
-> IncrementalDecoder s (ByteString, ByteOffset, a)
-> IncrementalDecoder s (ByteString, ByteOffset, a)
forall a. (?callStack::CallStack) => Bool -> a -> a
assert (ByteString -> Bool
BS.null ByteString
bs_empty) (IncrementalDecoder s (ByteString, ByteOffset, a)
-> IncrementalDecoder s (ByteString, ByteOffset, a))
-> IncrementalDecoder s (ByteString, ByteOffset, a)
-> IncrementalDecoder s (ByteString, ByteOffset, a)
forall a b. (a -> b) -> a -> b
$ do
(bstr :: ByteString
bstr, bs'' :: ByteString
bs'') <- ByteString
-> ByteOffset
-> Int
-> IncrementalDecoder s (ByteString, ByteString)
forall s.
ByteString
-> ByteOffset
-> Int
-> IncrementalDecoder s (ByteString, ByteString)
getTokenShortOrVarLen ByteString
bs' ByteOffset
offset' Int
len
let !ba :: ByteArray
ba = ByteString -> ByteArray
BA.fromByteString ByteString
bstr
ST s (DecodeAction s a) -> IncrementalDecoder s (DecodeAction s a)
forall s a. ST s a -> IncrementalDecoder s a
lift (ByteArray -> ST s (DecodeAction s a)
k ByteArray
ba) IncrementalDecoder s (DecodeAction s a)
-> (DecodeAction s a
-> IncrementalDecoder s (ByteString, ByteOffset, a))
-> IncrementalDecoder s (ByteString, ByteOffset, a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \daz :: DecodeAction s a
daz -> DecodeAction s a
-> ByteString
-> ByteOffset
-> IncrementalDecoder s (ByteString, ByteOffset, a)
forall s a.
DecodeAction s a
-> ByteString
-> ByteOffset
-> IncrementalDecoder s (ByteString, ByteOffset, a)
go_slow DecodeAction s a
daz ByteString
bs'' (ByteOffset
offset' ByteOffset -> ByteOffset -> ByteOffset
forall a. Num a => a -> a -> a
+ Int -> ByteOffset
intToInt64 Int
len)
SlowPeekByteOffset bs_empty :: ByteString
bs_empty k :: Int64# -> ST s (DecodeAction s a)
k ->
Bool
-> IncrementalDecoder s (ByteString, ByteOffset, a)
-> IncrementalDecoder s (ByteString, ByteOffset, a)
forall a. (?callStack::CallStack) => Bool -> a -> a
assert (ByteString -> Bool
BS.null ByteString
bs_empty) (IncrementalDecoder s (ByteString, ByteOffset, a)
-> IncrementalDecoder s (ByteString, ByteOffset, a))
-> IncrementalDecoder s (ByteString, ByteOffset, a)
-> IncrementalDecoder s (ByteString, ByteOffset, a)
forall a b. (a -> b) -> a -> b
$ do
ST s (DecodeAction s a) -> IncrementalDecoder s (DecodeAction s a)
forall s a. ST s a -> IncrementalDecoder s a
lift (Int64# -> ST s (DecodeAction s a)
k Int64#
off#) IncrementalDecoder s (DecodeAction s a)
-> (DecodeAction s a
-> IncrementalDecoder s (ByteString, ByteOffset, a))
-> IncrementalDecoder s (ByteString, ByteOffset, a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \daz :: DecodeAction s a
daz -> DecodeAction s a
-> ByteString
-> ByteOffset
-> IncrementalDecoder s (ByteString, ByteOffset, a)
forall s a.
DecodeAction s a
-> ByteString
-> ByteOffset
-> IncrementalDecoder s (ByteString, ByteOffset, a)
go_slow DecodeAction s a
daz ByteString
bs' ByteOffset
offset'
where
!(I64# off# :: Int64#
off#) = ByteOffset
offset'
SlowFail bs_unconsumed :: ByteString
bs_unconsumed msg :: String
msg ->
ByteString
-> ByteOffset
-> String
-> IncrementalDecoder s (ByteString, ByteOffset, a)
forall s a.
ByteString -> ByteOffset -> String -> IncrementalDecoder s a
decodeFail (ByteString
bs_unconsumed ByteString -> ByteString -> ByteString
forall a. Semigroup a => a -> a -> a
<> ByteString
bs') ByteOffset
offset'' String
msg
where
!offset'' :: ByteOffset
offset'' = ByteOffset
offset ByteOffset -> ByteOffset -> ByteOffset
forall a. Num a => a -> a -> a
+ Int -> ByteOffset
intToInt64 (Int
sz Int -> Int -> Int
forall a. Num a => a -> a -> a
- ByteString -> Int
BS.length ByteString
bs_unconsumed)
where
{-# INLINE getTokenShortOrVarLen #-}
getTokenShortOrVarLen :: BS.ByteString
-> ByteOffset
-> Int
-> IncrementalDecoder s (ByteString, ByteString)
getTokenShortOrVarLen :: ByteString
-> ByteOffset
-> Int
-> IncrementalDecoder s (ByteString, ByteString)
getTokenShortOrVarLen bs' :: ByteString
bs' offset' :: ByteOffset
offset' len :: Int
len
| ByteString -> Int
BS.length ByteString
bs' Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
< Int
len = Int
-> ByteString
-> ByteOffset
-> IncrementalDecoder s (ByteString, ByteString)
forall s.
Int
-> ByteString
-> ByteOffset
-> IncrementalDecoder s (ByteString, ByteString)
getTokenVarLen Int
len ByteString
bs' ByteOffset
offset'
| Bool
otherwise = let !bstr :: ByteString
bstr = Int -> ByteString -> ByteString
BS.take Int
len ByteString
bs'
!bs'' :: ByteString
bs'' = Int -> ByteString -> ByteString
BS.drop Int
len ByteString
bs'
in (ByteString, ByteString)
-> IncrementalDecoder s (ByteString, ByteString)
forall (m :: * -> *) a. Monad m => a -> m a
return (ByteString
bstr, ByteString
bs'')
getTokenVarLen :: Int -> ByteString -> ByteOffset
-> IncrementalDecoder s (ByteString, ByteString)
getTokenVarLen :: Int
-> ByteString
-> ByteOffset
-> IncrementalDecoder s (ByteString, ByteString)
getTokenVarLen len :: Int
len bs :: ByteString
bs offset :: ByteOffset
offset =
Bool
-> IncrementalDecoder s (ByteString, ByteString)
-> IncrementalDecoder s (ByteString, ByteString)
forall a. (?callStack::CallStack) => Bool -> a -> a
assert (Int
len Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> ByteString -> Int
BS.length ByteString
bs) (IncrementalDecoder s (ByteString, ByteString)
-> IncrementalDecoder s (ByteString, ByteString))
-> IncrementalDecoder s (ByteString, ByteString)
-> IncrementalDecoder s (ByteString, ByteString)
forall a b. (a -> b) -> a -> b
$ do
Maybe ByteString
mbs <- IncrementalDecoder s (Maybe ByteString)
forall s. IncrementalDecoder s (Maybe ByteString)
needChunk
case Maybe ByteString
mbs of
Nothing -> ByteString
-> ByteOffset
-> String
-> IncrementalDecoder s (ByteString, ByteString)
forall s a.
ByteString -> ByteOffset -> String -> IncrementalDecoder s a
decodeFail ByteString
BS.empty ByteOffset
offset "end of input"
Just bs' :: ByteString
bs'
| let n :: Int
n = Int
len Int -> Int -> Int
forall a. Num a => a -> a -> a
- ByteString -> Int
BS.length ByteString
bs
, ByteString -> Int
BS.length ByteString
bs' Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
>= Int
n ->
let !tok :: ByteString
tok = ByteString
bs ByteString -> ByteString -> ByteString
forall a. Semigroup a => a -> a -> a
<> Int -> ByteString -> ByteString
BS.unsafeTake Int
n ByteString
bs'
in (ByteString, ByteString)
-> IncrementalDecoder s (ByteString, ByteString)
forall (m :: * -> *) a. Monad m => a -> m a
return (ByteString
tok, Int -> ByteString -> ByteString
BS.drop Int
n ByteString
bs')
| Bool
otherwise -> [ByteString]
-> Int
-> ByteOffset
-> IncrementalDecoder s (ByteString, ByteString)
forall s.
[ByteString]
-> Int
-> ByteOffset
-> IncrementalDecoder s (ByteString, ByteString)
getTokenVarLenSlow
[ByteString
bs',ByteString
bs]
(Int
len Int -> Int -> Int
forall a. Num a => a -> a -> a
- (ByteString -> Int
BS.length ByteString
bs Int -> Int -> Int
forall a. Num a => a -> a -> a
+ ByteString -> Int
BS.length ByteString
bs'))
ByteOffset
offset
getTokenVarLenSlow :: [ByteString] -> Int -> ByteOffset
-> IncrementalDecoder s (ByteString, ByteString)
getTokenVarLenSlow :: [ByteString]
-> Int
-> ByteOffset
-> IncrementalDecoder s (ByteString, ByteString)
getTokenVarLenSlow bss :: [ByteString]
bss n :: Int
n offset :: ByteOffset
offset = do
Maybe ByteString
mbs <- IncrementalDecoder s (Maybe ByteString)
forall s. IncrementalDecoder s (Maybe ByteString)
needChunk
case Maybe ByteString
mbs of
Nothing -> ByteString
-> ByteOffset
-> String
-> IncrementalDecoder s (ByteString, ByteString)
forall s a.
ByteString -> ByteOffset -> String -> IncrementalDecoder s a
decodeFail ByteString
BS.empty ByteOffset
offset "end of input"
Just bs :: ByteString
bs
| ByteString -> Int
BS.length ByteString
bs Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
>= Int
n ->
let !tok :: ByteString
tok = [ByteString] -> ByteString
BS.concat ([ByteString] -> [ByteString]
forall a. [a] -> [a]
reverse (Int -> ByteString -> ByteString
BS.unsafeTake Int
n ByteString
bs ByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
: [ByteString]
bss))
in (ByteString, ByteString)
-> IncrementalDecoder s (ByteString, ByteString)
forall (m :: * -> *) a. Monad m => a -> m a
return (ByteString
tok, Int -> ByteString -> ByteString
BS.drop Int
n ByteString
bs)
| Bool
otherwise -> [ByteString]
-> Int
-> ByteOffset
-> IncrementalDecoder s (ByteString, ByteString)
forall s.
[ByteString]
-> Int
-> ByteOffset
-> IncrementalDecoder s (ByteString, ByteString)
getTokenVarLenSlow (ByteString
bsByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
:[ByteString]
bss) (Int
n Int -> Int -> Int
forall a. Num a => a -> a -> a
- ByteString -> Int
BS.length ByteString
bs) ByteOffset
offset
tokenSize :: Word8 -> Int
tokenSize :: Word8 -> Int
tokenSize hdr :: Word8
hdr =
Word8 -> Int
word8ToInt (Word8 -> Int) -> Word8 -> Int
forall a b. (a -> b) -> a -> b
$
UArray Word8 Word8
decodeTableSz UArray Word8 Word8 -> Int -> Word8
forall (a :: * -> * -> *) e i.
(IArray a e, Ix i) =>
a i e -> Int -> e
`A.unsafeAt` (Word8 -> Int
word8ToInt Word8
hdr Int -> Int -> Int
forall a. Bits a => a -> a -> a
.&. 0x1f)
decodeTableSz :: UArray Word8 Word8
decodeTableSz :: UArray Word8 Word8
decodeTableSz =
(Word8, Word8) -> [(Word8, Word8)] -> UArray Word8 Word8
forall (a :: * -> * -> *) e i.
(IArray a e, Ix i) =>
(i, i) -> [(i, e)] -> a i e
array (0, 0x1f) ([(Word8, Word8)] -> UArray Word8 Word8)
-> [(Word8, Word8)] -> UArray Word8 Word8
forall a b. (a -> b) -> a -> b
$
[ (Word8 -> Word8 -> Word8
encodeHeader 0 Word8
n, 1) | Word8
n <- [0..0x1f] ]
[(Word8, Word8)] -> [(Word8, Word8)] -> [(Word8, Word8)]
forall a. [a] -> [a] -> [a]
++ [ (Word8 -> Word8 -> Word8
encodeHeader 0 Word8
n, Word8
s) | (n :: Word8
n, s :: Word8
s) <- [Word8] -> [Word8] -> [(Word8, Word8)]
forall a b. [a] -> [b] -> [(a, b)]
zip [24..27] [2,3,5,9] ]
decodeTokenTypeTable :: Array Word8 TokenType
decodeTokenTypeTable :: Array Word8 TokenType
decodeTokenTypeTable =
(Word8, Word8) -> [(Word8, TokenType)] -> Array Word8 TokenType
forall (a :: * -> * -> *) e i.
(IArray a e, Ix i) =>
(i, i) -> [(i, e)] -> a i e
array (Word8
forall a. Bounded a => a
minBound, Word8
forall a. Bounded a => a
maxBound) ([(Word8, TokenType)] -> Array Word8 TokenType)
-> [(Word8, TokenType)] -> Array Word8 TokenType
forall a b. (a -> b) -> a -> b
$
[ (Word8 -> Word8 -> Word8
encodeHeader 0 Word8
n, TokenType
TypeUInt) | Word8
n <- [0..26] ]
[(Word8, TokenType)]
-> [(Word8, TokenType)] -> [(Word8, TokenType)]
forall a. [a] -> [a] -> [a]
++ [ (Word8 -> Word8 -> Word8
encodeHeader 0 27, TokenType
TypeUInt64)
, (Word8 -> Word8 -> Word8
encodeHeader 0 31, TokenType
TypeInvalid) ]
[(Word8, TokenType)]
-> [(Word8, TokenType)] -> [(Word8, TokenType)]
forall a. [a] -> [a] -> [a]
++ [ (Word8 -> Word8 -> Word8
encodeHeader 1 Word8
n, TokenType
TypeNInt) | Word8
n <- [0..26] ]
[(Word8, TokenType)]
-> [(Word8, TokenType)] -> [(Word8, TokenType)]
forall a. [a] -> [a] -> [a]
++ [ (Word8 -> Word8 -> Word8
encodeHeader 1 27, TokenType
TypeNInt64)
, (Word8 -> Word8 -> Word8
encodeHeader 1 31, TokenType
TypeInvalid) ]
[(Word8, TokenType)]
-> [(Word8, TokenType)] -> [(Word8, TokenType)]
forall a. [a] -> [a] -> [a]
++ [ (Word8 -> Word8 -> Word8
encodeHeader 2 Word8
n, TokenType
TypeBytes) | Word8
n <- [0..27] ]
[(Word8, TokenType)]
-> [(Word8, TokenType)] -> [(Word8, TokenType)]
forall a. [a] -> [a] -> [a]
++ [ (Word8 -> Word8 -> Word8
encodeHeader 2 31, TokenType
TypeBytesIndef) ]
[(Word8, TokenType)]
-> [(Word8, TokenType)] -> [(Word8, TokenType)]
forall a. [a] -> [a] -> [a]
++ [ (Word8 -> Word8 -> Word8
encodeHeader 3 Word8
n, TokenType
TypeString) | Word8
n <- [0..27] ]
[(Word8, TokenType)]
-> [(Word8, TokenType)] -> [(Word8, TokenType)]
forall a. [a] -> [a] -> [a]
++ [ (Word8 -> Word8 -> Word8
encodeHeader 3 31, TokenType
TypeStringIndef) ]
[(Word8, TokenType)]
-> [(Word8, TokenType)] -> [(Word8, TokenType)]
forall a. [a] -> [a] -> [a]
++ [ (Word8 -> Word8 -> Word8
encodeHeader 4 Word8
n, TokenType
TypeListLen) | Word8
n <- [0..26] ]
[(Word8, TokenType)]
-> [(Word8, TokenType)] -> [(Word8, TokenType)]
forall a. [a] -> [a] -> [a]
++ [ (Word8 -> Word8 -> Word8
encodeHeader 4 27, TokenType
TypeListLen64)
, (Word8 -> Word8 -> Word8
encodeHeader 4 31, TokenType
TypeListLenIndef) ]
[(Word8, TokenType)]
-> [(Word8, TokenType)] -> [(Word8, TokenType)]
forall a. [a] -> [a] -> [a]
++ [ (Word8 -> Word8 -> Word8
encodeHeader 5 Word8
n, TokenType
TypeMapLen) | Word8
n <- [0..26] ]
[(Word8, TokenType)]
-> [(Word8, TokenType)] -> [(Word8, TokenType)]
forall a. [a] -> [a] -> [a]
++ [ (Word8 -> Word8 -> Word8
encodeHeader 5 27, TokenType
TypeMapLen64)
, (Word8 -> Word8 -> Word8
encodeHeader 5 31, TokenType
TypeMapLenIndef) ]
[(Word8, TokenType)]
-> [(Word8, TokenType)] -> [(Word8, TokenType)]
forall a. [a] -> [a] -> [a]
++ [ (Word8 -> Word8 -> Word8
encodeHeader 6 Word8
n, TokenType
TypeTag) | Word8
n <- 0Word8 -> [Word8] -> [Word8]
forall a. a -> [a] -> [a]
:1Word8 -> [Word8] -> [Word8]
forall a. a -> [a] -> [a]
:[4..26] ]
[(Word8, TokenType)]
-> [(Word8, TokenType)] -> [(Word8, TokenType)]
forall a. [a] -> [a] -> [a]
++ [ (Word8 -> Word8 -> Word8
encodeHeader 6 2, TokenType
TypeInteger)
, (Word8 -> Word8 -> Word8
encodeHeader 6 3, TokenType
TypeInteger)
, (Word8 -> Word8 -> Word8
encodeHeader 6 27, TokenType
TypeTag64)
, (Word8 -> Word8 -> Word8
encodeHeader 6 31, TokenType
TypeInvalid) ]
[(Word8, TokenType)]
-> [(Word8, TokenType)] -> [(Word8, TokenType)]
forall a. [a] -> [a] -> [a]
++ [ (Word8 -> Word8 -> Word8
encodeHeader 7 Word8
n, TokenType
TypeSimple) | Word8
n <- [0..19] ]
[(Word8, TokenType)]
-> [(Word8, TokenType)] -> [(Word8, TokenType)]
forall a. [a] -> [a] -> [a]
++ [ (Word8 -> Word8 -> Word8
encodeHeader 7 20, TokenType
TypeBool)
, (Word8 -> Word8 -> Word8
encodeHeader 7 21, TokenType
TypeBool)
, (Word8 -> Word8 -> Word8
encodeHeader 7 22, TokenType
TypeNull)
, (Word8 -> Word8 -> Word8
encodeHeader 7 23, TokenType
TypeSimple)
, (Word8 -> Word8 -> Word8
encodeHeader 7 24, TokenType
TypeSimple)
, (Word8 -> Word8 -> Word8
encodeHeader 7 25, TokenType
TypeFloat16)
, (Word8 -> Word8 -> Word8
encodeHeader 7 26, TokenType
TypeFloat32)
, (Word8 -> Word8 -> Word8
encodeHeader 7 27, TokenType
TypeFloat64)
, (Word8 -> Word8 -> Word8
encodeHeader 7 31, TokenType
TypeBreak) ]
[(Word8, TokenType)]
-> [(Word8, TokenType)] -> [(Word8, TokenType)]
forall a. [a] -> [a] -> [a]
++ [ (Word8 -> Word8 -> Word8
encodeHeader Word8
mt Word8
n, TokenType
TypeInvalid) | Word8
mt <- [0..7], Word8
n <- [28..30] ]
encodeHeader :: Word8 -> Word8 -> Word8
mt :: Word8
mt ai :: Word8
ai = Word8
mt Word8 -> Int -> Word8
forall a. Bits a => a -> Int -> a
`shiftL` 5 Word8 -> Word8 -> Word8
forall a. Bits a => a -> a -> a
.|. Word8
ai
data DecodedToken a = DecodedToken !Int !a | DecodeFailure
deriving Int -> DecodedToken a -> ShowS
[DecodedToken a] -> ShowS
DecodedToken a -> String
(Int -> DecodedToken a -> ShowS)
-> (DecodedToken a -> String)
-> ([DecodedToken a] -> ShowS)
-> Show (DecodedToken a)
forall a. Show a => Int -> DecodedToken a -> ShowS
forall a. Show a => [DecodedToken a] -> ShowS
forall a. Show a => DecodedToken a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DecodedToken a] -> ShowS
$cshowList :: forall a. Show a => [DecodedToken a] -> ShowS
show :: DecodedToken a -> String
$cshow :: forall a. Show a => DecodedToken a -> String
showsPrec :: Int -> DecodedToken a -> ShowS
$cshowsPrec :: forall a. Show a => Int -> DecodedToken a -> ShowS
Show
data LongToken a = Fits Bool !a
| TooLong Bool !Int
deriving Int -> LongToken a -> ShowS
[LongToken a] -> ShowS
LongToken a -> String
(Int -> LongToken a -> ShowS)
-> (LongToken a -> String)
-> ([LongToken a] -> ShowS)
-> Show (LongToken a)
forall a. Show a => Int -> LongToken a -> ShowS
forall a. Show a => [LongToken a] -> ShowS
forall a. Show a => LongToken a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [LongToken a] -> ShowS
$cshowList :: forall a. Show a => [LongToken a] -> ShowS
show :: LongToken a -> String
$cshow :: forall a. Show a => LongToken a -> String
showsPrec :: Int -> LongToken a -> ShowS
$cshowsPrec :: forall a. Show a => Int -> LongToken a -> ShowS
Show
{-# INLINE isFloat16Canonical #-}
isFloat16Canonical :: Int -> BS.ByteString -> Float -> Bool
isFloat16Canonical :: Int -> ByteString -> Float -> Bool
isFloat16Canonical sz :: Int
sz bs :: ByteString
bs f :: Float
f
| Int
sz Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
/= 3 = Bool
False
| Float -> Bool
forall a. RealFloat a => a -> Bool
isNaN Float
f = ByteString -> Word16
eatTailWord16 ByteString
bs Word16 -> Word16 -> Bool
forall a. Eq a => a -> a -> Bool
== 0x7e00
| Bool
otherwise = Bool
True
{-# INLINE isFloatCanonical #-}
isFloatCanonical :: Int -> BS.ByteString -> Float -> Bool
isFloatCanonical :: Int -> ByteString -> Float -> Bool
isFloatCanonical sz :: Int
sz bs :: ByteString
bs f :: Float
f
| Float -> Bool
forall a. RealFloat a => a -> Bool
isNaN Float
f = Int
sz Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== 3 Bool -> Bool -> Bool
&& ByteString -> Word16
eatTailWord16 ByteString
bs Word16 -> Word16 -> Bool
forall a. Eq a => a -> a -> Bool
== 0x7e00
| Bool
otherwise = Int
sz Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== 5
{-# INLINE isDoubleCanonical #-}
isDoubleCanonical :: Int -> BS.ByteString -> Double -> Bool
isDoubleCanonical :: Int -> ByteString -> Double -> Bool
isDoubleCanonical sz :: Int
sz bs :: ByteString
bs f :: Double
f
| Double -> Bool
forall a. RealFloat a => a -> Bool
isNaN Double
f = Int
sz Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== 3 Bool -> Bool -> Bool
&& ByteString -> Word16
eatTailWord16 ByteString
bs Word16 -> Word16 -> Bool
forall a. Eq a => a -> a -> Bool
== 0x7e00
| Bool
otherwise = Int
sz Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== 9
{-# INLINE isWordCanonical #-}
isWordCanonical :: Int -> Word# -> Bool
isWordCanonical :: Int -> Word# -> Bool
isWordCanonical sz :: Int
sz w# :: Word#
w#
| Int
sz Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== 2 = Int# -> Bool
isTrue# (Word#
w# Word# -> Word# -> Int#
`gtWord#` 0x17##)
| Int
sz Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== 3 = Int# -> Bool
isTrue# (Word#
w# Word# -> Word# -> Int#
`gtWord#` 0xff##)
| Int
sz Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== 5 = Int# -> Bool
isTrue# (Word#
w# Word# -> Word# -> Int#
`gtWord#` 0xffff##)
| Int
sz Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== 9 = Int# -> Bool
isTrue# (Word#
w# Word# -> Word# -> Int#
`gtWord#` 0xffffffff##)
| Bool
otherwise = Bool
True
{-# INLINE isIntCanonical #-}
isIntCanonical :: Int -> Int# -> Bool
isIntCanonical :: Int -> Int# -> Bool
isIntCanonical sz :: Int
sz i# :: Int#
i#
| Int# -> Bool
isTrue# (Int#
i# Int# -> Int# -> Int#
<# 0#) = Int -> Word# -> Bool
isWordCanonical Int
sz (Word# -> Word#
not# Word#
w#)
| Bool
otherwise = Int -> Word# -> Bool
isWordCanonical Int
sz Word#
w#
where
w# :: Word#
w# = Int# -> Word#
int2Word# Int#
i#
#if defined(ARCH_32bit)
{-# INLINE isWord64Canonical #-}
isWord64Canonical :: Int -> Word64# -> Bool
isWord64Canonical :: Int -> Word64# -> Bool
isWord64Canonical sz :: Int
sz w# :: Word64#
w#
| Int
sz Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== 2 = Int# -> Bool
isTrue# (Word64#
w# Word64# -> Word64# -> Int#
`gtWord64#` Word# -> Word64#
wordToWord64# 0x17##)
| Int
sz Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== 3 = Int# -> Bool
isTrue# (Word64#
w# Word64# -> Word64# -> Int#
`gtWord64#` Word# -> Word64#
wordToWord64# 0xff##)
| Int
sz Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== 5 = Int# -> Bool
isTrue# (Word64#
w# Word64# -> Word64# -> Int#
`gtWord64#` Word# -> Word64#
wordToWord64# 0xffff##)
| Int
sz Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== 9 = Int# -> Bool
isTrue# (Word64#
w# Word64# -> Word64# -> Int#
`gtWord64#` Word# -> Word64#
wordToWord64# 0xffffffff##)
| Bool
otherwise = Bool
True
{-# INLINE isInt64Canonical #-}
isInt64Canonical :: Int -> Int64# -> Bool
isInt64Canonical :: Int -> Int64# -> Bool
isInt64Canonical sz :: Int
sz i# :: Int64#
i#
| Int# -> Bool
isTrue# (Int64#
i# Int64# -> Int64# -> Int#
`ltInt64#` Int# -> Int64#
intToInt64# 0#) = Int -> Word64# -> Bool
isWord64Canonical Int
sz (Word64# -> Word64#
not64# Word64#
w#)
| Bool
otherwise = Int -> Word64# -> Bool
isWord64Canonical Int
sz Word64#
w#
where
w# :: Word64#
w# = Int64# -> Word64#
int64ToWord64# Int64#
i#
#endif
{-# INLINE isSimpleCanonical #-}
isSimpleCanonical :: Int -> Word# -> Bool
isSimpleCanonical :: Int -> Word# -> Bool
isSimpleCanonical 2 w# :: Word#
w# = Int# -> Bool
isTrue# (Word#
w# Word# -> Word# -> Int#
`gtWord#` 0x17##)
isSimpleCanonical _ _ = Bool
True
{-# INLINE tryConsumeWord #-}
tryConsumeWord :: Word8 -> ByteString -> DecodedToken Word
tryConsumeWord :: Word8 -> ByteString -> DecodedToken Word
tryConsumeWord hdr :: Word8
hdr !ByteString
bs = case Word8 -> Word
word8ToWord Word8
hdr of
0x00 -> Int -> Word -> DecodedToken Word
forall a. Int -> a -> DecodedToken a
DecodedToken 1 0
0x01 -> Int -> Word -> DecodedToken Word
forall a. Int -> a -> DecodedToken a
DecodedToken 1 1
0x02 -> Int -> Word -> DecodedToken Word
forall a. Int -> a -> DecodedToken a
DecodedToken 1 2
0x03 -> Int -> Word -> DecodedToken Word
forall a. Int -> a -> DecodedToken a
DecodedToken 1 3
0x04 -> Int -> Word -> DecodedToken Word
forall a. Int -> a -> DecodedToken a
DecodedToken 1 4
0x05 -> Int -> Word -> DecodedToken Word
forall a. Int -> a -> DecodedToken a
DecodedToken 1 5
0x06 -> Int -> Word -> DecodedToken Word
forall a. Int -> a -> DecodedToken a
DecodedToken 1 6
0x07 -> Int -> Word -> DecodedToken Word
forall a. Int -> a -> DecodedToken a
DecodedToken 1 7
0x08 -> Int -> Word -> DecodedToken Word
forall a. Int -> a -> DecodedToken a
DecodedToken 1 8
0x09 -> Int -> Word -> DecodedToken Word
forall a. Int -> a -> DecodedToken a
DecodedToken 1 9
0x0a -> Int -> Word -> DecodedToken Word
forall a. Int -> a -> DecodedToken a
DecodedToken 1 10
0x0b -> Int -> Word -> DecodedToken Word
forall a. Int -> a -> DecodedToken a
DecodedToken 1 11
0x0c -> Int -> Word -> DecodedToken Word
forall a. Int -> a -> DecodedToken a
DecodedToken 1 12
0x0d -> Int -> Word -> DecodedToken Word
forall a. Int -> a -> DecodedToken a
DecodedToken 1 13
0x0e -> Int -> Word -> DecodedToken Word
forall a. Int -> a -> DecodedToken a
DecodedToken 1 14
0x0f -> Int -> Word -> DecodedToken Word
forall a. Int -> a -> DecodedToken a
DecodedToken 1 15
0x10 -> Int -> Word -> DecodedToken Word
forall a. Int -> a -> DecodedToken a
DecodedToken 1 16
0x11 -> Int -> Word -> DecodedToken Word
forall a. Int -> a -> DecodedToken a
DecodedToken 1 17
0x12 -> Int -> Word -> DecodedToken Word
forall a. Int -> a -> DecodedToken a
DecodedToken 1 18
0x13 -> Int -> Word -> DecodedToken Word
forall a. Int -> a -> DecodedToken a
DecodedToken 1 19
0x14 -> Int -> Word -> DecodedToken Word
forall a. Int -> a -> DecodedToken a
DecodedToken 1 20
0x15 -> Int -> Word -> DecodedToken Word
forall a. Int -> a -> DecodedToken a
DecodedToken 1 21
0x16 -> Int -> Word -> DecodedToken Word
forall a. Int -> a -> DecodedToken a
DecodedToken 1 22
0x17 -> Int -> Word -> DecodedToken Word
forall a. Int -> a -> DecodedToken a
DecodedToken 1 23
0x18 -> Int -> Word -> DecodedToken Word
forall a. Int -> a -> DecodedToken a
DecodedToken 2 (Word -> DecodedToken Word) -> Word -> DecodedToken Word
forall a b. (a -> b) -> a -> b
$! Word8 -> Word
word8ToWord (ByteString -> Word8
eatTailWord8 ByteString
bs)
0x19 -> Int -> Word -> DecodedToken Word
forall a. Int -> a -> DecodedToken a
DecodedToken 3 (Word -> DecodedToken Word) -> Word -> DecodedToken Word
forall a b. (a -> b) -> a -> b
$! Word16 -> Word
word16ToWord (ByteString -> Word16
eatTailWord16 ByteString
bs)
0x1a -> Int -> Word -> DecodedToken Word
forall a. Int -> a -> DecodedToken a
DecodedToken 5 (Word -> DecodedToken Word) -> Word -> DecodedToken Word
forall a b. (a -> b) -> a -> b
$! Word32 -> Word
word32ToWord (ByteString -> Word32
eatTailWord32 ByteString
bs)
#if defined(ARCH_64bit)
0x1b -> DecodedToken 9 $! word64ToWord (eatTailWord64 bs)
#else
0x1b -> case Word64 -> Maybe Word
word64ToWord (ByteString -> Word64
eatTailWord64 ByteString
bs) of
Just n :: Word
n -> Int -> Word -> DecodedToken Word
forall a. Int -> a -> DecodedToken a
DecodedToken 9 Word
n
Nothing -> DecodedToken Word
forall a. DecodedToken a
DecodeFailure
#endif
_ -> DecodedToken Word
forall a. DecodedToken a
DecodeFailure
{-# INLINE tryConsumeNegWord #-}
tryConsumeNegWord :: Word8 -> ByteString -> DecodedToken Word
tryConsumeNegWord :: Word8 -> ByteString -> DecodedToken Word
tryConsumeNegWord hdr :: Word8
hdr !ByteString
bs = case Word8 -> Word
word8ToWord Word8
hdr of
0x20 -> Int -> Word -> DecodedToken Word
forall a. Int -> a -> DecodedToken a
DecodedToken 1 0
0x21 -> Int -> Word -> DecodedToken Word
forall a. Int -> a -> DecodedToken a
DecodedToken 1 1
0x22 -> Int -> Word -> DecodedToken Word
forall a. Int -> a -> DecodedToken a
DecodedToken 1 2
0x23 -> Int -> Word -> DecodedToken Word
forall a. Int -> a -> DecodedToken a
DecodedToken 1 3
0x24 -> Int -> Word -> DecodedToken Word
forall a. Int -> a -> DecodedToken a
DecodedToken 1 4
0x25 -> Int -> Word -> DecodedToken Word
forall a. Int -> a -> DecodedToken a
DecodedToken 1 5
0x26 -> Int -> Word -> DecodedToken Word
forall a. Int -> a -> DecodedToken a
DecodedToken 1 6
0x27 -> Int -> Word -> DecodedToken Word
forall a. Int -> a -> DecodedToken a
DecodedToken 1 7
0x28 -> Int -> Word -> DecodedToken Word
forall a. Int -> a -> DecodedToken a
DecodedToken 1 8
0x29 -> Int -> Word -> DecodedToken Word
forall a. Int -> a -> DecodedToken a
DecodedToken 1 9
0x2a -> Int -> Word -> DecodedToken Word
forall a. Int -> a -> DecodedToken a
DecodedToken 1 10
0x2b -> Int -> Word -> DecodedToken Word
forall a. Int -> a -> DecodedToken a
DecodedToken 1 11
0x2c -> Int -> Word -> DecodedToken Word
forall a. Int -> a -> DecodedToken a
DecodedToken 1 12
0x2d -> Int -> Word -> DecodedToken Word
forall a. Int -> a -> DecodedToken a
DecodedToken 1 13
0x2e -> Int -> Word -> DecodedToken Word
forall a. Int -> a -> DecodedToken a
DecodedToken 1 14
0x2f -> Int -> Word -> DecodedToken Word
forall a. Int -> a -> DecodedToken a
DecodedToken 1 15
0x30 -> Int -> Word -> DecodedToken Word
forall a. Int -> a -> DecodedToken a
DecodedToken 1 16
0x31 -> Int -> Word -> DecodedToken Word
forall a. Int -> a -> DecodedToken a
DecodedToken 1 17
0x32 -> Int -> Word -> DecodedToken Word
forall a. Int -> a -> DecodedToken a
DecodedToken 1 18
0x33 -> Int -> Word -> DecodedToken Word
forall a. Int -> a -> DecodedToken a
DecodedToken 1 19
0x34 -> Int -> Word -> DecodedToken Word
forall a. Int -> a -> DecodedToken a
DecodedToken 1 20
0x35 -> Int -> Word -> DecodedToken Word
forall a. Int -> a -> DecodedToken a
DecodedToken 1 21
0x36 -> Int -> Word -> DecodedToken Word
forall a. Int -> a -> DecodedToken a
DecodedToken 1 22
0x37 -> Int -> Word -> DecodedToken Word
forall a. Int -> a -> DecodedToken a
DecodedToken 1 23
0x38 -> Int -> Word -> DecodedToken Word
forall a. Int -> a -> DecodedToken a
DecodedToken 2 (Word -> DecodedToken Word) -> Word -> DecodedToken Word
forall a b. (a -> b) -> a -> b
$! (Word8 -> Word
word8ToWord (ByteString -> Word8
eatTailWord8 ByteString
bs))
0x39 -> Int -> Word -> DecodedToken Word
forall a. Int -> a -> DecodedToken a
DecodedToken 3 (Word -> DecodedToken Word) -> Word -> DecodedToken Word
forall a b. (a -> b) -> a -> b
$! (Word16 -> Word
word16ToWord (ByteString -> Word16
eatTailWord16 ByteString
bs))
0x3a -> Int -> Word -> DecodedToken Word
forall a. Int -> a -> DecodedToken a
DecodedToken 5 (Word -> DecodedToken Word) -> Word -> DecodedToken Word
forall a b. (a -> b) -> a -> b
$! (Word32 -> Word
word32ToWord (ByteString -> Word32
eatTailWord32 ByteString
bs))
#if defined(ARCH_64bit)
0x3b -> DecodedToken 9 $! (word64ToWord (eatTailWord64 bs))
#else
0x3b -> case Word64 -> Maybe Word
word64ToWord (ByteString -> Word64
eatTailWord64 ByteString
bs) of
Just n :: Word
n -> Int -> Word -> DecodedToken Word
forall a. Int -> a -> DecodedToken a
DecodedToken 9 Word
n
Nothing -> DecodedToken Word
forall a. DecodedToken a
DecodeFailure
#endif
_ -> DecodedToken Word
forall a. DecodedToken a
DecodeFailure
{-# INLINE tryConsumeInt #-}
tryConsumeInt :: Word8 -> ByteString -> DecodedToken Int
tryConsumeInt :: Word8 -> ByteString -> DecodedToken Int
tryConsumeInt hdr :: Word8
hdr !ByteString
bs = case Word8 -> Word
word8ToWord Word8
hdr of
0x00 -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 0
0x01 -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 1
0x02 -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 2
0x03 -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 3
0x04 -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 4
0x05 -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 5
0x06 -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 6
0x07 -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 7
0x08 -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 8
0x09 -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 9
0x0a -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 10
0x0b -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 11
0x0c -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 12
0x0d -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 13
0x0e -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 14
0x0f -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 15
0x10 -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 16
0x11 -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 17
0x12 -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 18
0x13 -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 19
0x14 -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 20
0x15 -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 21
0x16 -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 22
0x17 -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 23
0x18 -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 2 (Int -> DecodedToken Int) -> Int -> DecodedToken Int
forall a b. (a -> b) -> a -> b
$! (Word8 -> Int
word8ToInt (ByteString -> Word8
eatTailWord8 ByteString
bs))
0x19 -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 3 (Int -> DecodedToken Int) -> Int -> DecodedToken Int
forall a b. (a -> b) -> a -> b
$! (Word16 -> Int
word16ToInt (ByteString -> Word16
eatTailWord16 ByteString
bs))
#if defined(ARCH_64bit)
0x1a -> DecodedToken 5 $! (word32ToInt (eatTailWord32 bs))
#else
0x1a -> case Word32 -> Maybe Int
word32ToInt (ByteString -> Word32
eatTailWord32 ByteString
bs) of
Just n :: Int
n -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 5 Int
n
Nothing -> DecodedToken Int
forall a. DecodedToken a
DecodeFailure
#endif
0x1b -> case Word64 -> Maybe Int
word64ToInt (ByteString -> Word64
eatTailWord64 ByteString
bs) of
Just n :: Int
n -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 9 Int
n
Nothing -> DecodedToken Int
forall a. DecodedToken a
DecodeFailure
0x20 -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 (-1)
0x21 -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 (-2)
0x22 -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 (-3)
0x23 -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 (-4)
0x24 -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 (-5)
0x25 -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 (-6)
0x26 -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 (-7)
0x27 -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 (-8)
0x28 -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 (-9)
0x29 -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 (-10)
0x2a -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 (-11)
0x2b -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 (-12)
0x2c -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 (-13)
0x2d -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 (-14)
0x2e -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 (-15)
0x2f -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 (-16)
0x30 -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 (-17)
0x31 -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 (-18)
0x32 -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 (-19)
0x33 -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 (-20)
0x34 -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 (-21)
0x35 -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 (-22)
0x36 -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 (-23)
0x37 -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 (-24)
0x38 -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 2 (Int -> DecodedToken Int) -> Int -> DecodedToken Int
forall a b. (a -> b) -> a -> b
$! (-1 Int -> Int -> Int
forall a. Num a => a -> a -> a
- Word8 -> Int
word8ToInt (ByteString -> Word8
eatTailWord8 ByteString
bs))
0x39 -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 3 (Int -> DecodedToken Int) -> Int -> DecodedToken Int
forall a b. (a -> b) -> a -> b
$! (-1 Int -> Int -> Int
forall a. Num a => a -> a -> a
- Word16 -> Int
word16ToInt (ByteString -> Word16
eatTailWord16 ByteString
bs))
#if defined(ARCH_64bit)
0x3a -> DecodedToken 5 $! (-1 - word32ToInt (eatTailWord32 bs))
#else
0x3a -> case Word32 -> Maybe Int
word32ToInt (ByteString -> Word32
eatTailWord32 ByteString
bs) of
Just n :: Int
n -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 5 (-1 Int -> Int -> Int
forall a. Num a => a -> a -> a
- Int
n)
Nothing -> DecodedToken Int
forall a. DecodedToken a
DecodeFailure
#endif
0x3b -> case Word64 -> Maybe Int
word64ToInt (ByteString -> Word64
eatTailWord64 ByteString
bs) of
Just n :: Int
n -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 9 (-1 Int -> Int -> Int
forall a. Num a => a -> a -> a
- Int
n)
Nothing -> DecodedToken Int
forall a. DecodedToken a
DecodeFailure
_ -> DecodedToken Int
forall a. DecodedToken a
DecodeFailure
{-# INLINE tryConsumeInteger #-}
tryConsumeInteger :: Word8 -> ByteString -> DecodedToken (BigIntToken Integer)
tryConsumeInteger :: Word8 -> ByteString -> DecodedToken (BigIntToken Integer)
tryConsumeInteger hdr :: Word8
hdr !ByteString
bs = case Word8 -> Word
word8ToWord Word8
hdr of
0x00 -> Int -> BigIntToken Integer -> DecodedToken (BigIntToken Integer)
forall a. Int -> a -> DecodedToken a
DecodedToken 1 (Bool -> Integer -> BigIntToken Integer
forall a. Bool -> Integer -> BigIntToken a
BigIntToken Bool
True 0)
0x01 -> Int -> BigIntToken Integer -> DecodedToken (BigIntToken Integer)
forall a. Int -> a -> DecodedToken a
DecodedToken 1 (Bool -> Integer -> BigIntToken Integer
forall a. Bool -> Integer -> BigIntToken a
BigIntToken Bool
True 1)
0x02 -> Int -> BigIntToken Integer -> DecodedToken (BigIntToken Integer)
forall a. Int -> a -> DecodedToken a
DecodedToken 1 (Bool -> Integer -> BigIntToken Integer
forall a. Bool -> Integer -> BigIntToken a
BigIntToken Bool
True 2)
0x03 -> Int -> BigIntToken Integer -> DecodedToken (BigIntToken Integer)
forall a. Int -> a -> DecodedToken a
DecodedToken 1 (Bool -> Integer -> BigIntToken Integer
forall a. Bool -> Integer -> BigIntToken a
BigIntToken Bool
True 3)
0x04 -> Int -> BigIntToken Integer -> DecodedToken (BigIntToken Integer)
forall a. Int -> a -> DecodedToken a
DecodedToken 1 (Bool -> Integer -> BigIntToken Integer
forall a. Bool -> Integer -> BigIntToken a
BigIntToken Bool
True 4)
0x05 -> Int -> BigIntToken Integer -> DecodedToken (BigIntToken Integer)
forall a. Int -> a -> DecodedToken a
DecodedToken 1 (Bool -> Integer -> BigIntToken Integer
forall a. Bool -> Integer -> BigIntToken a
BigIntToken Bool
True 5)
0x06 -> Int -> BigIntToken Integer -> DecodedToken (BigIntToken Integer)
forall a. Int -> a -> DecodedToken a
DecodedToken 1 (Bool -> Integer -> BigIntToken Integer
forall a. Bool -> Integer -> BigIntToken a
BigIntToken Bool
True 6)
0x07 -> Int -> BigIntToken Integer -> DecodedToken (BigIntToken Integer)
forall a. Int -> a -> DecodedToken a
DecodedToken 1 (Bool -> Integer -> BigIntToken Integer
forall a. Bool -> Integer -> BigIntToken a
BigIntToken Bool
True 7)
0x08 -> Int -> BigIntToken Integer -> DecodedToken (BigIntToken Integer)
forall a. Int -> a -> DecodedToken a
DecodedToken 1 (Bool -> Integer -> BigIntToken Integer
forall a. Bool -> Integer -> BigIntToken a
BigIntToken Bool
True 8)
0x09 -> Int -> BigIntToken Integer -> DecodedToken (BigIntToken Integer)
forall a. Int -> a -> DecodedToken a
DecodedToken 1 (Bool -> Integer -> BigIntToken Integer
forall a. Bool -> Integer -> BigIntToken a
BigIntToken Bool
True 9)
0x0a -> Int -> BigIntToken Integer -> DecodedToken (BigIntToken Integer)
forall a. Int -> a -> DecodedToken a
DecodedToken 1 (Bool -> Integer -> BigIntToken Integer
forall a. Bool -> Integer -> BigIntToken a
BigIntToken Bool
True 10)
0x0b -> Int -> BigIntToken Integer -> DecodedToken (BigIntToken Integer)
forall a. Int -> a -> DecodedToken a
DecodedToken 1 (Bool -> Integer -> BigIntToken Integer
forall a. Bool -> Integer -> BigIntToken a
BigIntToken Bool
True 11)
0x0c -> Int -> BigIntToken Integer -> DecodedToken (BigIntToken Integer)
forall a. Int -> a -> DecodedToken a
DecodedToken 1 (Bool -> Integer -> BigIntToken Integer
forall a. Bool -> Integer -> BigIntToken a
BigIntToken Bool
True 12)
0x0d -> Int -> BigIntToken Integer -> DecodedToken (BigIntToken Integer)
forall a. Int -> a -> DecodedToken a
DecodedToken 1 (Bool -> Integer -> BigIntToken Integer
forall a. Bool -> Integer -> BigIntToken a
BigIntToken Bool
True 13)
0x0e -> Int -> BigIntToken Integer -> DecodedToken (BigIntToken Integer)
forall a. Int -> a -> DecodedToken a
DecodedToken 1 (Bool -> Integer -> BigIntToken Integer
forall a. Bool -> Integer -> BigIntToken a
BigIntToken Bool
True 14)
0x0f -> Int -> BigIntToken Integer -> DecodedToken (BigIntToken Integer)
forall a. Int -> a -> DecodedToken a
DecodedToken 1 (Bool -> Integer -> BigIntToken Integer
forall a. Bool -> Integer -> BigIntToken a
BigIntToken Bool
True 15)
0x10 -> Int -> BigIntToken Integer -> DecodedToken (BigIntToken Integer)
forall a. Int -> a -> DecodedToken a
DecodedToken 1 (Bool -> Integer -> BigIntToken Integer
forall a. Bool -> Integer -> BigIntToken a
BigIntToken Bool
True 16)
0x11 -> Int -> BigIntToken Integer -> DecodedToken (BigIntToken Integer)
forall a. Int -> a -> DecodedToken a
DecodedToken 1 (Bool -> Integer -> BigIntToken Integer
forall a. Bool -> Integer -> BigIntToken a
BigIntToken Bool
True 17)
0x12 -> Int -> BigIntToken Integer -> DecodedToken (BigIntToken Integer)
forall a. Int -> a -> DecodedToken a
DecodedToken 1 (Bool -> Integer -> BigIntToken Integer
forall a. Bool -> Integer -> BigIntToken a
BigIntToken Bool
True 18)
0x13 -> Int -> BigIntToken Integer -> DecodedToken (BigIntToken Integer)
forall a. Int -> a -> DecodedToken a
DecodedToken 1 (Bool -> Integer -> BigIntToken Integer
forall a. Bool -> Integer -> BigIntToken a
BigIntToken Bool
True 19)
0x14 -> Int -> BigIntToken Integer -> DecodedToken (BigIntToken Integer)
forall a. Int -> a -> DecodedToken a
DecodedToken 1 (Bool -> Integer -> BigIntToken Integer
forall a. Bool -> Integer -> BigIntToken a
BigIntToken Bool
True 20)
0x15 -> Int -> BigIntToken Integer -> DecodedToken (BigIntToken Integer)
forall a. Int -> a -> DecodedToken a
DecodedToken 1 (Bool -> Integer -> BigIntToken Integer
forall a. Bool -> Integer -> BigIntToken a
BigIntToken Bool
True 21)
0x16 -> Int -> BigIntToken Integer -> DecodedToken (BigIntToken Integer)
forall a. Int -> a -> DecodedToken a
DecodedToken 1 (Bool -> Integer -> BigIntToken Integer
forall a. Bool -> Integer -> BigIntToken a
BigIntToken Bool
True 22)
0x17 -> Int -> BigIntToken Integer -> DecodedToken (BigIntToken Integer)
forall a. Int -> a -> DecodedToken a
DecodedToken 1 (Bool -> Integer -> BigIntToken Integer
forall a. Bool -> Integer -> BigIntToken a
BigIntToken Bool
True 23)
0x18 -> let !w :: Word8
w@(W8# w# :: Word#
w#) = ByteString -> Word8
eatTailWord8 ByteString
bs
sz :: Int
sz = 2
in Int -> BigIntToken Integer -> DecodedToken (BigIntToken Integer)
forall a. Int -> a -> DecodedToken a
DecodedToken Int
sz (Bool -> Integer -> BigIntToken Integer
forall a. Bool -> Integer -> BigIntToken a
BigIntToken (Int -> Word# -> Bool
isWordCanonical Int
sz Word#
w#) (Integer -> BigIntToken Integer) -> Integer -> BigIntToken Integer
forall a b. (a -> b) -> a -> b
$! Word8 -> Integer
forall a. Integral a => a -> Integer
toInteger Word8
w)
0x19 -> let !w :: Word16
w@(W16# w# :: Word#
w#) = ByteString -> Word16
eatTailWord16 ByteString
bs
sz :: Int
sz = 3
in Int -> BigIntToken Integer -> DecodedToken (BigIntToken Integer)
forall a. Int -> a -> DecodedToken a
DecodedToken Int
sz (Bool -> Integer -> BigIntToken Integer
forall a. Bool -> Integer -> BigIntToken a
BigIntToken (Int -> Word# -> Bool
isWordCanonical Int
sz Word#
w#) (Integer -> BigIntToken Integer) -> Integer -> BigIntToken Integer
forall a b. (a -> b) -> a -> b
$! Word16 -> Integer
forall a. Integral a => a -> Integer
toInteger Word16
w)
0x1a -> let !w :: Word32
w@(W32# w# :: Word#
w#) = ByteString -> Word32
eatTailWord32 ByteString
bs
sz :: Int
sz = 5
in Int -> BigIntToken Integer -> DecodedToken (BigIntToken Integer)
forall a. Int -> a -> DecodedToken a
DecodedToken Int
sz (Bool -> Integer -> BigIntToken Integer
forall a. Bool -> Integer -> BigIntToken a
BigIntToken (Int -> Word# -> Bool
isWordCanonical Int
sz Word#
w#) (Integer -> BigIntToken Integer) -> Integer -> BigIntToken Integer
forall a b. (a -> b) -> a -> b
$! Word32 -> Integer
forall a. Integral a => a -> Integer
toInteger Word32
w)
0x1b -> let !w :: Word64
w@(W64# w# :: Word64#
w#) = ByteString -> Word64
eatTailWord64 ByteString
bs
sz :: Int
sz = 9
#if defined(ARCH_32bit)
in Int -> BigIntToken Integer -> DecodedToken (BigIntToken Integer)
forall a. Int -> a -> DecodedToken a
DecodedToken Int
sz (Bool -> Integer -> BigIntToken Integer
forall a. Bool -> Integer -> BigIntToken a
BigIntToken (Int -> Word64# -> Bool
isWord64Canonical Int
sz Word64#
w#) (Integer -> BigIntToken Integer) -> Integer -> BigIntToken Integer
forall a b. (a -> b) -> a -> b
$! Word64 -> Integer
forall a. Integral a => a -> Integer
toInteger Word64
w)
#else
in DecodedToken sz (BigIntToken (isWordCanonical sz w#) $! toInteger w)
#endif
0x20 -> Int -> BigIntToken Integer -> DecodedToken (BigIntToken Integer)
forall a. Int -> a -> DecodedToken a
DecodedToken 1 (Bool -> Integer -> BigIntToken Integer
forall a. Bool -> Integer -> BigIntToken a
BigIntToken Bool
True (-1))
0x21 -> Int -> BigIntToken Integer -> DecodedToken (BigIntToken Integer)
forall a. Int -> a -> DecodedToken a
DecodedToken 1 (Bool -> Integer -> BigIntToken Integer
forall a. Bool -> Integer -> BigIntToken a
BigIntToken Bool
True (-2))
0x22 -> Int -> BigIntToken Integer -> DecodedToken (BigIntToken Integer)
forall a. Int -> a -> DecodedToken a
DecodedToken 1 (Bool -> Integer -> BigIntToken Integer
forall a. Bool -> Integer -> BigIntToken a
BigIntToken Bool
True (-3))
0x23 -> Int -> BigIntToken Integer -> DecodedToken (BigIntToken Integer)
forall a. Int -> a -> DecodedToken a
DecodedToken 1 (Bool -> Integer -> BigIntToken Integer
forall a. Bool -> Integer -> BigIntToken a
BigIntToken Bool
True (-4))
0x24 -> Int -> BigIntToken Integer -> DecodedToken (BigIntToken Integer)
forall a. Int -> a -> DecodedToken a
DecodedToken 1 (Bool -> Integer -> BigIntToken Integer
forall a. Bool -> Integer -> BigIntToken a
BigIntToken Bool
True (-5))
0x25 -> Int -> BigIntToken Integer -> DecodedToken (BigIntToken Integer)
forall a. Int -> a -> DecodedToken a
DecodedToken 1 (Bool -> Integer -> BigIntToken Integer
forall a. Bool -> Integer -> BigIntToken a
BigIntToken Bool
True (-6))
0x26 -> Int -> BigIntToken Integer -> DecodedToken (BigIntToken Integer)
forall a. Int -> a -> DecodedToken a
DecodedToken 1 (Bool -> Integer -> BigIntToken Integer
forall a. Bool -> Integer -> BigIntToken a
BigIntToken Bool
True (-7))
0x27 -> Int -> BigIntToken Integer -> DecodedToken (BigIntToken Integer)
forall a. Int -> a -> DecodedToken a
DecodedToken 1 (Bool -> Integer -> BigIntToken Integer
forall a. Bool -> Integer -> BigIntToken a
BigIntToken Bool
True (-8))
0x28 -> Int -> BigIntToken Integer -> DecodedToken (BigIntToken Integer)
forall a. Int -> a -> DecodedToken a
DecodedToken 1 (Bool -> Integer -> BigIntToken Integer
forall a. Bool -> Integer -> BigIntToken a
BigIntToken Bool
True (-9))
0x29 -> Int -> BigIntToken Integer -> DecodedToken (BigIntToken Integer)
forall a. Int -> a -> DecodedToken a
DecodedToken 1 (Bool -> Integer -> BigIntToken Integer
forall a. Bool -> Integer -> BigIntToken a
BigIntToken Bool
True (-10))
0x2a -> Int -> BigIntToken Integer -> DecodedToken (BigIntToken Integer)
forall a. Int -> a -> DecodedToken a
DecodedToken 1 (Bool -> Integer -> BigIntToken Integer
forall a. Bool -> Integer -> BigIntToken a
BigIntToken Bool
True (-11))
0x2b -> Int -> BigIntToken Integer -> DecodedToken (BigIntToken Integer)
forall a. Int -> a -> DecodedToken a
DecodedToken 1 (Bool -> Integer -> BigIntToken Integer
forall a. Bool -> Integer -> BigIntToken a
BigIntToken Bool
True (-12))
0x2c -> Int -> BigIntToken Integer -> DecodedToken (BigIntToken Integer)
forall a. Int -> a -> DecodedToken a
DecodedToken 1 (Bool -> Integer -> BigIntToken Integer
forall a. Bool -> Integer -> BigIntToken a
BigIntToken Bool
True (-13))
0x2d -> Int -> BigIntToken Integer -> DecodedToken (BigIntToken Integer)
forall a. Int -> a -> DecodedToken a
DecodedToken 1 (Bool -> Integer -> BigIntToken Integer
forall a. Bool -> Integer -> BigIntToken a
BigIntToken Bool
True (-14))
0x2e -> Int -> BigIntToken Integer -> DecodedToken (BigIntToken Integer)
forall a. Int -> a -> DecodedToken a
DecodedToken 1 (Bool -> Integer -> BigIntToken Integer
forall a. Bool -> Integer -> BigIntToken a
BigIntToken Bool
True (-15))
0x2f -> Int -> BigIntToken Integer -> DecodedToken (BigIntToken Integer)
forall a. Int -> a -> DecodedToken a
DecodedToken 1 (Bool -> Integer -> BigIntToken Integer
forall a. Bool -> Integer -> BigIntToken a
BigIntToken Bool
True (-16))
0x30 -> Int -> BigIntToken Integer -> DecodedToken (BigIntToken Integer)
forall a. Int -> a -> DecodedToken a
DecodedToken 1 (Bool -> Integer -> BigIntToken Integer
forall a. Bool -> Integer -> BigIntToken a
BigIntToken Bool
True (-17))
0x31 -> Int -> BigIntToken Integer -> DecodedToken (BigIntToken Integer)
forall a. Int -> a -> DecodedToken a
DecodedToken 1 (Bool -> Integer -> BigIntToken Integer
forall a. Bool -> Integer -> BigIntToken a
BigIntToken Bool
True (-18))
0x32 -> Int -> BigIntToken Integer -> DecodedToken (BigIntToken Integer)
forall a. Int -> a -> DecodedToken a
DecodedToken 1 (Bool -> Integer -> BigIntToken Integer
forall a. Bool -> Integer -> BigIntToken a
BigIntToken Bool
True (-19))
0x33 -> Int -> BigIntToken Integer -> DecodedToken (BigIntToken Integer)
forall a. Int -> a -> DecodedToken a
DecodedToken 1 (Bool -> Integer -> BigIntToken Integer
forall a. Bool -> Integer -> BigIntToken a
BigIntToken Bool
True (-20))
0x34 -> Int -> BigIntToken Integer -> DecodedToken (BigIntToken Integer)
forall a. Int -> a -> DecodedToken a
DecodedToken 1 (Bool -> Integer -> BigIntToken Integer
forall a. Bool -> Integer -> BigIntToken a
BigIntToken Bool
True (-21))
0x35 -> Int -> BigIntToken Integer -> DecodedToken (BigIntToken Integer)
forall a. Int -> a -> DecodedToken a
DecodedToken 1 (Bool -> Integer -> BigIntToken Integer
forall a. Bool -> Integer -> BigIntToken a
BigIntToken Bool
True (-22))
0x36 -> Int -> BigIntToken Integer -> DecodedToken (BigIntToken Integer)
forall a. Int -> a -> DecodedToken a
DecodedToken 1 (Bool -> Integer -> BigIntToken Integer
forall a. Bool -> Integer -> BigIntToken a
BigIntToken Bool
True (-23))
0x37 -> Int -> BigIntToken Integer -> DecodedToken (BigIntToken Integer)
forall a. Int -> a -> DecodedToken a
DecodedToken 1 (Bool -> Integer -> BigIntToken Integer
forall a. Bool -> Integer -> BigIntToken a
BigIntToken Bool
True (-24))
0x38 -> let !w :: Word8
w@(W8# w# :: Word#
w#) = ByteString -> Word8
eatTailWord8 ByteString
bs
sz :: Int
sz = 2
in Int -> BigIntToken Integer -> DecodedToken (BigIntToken Integer)
forall a. Int -> a -> DecodedToken a
DecodedToken Int
sz (Bool -> Integer -> BigIntToken Integer
forall a. Bool -> Integer -> BigIntToken a
BigIntToken (Int -> Word# -> Bool
isWordCanonical Int
sz Word#
w#) (Integer -> BigIntToken Integer) -> Integer -> BigIntToken Integer
forall a b. (a -> b) -> a -> b
$! (-1 Integer -> Integer -> Integer
forall a. Num a => a -> a -> a
- Word8 -> Integer
forall a. Integral a => a -> Integer
toInteger Word8
w))
0x39 -> let !w :: Word16
w@(W16# w# :: Word#
w#) = ByteString -> Word16
eatTailWord16 ByteString
bs
sz :: Int
sz = 3
in Int -> BigIntToken Integer -> DecodedToken (BigIntToken Integer)
forall a. Int -> a -> DecodedToken a
DecodedToken Int
sz (Bool -> Integer -> BigIntToken Integer
forall a. Bool -> Integer -> BigIntToken a
BigIntToken (Int -> Word# -> Bool
isWordCanonical Int
sz Word#
w#) (Integer -> BigIntToken Integer) -> Integer -> BigIntToken Integer
forall a b. (a -> b) -> a -> b
$! (-1 Integer -> Integer -> Integer
forall a. Num a => a -> a -> a
- Word16 -> Integer
forall a. Integral a => a -> Integer
toInteger Word16
w))
0x3a -> let !w :: Word32
w@(W32# w# :: Word#
w#) = ByteString -> Word32
eatTailWord32 ByteString
bs
sz :: Int
sz = 5
in Int -> BigIntToken Integer -> DecodedToken (BigIntToken Integer)
forall a. Int -> a -> DecodedToken a
DecodedToken Int
sz (Bool -> Integer -> BigIntToken Integer
forall a. Bool -> Integer -> BigIntToken a
BigIntToken (Int -> Word# -> Bool
isWordCanonical Int
sz Word#
w#) (Integer -> BigIntToken Integer) -> Integer -> BigIntToken Integer
forall a b. (a -> b) -> a -> b
$! (-1 Integer -> Integer -> Integer
forall a. Num a => a -> a -> a
- Word32 -> Integer
forall a. Integral a => a -> Integer
toInteger Word32
w))
0x3b -> let !w :: Word64
w@(W64# w# :: Word64#
w#) = ByteString -> Word64
eatTailWord64 ByteString
bs
sz :: Int
sz = 9
#if defined(ARCH_32bit)
in Int -> BigIntToken Integer -> DecodedToken (BigIntToken Integer)
forall a. Int -> a -> DecodedToken a
DecodedToken Int
sz (Bool -> Integer -> BigIntToken Integer
forall a. Bool -> Integer -> BigIntToken a
BigIntToken (Int -> Word64# -> Bool
isWord64Canonical Int
sz Word64#
w#) (Integer -> BigIntToken Integer) -> Integer -> BigIntToken Integer
forall a b. (a -> b) -> a -> b
$! (-1 Integer -> Integer -> Integer
forall a. Num a => a -> a -> a
- Word64 -> Integer
forall a. Integral a => a -> Integer
toInteger Word64
w))
#else
in DecodedToken sz (BigIntToken (isWordCanonical sz w#) $! (-1 - toInteger w))
#endif
0xc2 -> ByteString -> DecodedToken (BigIntToken Integer)
forall a. ByteString -> DecodedToken (BigIntToken a)
readBigUInt ByteString
bs
0xc3 -> ByteString -> DecodedToken (BigIntToken Integer)
forall a. ByteString -> DecodedToken (BigIntToken a)
readBigNInt ByteString
bs
_ -> DecodedToken (BigIntToken Integer)
forall a. DecodedToken a
DecodeFailure
{-# INLINE tryConsumeBytes #-}
tryConsumeBytes :: Word8 -> ByteString -> DecodedToken (LongToken ByteString)
tryConsumeBytes :: Word8 -> ByteString -> DecodedToken (LongToken ByteString)
tryConsumeBytes hdr :: Word8
hdr !ByteString
bs = case Word8 -> Word
word8ToWord Word8
hdr of
0x40 -> Int -> ByteString -> DecodedToken (LongToken ByteString)
readBytesSmall 0 ByteString
bs
0x41 -> Int -> ByteString -> DecodedToken (LongToken ByteString)
readBytesSmall 1 ByteString
bs
0x42 -> Int -> ByteString -> DecodedToken (LongToken ByteString)
readBytesSmall 2 ByteString
bs
0x43 -> Int -> ByteString -> DecodedToken (LongToken ByteString)
readBytesSmall 3 ByteString
bs
0x44 -> Int -> ByteString -> DecodedToken (LongToken ByteString)
readBytesSmall 4 ByteString
bs
0x45 -> Int -> ByteString -> DecodedToken (LongToken ByteString)
readBytesSmall 5 ByteString
bs
0x46 -> Int -> ByteString -> DecodedToken (LongToken ByteString)
readBytesSmall 6 ByteString
bs
0x47 -> Int -> ByteString -> DecodedToken (LongToken ByteString)
readBytesSmall 7 ByteString
bs
0x48 -> Int -> ByteString -> DecodedToken (LongToken ByteString)
readBytesSmall 8 ByteString
bs
0x49 -> Int -> ByteString -> DecodedToken (LongToken ByteString)
readBytesSmall 9 ByteString
bs
0x4a -> Int -> ByteString -> DecodedToken (LongToken ByteString)
readBytesSmall 10 ByteString
bs
0x4b -> Int -> ByteString -> DecodedToken (LongToken ByteString)
readBytesSmall 11 ByteString
bs
0x4c -> Int -> ByteString -> DecodedToken (LongToken ByteString)
readBytesSmall 12 ByteString
bs
0x4d -> Int -> ByteString -> DecodedToken (LongToken ByteString)
readBytesSmall 13 ByteString
bs
0x4e -> Int -> ByteString -> DecodedToken (LongToken ByteString)
readBytesSmall 14 ByteString
bs
0x4f -> Int -> ByteString -> DecodedToken (LongToken ByteString)
readBytesSmall 15 ByteString
bs
0x50 -> Int -> ByteString -> DecodedToken (LongToken ByteString)
readBytesSmall 16 ByteString
bs
0x51 -> Int -> ByteString -> DecodedToken (LongToken ByteString)
readBytesSmall 17 ByteString
bs
0x52 -> Int -> ByteString -> DecodedToken (LongToken ByteString)
readBytesSmall 18 ByteString
bs
0x53 -> Int -> ByteString -> DecodedToken (LongToken ByteString)
readBytesSmall 19 ByteString
bs
0x54 -> Int -> ByteString -> DecodedToken (LongToken ByteString)
readBytesSmall 20 ByteString
bs
0x55 -> Int -> ByteString -> DecodedToken (LongToken ByteString)
readBytesSmall 21 ByteString
bs
0x56 -> Int -> ByteString -> DecodedToken (LongToken ByteString)
readBytesSmall 22 ByteString
bs
0x57 -> Int -> ByteString -> DecodedToken (LongToken ByteString)
readBytesSmall 23 ByteString
bs
0x58 -> ByteString -> DecodedToken (LongToken ByteString)
readBytes8 ByteString
bs
0x59 -> ByteString -> DecodedToken (LongToken ByteString)
readBytes16 ByteString
bs
0x5a -> ByteString -> DecodedToken (LongToken ByteString)
readBytes32 ByteString
bs
0x5b -> ByteString -> DecodedToken (LongToken ByteString)
readBytes64 ByteString
bs
_ -> DecodedToken (LongToken ByteString)
forall a. DecodedToken a
DecodeFailure
{-# INLINE tryConsumeString #-}
tryConsumeString :: Word8 -> ByteString -> DecodedToken (LongToken ByteString)
tryConsumeString :: Word8 -> ByteString -> DecodedToken (LongToken ByteString)
tryConsumeString hdr :: Word8
hdr !ByteString
bs = case Word8 -> Word
word8ToWord Word8
hdr of
0x60 -> Int -> ByteString -> DecodedToken (LongToken ByteString)
readBytesSmall 0 ByteString
bs
0x61 -> Int -> ByteString -> DecodedToken (LongToken ByteString)
readBytesSmall 1 ByteString
bs
0x62 -> Int -> ByteString -> DecodedToken (LongToken ByteString)
readBytesSmall 2 ByteString
bs
0x63 -> Int -> ByteString -> DecodedToken (LongToken ByteString)
readBytesSmall 3 ByteString
bs
0x64 -> Int -> ByteString -> DecodedToken (LongToken ByteString)
readBytesSmall 4 ByteString
bs
0x65 -> Int -> ByteString -> DecodedToken (LongToken ByteString)
readBytesSmall 5 ByteString
bs
0x66 -> Int -> ByteString -> DecodedToken (LongToken ByteString)
readBytesSmall 6 ByteString
bs
0x67 -> Int -> ByteString -> DecodedToken (LongToken ByteString)
readBytesSmall 7 ByteString
bs
0x68 -> Int -> ByteString -> DecodedToken (LongToken ByteString)
readBytesSmall 8 ByteString
bs
0x69 -> Int -> ByteString -> DecodedToken (LongToken ByteString)
readBytesSmall 9 ByteString
bs
0x6a -> Int -> ByteString -> DecodedToken (LongToken ByteString)
readBytesSmall 10 ByteString
bs
0x6b -> Int -> ByteString -> DecodedToken (LongToken ByteString)
readBytesSmall 11 ByteString
bs
0x6c -> Int -> ByteString -> DecodedToken (LongToken ByteString)
readBytesSmall 12 ByteString
bs
0x6d -> Int -> ByteString -> DecodedToken (LongToken ByteString)
readBytesSmall 13 ByteString
bs
0x6e -> Int -> ByteString -> DecodedToken (LongToken ByteString)
readBytesSmall 14 ByteString
bs
0x6f -> Int -> ByteString -> DecodedToken (LongToken ByteString)
readBytesSmall 15 ByteString
bs
0x70 -> Int -> ByteString -> DecodedToken (LongToken ByteString)
readBytesSmall 16 ByteString
bs
0x71 -> Int -> ByteString -> DecodedToken (LongToken ByteString)
readBytesSmall 17 ByteString
bs
0x72 -> Int -> ByteString -> DecodedToken (LongToken ByteString)
readBytesSmall 18 ByteString
bs
0x73 -> Int -> ByteString -> DecodedToken (LongToken ByteString)
readBytesSmall 19 ByteString
bs
0x74 -> Int -> ByteString -> DecodedToken (LongToken ByteString)
readBytesSmall 20 ByteString
bs
0x75 -> Int -> ByteString -> DecodedToken (LongToken ByteString)
readBytesSmall 21 ByteString
bs
0x76 -> Int -> ByteString -> DecodedToken (LongToken ByteString)
readBytesSmall 22 ByteString
bs
0x77 -> Int -> ByteString -> DecodedToken (LongToken ByteString)
readBytesSmall 23 ByteString
bs
0x78 -> ByteString -> DecodedToken (LongToken ByteString)
readBytes8 ByteString
bs
0x79 -> ByteString -> DecodedToken (LongToken ByteString)
readBytes16 ByteString
bs
0x7a -> ByteString -> DecodedToken (LongToken ByteString)
readBytes32 ByteString
bs
0x7b -> ByteString -> DecodedToken (LongToken ByteString)
readBytes64 ByteString
bs
_ -> DecodedToken (LongToken ByteString)
forall a. DecodedToken a
DecodeFailure
{-# INLINE tryConsumeListLen #-}
tryConsumeListLen :: Word8 -> ByteString -> DecodedToken Int
tryConsumeListLen :: Word8 -> ByteString -> DecodedToken Int
tryConsumeListLen hdr :: Word8
hdr !ByteString
bs = case Word8 -> Word
word8ToWord Word8
hdr of
0x80 -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 0
0x81 -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 1
0x82 -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 2
0x83 -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 3
0x84 -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 4
0x85 -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 5
0x86 -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 6
0x87 -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 7
0x88 -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 8
0x89 -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 9
0x8a -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 10
0x8b -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 11
0x8c -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 12
0x8d -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 13
0x8e -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 14
0x8f -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 15
0x90 -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 16
0x91 -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 17
0x92 -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 18
0x93 -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 19
0x94 -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 20
0x95 -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 21
0x96 -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 22
0x97 -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 23
0x98 -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 2 (Word8 -> Int
word8ToInt (ByteString -> Word8
eatTailWord8 ByteString
bs))
0x99 -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 3 (Word16 -> Int
word16ToInt (ByteString -> Word16
eatTailWord16 ByteString
bs))
#if defined(ARCH_64bit)
0x9a -> DecodedToken 5 (word32ToInt (eatTailWord32 bs))
#else
0x9a -> case Word32 -> Maybe Int
word32ToInt (ByteString -> Word32
eatTailWord32 ByteString
bs) of
Just n :: Int
n -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 5 Int
n
Nothing -> DecodedToken Int
forall a. DecodedToken a
DecodeFailure
#endif
0x9b -> case Word64 -> Maybe Int
word64ToInt (ByteString -> Word64
eatTailWord64 ByteString
bs) of
Just n :: Int
n -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 9 Int
n
Nothing -> DecodedToken Int
forall a. DecodedToken a
DecodeFailure
_ -> DecodedToken Int
forall a. DecodedToken a
DecodeFailure
{-# INLINE tryConsumeMapLen #-}
tryConsumeMapLen :: Word8 -> ByteString -> DecodedToken Int
tryConsumeMapLen :: Word8 -> ByteString -> DecodedToken Int
tryConsumeMapLen hdr :: Word8
hdr !ByteString
bs = case Word8 -> Word
word8ToWord Word8
hdr of
0xa0 -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 0
0xa1 -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 1
0xa2 -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 2
0xa3 -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 3
0xa4 -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 4
0xa5 -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 5
0xa6 -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 6
0xa7 -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 7
0xa8 -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 8
0xa9 -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 9
0xaa -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 10
0xab -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 11
0xac -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 12
0xad -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 13
0xae -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 14
0xaf -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 15
0xb0 -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 16
0xb1 -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 17
0xb2 -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 18
0xb3 -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 19
0xb4 -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 20
0xb5 -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 21
0xb6 -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 22
0xb7 -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 23
0xb8 -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 2 (Int -> DecodedToken Int) -> Int -> DecodedToken Int
forall a b. (a -> b) -> a -> b
$! (Word8 -> Int
word8ToInt (ByteString -> Word8
eatTailWord8 ByteString
bs))
0xb9 -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 3 (Int -> DecodedToken Int) -> Int -> DecodedToken Int
forall a b. (a -> b) -> a -> b
$! (Word16 -> Int
word16ToInt (ByteString -> Word16
eatTailWord16 ByteString
bs))
#if defined(ARCH_64bit)
0xba -> DecodedToken 5 $! (word32ToInt (eatTailWord32 bs))
#else
0xba -> case Word32 -> Maybe Int
word32ToInt (ByteString -> Word32
eatTailWord32 ByteString
bs) of
Just n :: Int
n -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 5 Int
n
Nothing -> DecodedToken Int
forall a. DecodedToken a
DecodeFailure
#endif
0xbb -> case Word64 -> Maybe Int
word64ToInt (ByteString -> Word64
eatTailWord64 ByteString
bs) of
Just n :: Int
n -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 9 Int
n
Nothing -> DecodedToken Int
forall a. DecodedToken a
DecodeFailure
_ -> DecodedToken Int
forall a. DecodedToken a
DecodeFailure
{-# INLINE tryConsumeListLenIndef #-}
tryConsumeListLenIndef :: Word8 -> DecodedToken ()
tryConsumeListLenIndef :: Word8 -> DecodedToken ()
tryConsumeListLenIndef hdr :: Word8
hdr = case Word8 -> Word
word8ToWord Word8
hdr of
0x9f -> Int -> () -> DecodedToken ()
forall a. Int -> a -> DecodedToken a
DecodedToken 1 ()
_ -> DecodedToken ()
forall a. DecodedToken a
DecodeFailure
{-# INLINE tryConsumeMapLenIndef #-}
tryConsumeMapLenIndef :: Word8 -> DecodedToken ()
tryConsumeMapLenIndef :: Word8 -> DecodedToken ()
tryConsumeMapLenIndef hdr :: Word8
hdr = case Word8 -> Word
word8ToWord Word8
hdr of
0xbf -> Int -> () -> DecodedToken ()
forall a. Int -> a -> DecodedToken a
DecodedToken 1 ()
_ -> DecodedToken ()
forall a. DecodedToken a
DecodeFailure
{-# INLINE tryConsumeListLenOrIndef #-}
tryConsumeListLenOrIndef :: Word8 -> ByteString -> DecodedToken Int
tryConsumeListLenOrIndef :: Word8 -> ByteString -> DecodedToken Int
tryConsumeListLenOrIndef hdr :: Word8
hdr !ByteString
bs = case Word8 -> Word
word8ToWord Word8
hdr of
0x80 -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 0
0x81 -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 1
0x82 -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 2
0x83 -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 3
0x84 -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 4
0x85 -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 5
0x86 -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 6
0x87 -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 7
0x88 -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 8
0x89 -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 9
0x8a -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 10
0x8b -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 11
0x8c -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 12
0x8d -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 13
0x8e -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 14
0x8f -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 15
0x90 -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 16
0x91 -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 17
0x92 -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 18
0x93 -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 19
0x94 -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 20
0x95 -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 21
0x96 -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 22
0x97 -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 23
0x98 -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 2 (Int -> DecodedToken Int) -> Int -> DecodedToken Int
forall a b. (a -> b) -> a -> b
$! (Word8 -> Int
word8ToInt (ByteString -> Word8
eatTailWord8 ByteString
bs))
0x99 -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 3 (Int -> DecodedToken Int) -> Int -> DecodedToken Int
forall a b. (a -> b) -> a -> b
$! (Word16 -> Int
word16ToInt (ByteString -> Word16
eatTailWord16 ByteString
bs))
#if defined(ARCH_64bit)
0x9a -> DecodedToken 5 $! (word32ToInt (eatTailWord32 bs))
#else
0x9a -> case Word32 -> Maybe Int
word32ToInt (ByteString -> Word32
eatTailWord32 ByteString
bs) of
Just n :: Int
n -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 5 Int
n
Nothing -> DecodedToken Int
forall a. DecodedToken a
DecodeFailure
#endif
0x9b -> case Word64 -> Maybe Int
word64ToInt (ByteString -> Word64
eatTailWord64 ByteString
bs) of
Just n :: Int
n -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 9 Int
n
Nothing -> DecodedToken Int
forall a. DecodedToken a
DecodeFailure
0x9f -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 (-1)
_ -> DecodedToken Int
forall a. DecodedToken a
DecodeFailure
{-# INLINE tryConsumeMapLenOrIndef #-}
tryConsumeMapLenOrIndef :: Word8 -> ByteString -> DecodedToken Int
tryConsumeMapLenOrIndef :: Word8 -> ByteString -> DecodedToken Int
tryConsumeMapLenOrIndef hdr :: Word8
hdr !ByteString
bs = case Word8 -> Word
word8ToWord Word8
hdr of
0xa0 -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 0
0xa1 -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 1
0xa2 -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 2
0xa3 -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 3
0xa4 -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 4
0xa5 -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 5
0xa6 -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 6
0xa7 -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 7
0xa8 -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 8
0xa9 -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 9
0xaa -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 10
0xab -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 11
0xac -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 12
0xad -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 13
0xae -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 14
0xaf -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 15
0xb0 -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 16
0xb1 -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 17
0xb2 -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 18
0xb3 -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 19
0xb4 -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 20
0xb5 -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 21
0xb6 -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 22
0xb7 -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 23
0xb8 -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 2 (Int -> DecodedToken Int) -> Int -> DecodedToken Int
forall a b. (a -> b) -> a -> b
$! (Word8 -> Int
word8ToInt (ByteString -> Word8
eatTailWord8 ByteString
bs))
0xb9 -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 3 (Int -> DecodedToken Int) -> Int -> DecodedToken Int
forall a b. (a -> b) -> a -> b
$! (Word16 -> Int
word16ToInt (ByteString -> Word16
eatTailWord16 ByteString
bs))
#if defined(ARCH_64bit)
0xba -> DecodedToken 5 $! (word32ToInt (eatTailWord32 bs))
#else
0xba -> case Word32 -> Maybe Int
word32ToInt (ByteString -> Word32
eatTailWord32 ByteString
bs) of
Just n :: Int
n -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 5 Int
n
Nothing -> DecodedToken Int
forall a. DecodedToken a
DecodeFailure
#endif
0xbb -> case Word64 -> Maybe Int
word64ToInt (ByteString -> Word64
eatTailWord64 ByteString
bs) of
Just n :: Int
n -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 9 Int
n
Nothing -> DecodedToken Int
forall a. DecodedToken a
DecodeFailure
0xbf -> Int -> Int -> DecodedToken Int
forall a. Int -> a -> DecodedToken a
DecodedToken 1 (-1)
_ -> DecodedToken Int
forall a. DecodedToken a
DecodeFailure
{-# INLINE tryConsumeTag #-}
tryConsumeTag :: Word8 -> ByteString -> DecodedToken Word
tryConsumeTag :: Word8 -> ByteString -> DecodedToken Word
tryConsumeTag hdr :: Word8
hdr !ByteString
bs = case Word8 -> Word
word8ToWord Word8
hdr of
0xc0 -> Int -> Word -> DecodedToken Word
forall a. Int -> a -> DecodedToken a
DecodedToken 1 0
0xc1 -> Int -> Word -> DecodedToken Word
forall a. Int -> a -> DecodedToken a
DecodedToken 1 1
0xc2 -> Int -> Word -> DecodedToken Word
forall a. Int -> a -> DecodedToken a
DecodedToken 1 2
0xc3 -> Int -> Word -> DecodedToken Word
forall a. Int -> a -> DecodedToken a
DecodedToken 1 3
0xc4 -> Int -> Word -> DecodedToken Word
forall a. Int -> a -> DecodedToken a
DecodedToken 1 4
0xc5 -> Int -> Word -> DecodedToken Word
forall a. Int -> a -> DecodedToken a
DecodedToken 1 5
0xc6 -> Int -> Word -> DecodedToken Word
forall a. Int -> a -> DecodedToken a
DecodedToken 1 6
0xc7 -> Int -> Word -> DecodedToken Word
forall a. Int -> a -> DecodedToken a
DecodedToken 1 7
0xc8 -> Int -> Word -> DecodedToken Word
forall a. Int -> a -> DecodedToken a
DecodedToken 1 8
0xc9 -> Int -> Word -> DecodedToken Word
forall a. Int -> a -> DecodedToken a
DecodedToken 1 9
0xca -> Int -> Word -> DecodedToken Word
forall a. Int -> a -> DecodedToken a
DecodedToken 1 10
0xcb -> Int -> Word -> DecodedToken Word
forall a. Int -> a -> DecodedToken a
DecodedToken 1 11
0xcc -> Int -> Word -> DecodedToken Word
forall a. Int -> a -> DecodedToken a
DecodedToken 1 12
0xcd -> Int -> Word -> DecodedToken Word
forall a. Int -> a -> DecodedToken a
DecodedToken 1 13
0xce -> Int -> Word -> DecodedToken Word
forall a. Int -> a -> DecodedToken a
DecodedToken 1 14
0xcf -> Int -> Word -> DecodedToken Word
forall a. Int -> a -> DecodedToken a
DecodedToken 1 15
0xd0 -> Int -> Word -> DecodedToken Word
forall a. Int -> a -> DecodedToken a
DecodedToken 1 16
0xd1 -> Int -> Word -> DecodedToken Word
forall a. Int -> a -> DecodedToken a
DecodedToken 1 17
0xd2 -> Int -> Word -> DecodedToken Word
forall a. Int -> a -> DecodedToken a
DecodedToken 1 18
0xd3 -> Int -> Word -> DecodedToken Word
forall a. Int -> a -> DecodedToken a
DecodedToken 1 19
0xd4 -> Int -> Word -> DecodedToken Word
forall a. Int -> a -> DecodedToken a
DecodedToken 1 20
0xd5 -> Int -> Word -> DecodedToken Word
forall a. Int -> a -> DecodedToken a
DecodedToken 1 21
0xd6 -> Int -> Word -> DecodedToken Word
forall a. Int -> a -> DecodedToken a
DecodedToken 1 22
0xd7 -> Int -> Word -> DecodedToken Word
forall a. Int -> a -> DecodedToken a
DecodedToken 1 23
0xd8 -> Int -> Word -> DecodedToken Word
forall a. Int -> a -> DecodedToken a
DecodedToken 2 (Word -> DecodedToken Word) -> Word -> DecodedToken Word
forall a b. (a -> b) -> a -> b
$! (Word8 -> Word
word8ToWord (ByteString -> Word8
eatTailWord8 ByteString
bs))
0xd9 -> Int -> Word -> DecodedToken Word
forall a. Int -> a -> DecodedToken a
DecodedToken 3 (Word -> DecodedToken Word) -> Word -> DecodedToken Word
forall a b. (a -> b) -> a -> b
$! (Word16 -> Word
word16ToWord (ByteString -> Word16
eatTailWord16 ByteString
bs))
0xda -> Int -> Word -> DecodedToken Word
forall a. Int -> a -> DecodedToken a
DecodedToken 5 (Word -> DecodedToken Word) -> Word -> DecodedToken Word
forall a b. (a -> b) -> a -> b
$! (Word32 -> Word
word32ToWord (ByteString -> Word32
eatTailWord32 ByteString
bs))
#if defined(ARCH_64bit)
0xdb -> DecodedToken 9 $! (word64ToWord (eatTailWord64 bs))
#else
0xdb -> case Word64 -> Maybe Word
word64ToWord (ByteString -> Word64
eatTailWord64 ByteString
bs) of
Just n :: Word
n -> Int -> Word -> DecodedToken Word
forall a. Int -> a -> DecodedToken a
DecodedToken 9 Word
n
Nothing -> DecodedToken Word
forall a. DecodedToken a
DecodeFailure
#endif
_ -> DecodedToken Word
forall a. DecodedToken a
DecodeFailure
#if defined(ARCH_32bit)
tryConsumeWord64 :: Word8 -> ByteString -> DecodedToken Word64
tryConsumeWord64 :: Word8 -> ByteString -> DecodedToken Word64
tryConsumeWord64 hdr :: Word8
hdr !ByteString
bs = case Word8 -> Word
word8ToWord Word8
hdr of
0x00 -> Int -> Word64 -> DecodedToken Word64
forall a. Int -> a -> DecodedToken a
DecodedToken 1 0
0x01 -> Int -> Word64 -> DecodedToken Word64
forall a. Int -> a -> DecodedToken a
DecodedToken 1 1
0x02 -> Int -> Word64 -> DecodedToken Word64
forall a. Int -> a -> DecodedToken a
DecodedToken 1 2
0x03 -> Int -> Word64 -> DecodedToken Word64
forall a. Int -> a -> DecodedToken a
DecodedToken 1 3
0x04 -> Int -> Word64 -> DecodedToken Word64
forall a. Int -> a -> DecodedToken a
DecodedToken 1 4
0x05 -> Int -> Word64 -> DecodedToken Word64
forall a. Int -> a -> DecodedToken a
DecodedToken 1 5
0x06 -> Int -> Word64 -> DecodedToken Word64
forall a. Int -> a -> DecodedToken a
DecodedToken 1 6
0x07 -> Int -> Word64 -> DecodedToken Word64
forall a. Int -> a -> DecodedToken a
DecodedToken 1 7
0x08 -> Int -> Word64 -> DecodedToken Word64
forall a. Int -> a -> DecodedToken a
DecodedToken 1 8
0x09 -> Int -> Word64 -> DecodedToken Word64
forall a. Int -> a -> DecodedToken a
DecodedToken 1 9
0x0a -> Int -> Word64 -> DecodedToken Word64
forall a. Int -> a -> DecodedToken a
DecodedToken 1 10
0x0b -> Int -> Word64 -> DecodedToken Word64
forall a. Int -> a -> DecodedToken a
DecodedToken 1 11
0x0c -> Int -> Word64 -> DecodedToken Word64
forall a. Int -> a -> DecodedToken a
DecodedToken 1 12
0x0d -> Int -> Word64 -> DecodedToken Word64
forall a. Int -> a -> DecodedToken a
DecodedToken 1 13
0x0e -> Int -> Word64 -> DecodedToken Word64
forall a. Int -> a -> DecodedToken a
DecodedToken 1 14
0x0f -> Int -> Word64 -> DecodedToken Word64
forall a. Int -> a -> DecodedToken a
DecodedToken 1 15
0x10 -> Int -> Word64 -> DecodedToken Word64
forall a. Int -> a -> DecodedToken a
DecodedToken 1 16
0x11 -> Int -> Word64 -> DecodedToken Word64
forall a. Int -> a -> DecodedToken a
DecodedToken 1 17
0x12 -> Int -> Word64 -> DecodedToken Word64
forall a. Int -> a -> DecodedToken a
DecodedToken 1 18
0x13 -> Int -> Word64 -> DecodedToken Word64
forall a. Int -> a -> DecodedToken a
DecodedToken 1 19
0x14 -> Int -> Word64 -> DecodedToken Word64
forall a. Int -> a -> DecodedToken a
DecodedToken 1 20
0x15 -> Int -> Word64 -> DecodedToken Word64
forall a. Int -> a -> DecodedToken a
DecodedToken 1 21
0x16 -> Int -> Word64 -> DecodedToken Word64
forall a. Int -> a -> DecodedToken a
DecodedToken 1 22
0x17 -> Int -> Word64 -> DecodedToken Word64
forall a. Int -> a -> DecodedToken a
DecodedToken 1 23
0x18 -> Int -> Word64 -> DecodedToken Word64
forall a. Int -> a -> DecodedToken a
DecodedToken 2 (Word64 -> DecodedToken Word64) -> Word64 -> DecodedToken Word64
forall a b. (a -> b) -> a -> b
$! (Word8 -> Word64
word8ToWord64 (ByteString -> Word8
eatTailWord8 ByteString
bs))
0x19 -> Int -> Word64 -> DecodedToken Word64
forall a. Int -> a -> DecodedToken a
DecodedToken 3 (Word64 -> DecodedToken Word64) -> Word64 -> DecodedToken Word64
forall a b. (a -> b) -> a -> b
$! (Word16 -> Word64
word16ToWord64 (ByteString -> Word16
eatTailWord16 ByteString
bs))
0x1a -> Int -> Word64 -> DecodedToken Word64
forall a. Int -> a -> DecodedToken a
DecodedToken 5 (Word64 -> DecodedToken Word64) -> Word64 -> DecodedToken Word64
forall a b. (a -> b) -> a -> b
$! (Word32 -> Word64
word32ToWord64 (ByteString -> Word32
eatTailWord32 ByteString
bs))
0x1b -> Int -> Word64 -> DecodedToken Word64
forall a. Int -> a -> DecodedToken a
DecodedToken 9 (Word64 -> DecodedToken Word64) -> Word64 -> DecodedToken Word64
forall a b. (a -> b) -> a -> b
$! (ByteString -> Word64
eatTailWord64 ByteString
bs)
_ -> DecodedToken Word64
forall a. DecodedToken a
DecodeFailure
{-# INLINE tryConsumeWord64 #-}
tryConsumeNegWord64 :: Word8 -> ByteString -> DecodedToken Word64
tryConsumeNegWord64 :: Word8 -> ByteString -> DecodedToken Word64
tryConsumeNegWord64 hdr :: Word8
hdr !ByteString
bs = case Word8 -> Word
word8ToWord Word8
hdr of
0x20 -> Int -> Word64 -> DecodedToken Word64
forall a. Int -> a -> DecodedToken a
DecodedToken 1 0
0x21 -> Int -> Word64 -> DecodedToken Word64
forall a. Int -> a -> DecodedToken a
DecodedToken 1 1
0x22 -> Int -> Word64 -> DecodedToken Word64
forall a. Int -> a -> DecodedToken a
DecodedToken 1 2
0x23 -> Int -> Word64 -> DecodedToken Word64
forall a. Int -> a -> DecodedToken a
DecodedToken 1 3
0x24 -> Int -> Word64 -> DecodedToken Word64
forall a. Int -> a -> DecodedToken a
DecodedToken 1 4
0x25 -> Int -> Word64 -> DecodedToken Word64
forall a. Int -> a -> DecodedToken a
DecodedToken 1 5
0x26 -> Int -> Word64 -> DecodedToken Word64
forall a. Int -> a -> DecodedToken a
DecodedToken 1 6
0x27 -> Int -> Word64 -> DecodedToken Word64
forall a. Int -> a -> DecodedToken a
DecodedToken 1 7
0x28 -> Int -> Word64 -> DecodedToken Word64
forall a. Int -> a -> DecodedToken a
DecodedToken 1 8
0x29 -> Int -> Word64 -> DecodedToken Word64
forall a. Int -> a -> DecodedToken a
DecodedToken 1 9
0x2a -> Int -> Word64 -> DecodedToken Word64
forall a. Int -> a -> DecodedToken a
DecodedToken 1 10
0x2b -> Int -> Word64 -> DecodedToken Word64
forall a. Int -> a -> DecodedToken a
DecodedToken 1 11
0x2c -> Int -> Word64 -> DecodedToken Word64
forall a. Int -> a -> DecodedToken a
DecodedToken 1 12
0x2d -> Int -> Word64 -> DecodedToken Word64
forall a. Int -> a -> DecodedToken a
DecodedToken 1 13
0x2e -> Int -> Word64 -> DecodedToken Word64
forall a. Int -> a -> DecodedToken a
DecodedToken 1 14
0x2f -> Int -> Word64 -> DecodedToken Word64
forall a. Int -> a -> DecodedToken a
DecodedToken 1 15
0x30 -> Int -> Word64 -> DecodedToken Word64
forall a. Int -> a -> DecodedToken a
DecodedToken 1 16
0x31 -> Int -> Word64 -> DecodedToken Word64
forall a. Int -> a -> DecodedToken a
DecodedToken 1 17
0x32 -> Int -> Word64 -> DecodedToken Word64
forall a. Int -> a -> DecodedToken a
DecodedToken 1 18
0x33 -> Int -> Word64 -> DecodedToken Word64
forall a. Int -> a -> DecodedToken a
DecodedToken 1 19
0x34 -> Int -> Word64 -> DecodedToken Word64
forall a. Int -> a -> DecodedToken a
DecodedToken 1 20
0x35 -> Int -> Word64 -> DecodedToken Word64
forall a. Int -> a -> DecodedToken a
DecodedToken 1 21
0x36 -> Int -> Word64 -> DecodedToken Word64
forall a. Int -> a -> DecodedToken a
DecodedToken 1 22
0x37 -> Int -> Word64 -> DecodedToken Word64
forall a. Int -> a -> DecodedToken a
DecodedToken 1 23
0x38 -> Int -> Word64 -> DecodedToken Word64
forall a. Int -> a -> DecodedToken a
DecodedToken 2 (Word64 -> DecodedToken Word64) -> Word64 -> DecodedToken Word64
forall a b. (a -> b) -> a -> b
$! (Word8 -> Word64
word8ToWord64 (ByteString -> Word8
eatTailWord8 ByteString
bs))
0x39 -> Int -> Word64 -> DecodedToken Word64
forall a. Int -> a -> DecodedToken a
DecodedToken 3 (Word64 -> DecodedToken Word64) -> Word64 -> DecodedToken Word64
forall a b. (a -> b) -> a -> b
$! (Word16 -> Word64
word16ToWord64 (ByteString -> Word16
eatTailWord16 ByteString
bs))
0x3a -> Int -> Word64 -> DecodedToken Word64
forall a. Int -> a -> DecodedToken a
DecodedToken 5 (Word64 -> DecodedToken Word64) -> Word64 -> DecodedToken Word64
forall a b. (a -> b) -> a -> b
$! (Word32 -> Word64
word32ToWord64 (ByteString -> Word32
eatTailWord32 ByteString
bs))
0x3b -> Int -> Word64 -> DecodedToken Word64
forall a. Int -> a -> DecodedToken a
DecodedToken 9 (Word64 -> DecodedToken Word64) -> Word64 -> DecodedToken Word64
forall a b. (a -> b) -> a -> b
$! (ByteString -> Word64
eatTailWord64 ByteString
bs)
_ -> DecodedToken Word64
forall a. DecodedToken a
DecodeFailure
{-# INLINE tryConsumeNegWord64 #-}
tryConsumeInt64 :: Word8 -> ByteString -> DecodedToken Int64
tryConsumeInt64 :: Word8 -> ByteString -> DecodedToken ByteOffset
tryConsumeInt64 hdr :: Word8
hdr !ByteString
bs = case Word8 -> Word
word8ToWord Word8
hdr of
0x00 -> Int -> ByteOffset -> DecodedToken ByteOffset
forall a. Int -> a -> DecodedToken a
DecodedToken 1 0
0x01 -> Int -> ByteOffset -> DecodedToken ByteOffset
forall a. Int -> a -> DecodedToken a
DecodedToken 1 1
0x02 -> Int -> ByteOffset -> DecodedToken ByteOffset
forall a. Int -> a -> DecodedToken a
DecodedToken 1 2
0x03 -> Int -> ByteOffset -> DecodedToken ByteOffset
forall a. Int -> a -> DecodedToken a
DecodedToken 1 3
0x04 -> Int -> ByteOffset -> DecodedToken ByteOffset
forall a. Int -> a -> DecodedToken a
DecodedToken 1 4
0x05 -> Int -> ByteOffset -> DecodedToken ByteOffset
forall a. Int -> a -> DecodedToken a
DecodedToken 1 5
0x06 -> Int -> ByteOffset -> DecodedToken ByteOffset
forall a. Int -> a -> DecodedToken a
DecodedToken 1 6
0x07 -> Int -> ByteOffset -> DecodedToken ByteOffset
forall a. Int -> a -> DecodedToken a
DecodedToken 1 7
0x08 -> Int -> ByteOffset -> DecodedToken ByteOffset
forall a. Int -> a -> DecodedToken a
DecodedToken 1 8
0x09 -> Int -> ByteOffset -> DecodedToken ByteOffset
forall a. Int -> a -> DecodedToken a
DecodedToken 1 9
0x0a -> Int -> ByteOffset -> DecodedToken ByteOffset
forall a. Int -> a -> DecodedToken a
DecodedToken 1 10
0x0b -> Int -> ByteOffset -> DecodedToken ByteOffset
forall a. Int -> a -> DecodedToken a
DecodedToken 1 11
0x0c -> Int -> ByteOffset -> DecodedToken ByteOffset
forall a. Int -> a -> DecodedToken a
DecodedToken 1 12
0x0d -> Int -> ByteOffset -> DecodedToken ByteOffset
forall a. Int -> a -> DecodedToken a
DecodedToken 1 13
0x0e -> Int -> ByteOffset -> DecodedToken ByteOffset
forall a. Int -> a -> DecodedToken a
DecodedToken 1 14
0x0f -> Int -> ByteOffset -> DecodedToken ByteOffset
forall a. Int -> a -> DecodedToken a
DecodedToken 1 15
0x10 -> Int -> ByteOffset -> DecodedToken ByteOffset
forall a. Int -> a -> DecodedToken a
DecodedToken 1 16
0x11 -> Int -> ByteOffset -> DecodedToken ByteOffset
forall a. Int -> a -> DecodedToken a
DecodedToken 1 17
0x12 -> Int -> ByteOffset -> DecodedToken ByteOffset
forall a. Int -> a -> DecodedToken a
DecodedToken 1 18
0x13 -> Int -> ByteOffset -> DecodedToken ByteOffset
forall a. Int -> a -> DecodedToken a
DecodedToken 1 19
0x14 -> Int -> ByteOffset -> DecodedToken ByteOffset
forall a. Int -> a -> DecodedToken a
DecodedToken 1 20
0x15 -> Int -> ByteOffset -> DecodedToken ByteOffset
forall a. Int -> a -> DecodedToken a
DecodedToken 1 21
0x16 -> Int -> ByteOffset -> DecodedToken ByteOffset
forall a. Int -> a -> DecodedToken a
DecodedToken 1 22
0x17 -> Int -> ByteOffset -> DecodedToken ByteOffset
forall a. Int -> a -> DecodedToken a
DecodedToken 1 23
0x18 -> Int -> ByteOffset -> DecodedToken ByteOffset
forall a. Int -> a -> DecodedToken a
DecodedToken 2 (ByteOffset -> DecodedToken ByteOffset)
-> ByteOffset -> DecodedToken ByteOffset
forall a b. (a -> b) -> a -> b
$! (Word8 -> ByteOffset
word8ToInt64 (ByteString -> Word8
eatTailWord8 ByteString
bs))
0x19 -> Int -> ByteOffset -> DecodedToken ByteOffset
forall a. Int -> a -> DecodedToken a
DecodedToken 3 (ByteOffset -> DecodedToken ByteOffset)
-> ByteOffset -> DecodedToken ByteOffset
forall a b. (a -> b) -> a -> b
$! (Word16 -> ByteOffset
word16ToInt64 (ByteString -> Word16
eatTailWord16 ByteString
bs))
0x1a -> Int -> ByteOffset -> DecodedToken ByteOffset
forall a. Int -> a -> DecodedToken a
DecodedToken 5 (ByteOffset -> DecodedToken ByteOffset)
-> ByteOffset -> DecodedToken ByteOffset
forall a b. (a -> b) -> a -> b
$! (Word32 -> ByteOffset
word32ToInt64 (ByteString -> Word32
eatTailWord32 ByteString
bs))
0x1b -> case Word64 -> Maybe ByteOffset
word64ToInt64 (ByteString -> Word64
eatTailWord64 ByteString
bs) of
Just n :: ByteOffset
n -> Int -> ByteOffset -> DecodedToken ByteOffset
forall a. Int -> a -> DecodedToken a
DecodedToken 9 ByteOffset
n
Nothing -> DecodedToken ByteOffset
forall a. DecodedToken a
DecodeFailure
0x20 -> Int -> ByteOffset -> DecodedToken ByteOffset
forall a. Int -> a -> DecodedToken a
DecodedToken 1 (-1)
0x21 -> Int -> ByteOffset -> DecodedToken ByteOffset
forall a. Int -> a -> DecodedToken a
DecodedToken 1 (-2)
0x22 -> Int -> ByteOffset -> DecodedToken ByteOffset
forall a. Int -> a -> DecodedToken a
DecodedToken 1 (-3)
0x23 -> Int -> ByteOffset -> DecodedToken ByteOffset
forall a. Int -> a -> DecodedToken a
DecodedToken 1 (-4)
0x24 -> Int -> ByteOffset -> DecodedToken ByteOffset
forall a. Int -> a -> DecodedToken a
DecodedToken 1 (-5)
0x25 -> Int -> ByteOffset -> DecodedToken ByteOffset
forall a. Int -> a -> DecodedToken a
DecodedToken 1 (-6)
0x26 -> Int -> ByteOffset -> DecodedToken ByteOffset
forall a. Int -> a -> DecodedToken a
DecodedToken 1 (-7)
0x27 -> Int -> ByteOffset -> DecodedToken ByteOffset
forall a. Int -> a -> DecodedToken a
DecodedToken 1 (-8)
0x28 -> Int -> ByteOffset -> DecodedToken ByteOffset
forall a. Int -> a -> DecodedToken a
DecodedToken 1 (-9)
0x29 -> Int -> ByteOffset -> DecodedToken ByteOffset
forall a. Int -> a -> DecodedToken a
DecodedToken 1 (-10)
0x2a -> Int -> ByteOffset -> DecodedToken ByteOffset
forall a. Int -> a -> DecodedToken a
DecodedToken 1 (-11)
0x2b -> Int -> ByteOffset -> DecodedToken ByteOffset
forall a. Int -> a -> DecodedToken a
DecodedToken 1 (-12)
0x2c -> Int -> ByteOffset -> DecodedToken ByteOffset
forall a. Int -> a -> DecodedToken a
DecodedToken 1 (-13)
0x2d -> Int -> ByteOffset -> DecodedToken ByteOffset
forall a. Int -> a -> DecodedToken a
DecodedToken 1 (-14)
0x2e -> Int -> ByteOffset -> DecodedToken ByteOffset
forall a. Int -> a -> DecodedToken a
DecodedToken 1 (-15)
0x2f -> Int -> ByteOffset -> DecodedToken ByteOffset
forall a. Int -> a -> DecodedToken a
DecodedToken 1 (-16)
0x30 -> Int -> ByteOffset -> DecodedToken ByteOffset
forall a. Int -> a -> DecodedToken a
DecodedToken 1 (-17)
0x31 -> Int -> ByteOffset -> DecodedToken ByteOffset
forall a. Int -> a -> DecodedToken a
DecodedToken 1 (-18)
0x32 -> Int -> ByteOffset -> DecodedToken ByteOffset
forall a. Int -> a -> DecodedToken a
DecodedToken 1 (-19)
0x33 -> Int -> ByteOffset -> DecodedToken ByteOffset
forall a. Int -> a -> DecodedToken a
DecodedToken 1 (-20)
0x34 -> Int -> ByteOffset -> DecodedToken ByteOffset
forall a. Int -> a -> DecodedToken a
DecodedToken 1 (-21)
0x35 -> Int -> ByteOffset -> DecodedToken ByteOffset
forall a. Int -> a -> DecodedToken a
DecodedToken 1 (-22)
0x36 -> Int -> ByteOffset -> DecodedToken ByteOffset
forall a. Int -> a -> DecodedToken a
DecodedToken 1 (-23)
0x37 -> Int -> ByteOffset -> DecodedToken ByteOffset
forall a. Int -> a -> DecodedToken a
DecodedToken 1 (-24)
0x38 -> Int -> ByteOffset -> DecodedToken ByteOffset
forall a. Int -> a -> DecodedToken a
DecodedToken 2 (ByteOffset -> DecodedToken ByteOffset)
-> ByteOffset -> DecodedToken ByteOffset
forall a b. (a -> b) -> a -> b
$! (-1 ByteOffset -> ByteOffset -> ByteOffset
forall a. Num a => a -> a -> a
- Word8 -> ByteOffset
word8ToInt64 (ByteString -> Word8
eatTailWord8 ByteString
bs))
0x39 -> Int -> ByteOffset -> DecodedToken ByteOffset
forall a. Int -> a -> DecodedToken a
DecodedToken 3 (ByteOffset -> DecodedToken ByteOffset)
-> ByteOffset -> DecodedToken ByteOffset
forall a b. (a -> b) -> a -> b
$! (-1 ByteOffset -> ByteOffset -> ByteOffset
forall a. Num a => a -> a -> a
- Word16 -> ByteOffset
word16ToInt64 (ByteString -> Word16
eatTailWord16 ByteString
bs))
0x3a -> Int -> ByteOffset -> DecodedToken ByteOffset
forall a. Int -> a -> DecodedToken a
DecodedToken 5 (ByteOffset -> DecodedToken ByteOffset)
-> ByteOffset -> DecodedToken ByteOffset
forall a b. (a -> b) -> a -> b
$! (-1 ByteOffset -> ByteOffset -> ByteOffset
forall a. Num a => a -> a -> a
- Word32 -> ByteOffset
word32ToInt64 (ByteString -> Word32
eatTailWord32 ByteString
bs))
0x3b -> case Word64 -> Maybe ByteOffset
word64ToInt64 (ByteString -> Word64
eatTailWord64 ByteString
bs) of
Just n :: ByteOffset
n -> Int -> ByteOffset -> DecodedToken ByteOffset
forall a. Int -> a -> DecodedToken a
DecodedToken 9 (-1 ByteOffset -> ByteOffset -> ByteOffset
forall a. Num a => a -> a -> a
- ByteOffset
n)
Nothing -> DecodedToken ByteOffset
forall a. DecodedToken a
DecodeFailure
_ -> DecodedToken ByteOffset
forall a. DecodedToken a
DecodeFailure
{-# INLINE tryConsumeInt64 #-}
tryConsumeListLen64 :: Word8 -> ByteString -> DecodedToken Int64
tryConsumeListLen64 :: Word8 -> ByteString -> DecodedToken ByteOffset
tryConsumeListLen64 hdr :: Word8
hdr !ByteString
bs = case Word8 -> Word
word8ToWord Word8
hdr of
0x80 -> Int -> ByteOffset -> DecodedToken ByteOffset
forall a. Int -> a -> DecodedToken a
DecodedToken 1 0
0x81 -> Int -> ByteOffset -> DecodedToken ByteOffset
forall a. Int -> a -> DecodedToken a
DecodedToken 1 1
0x82 -> Int -> ByteOffset -> DecodedToken ByteOffset
forall a. Int -> a -> DecodedToken a
DecodedToken 1 2
0x83 -> Int -> ByteOffset -> DecodedToken ByteOffset
forall a. Int -> a -> DecodedToken a
DecodedToken 1 3
0x84 -> Int -> ByteOffset -> DecodedToken ByteOffset
forall a. Int -> a -> DecodedToken a
DecodedToken 1 4
0x85 -> Int -> ByteOffset -> DecodedToken ByteOffset
forall a. Int -> a -> DecodedToken a
DecodedToken 1 5
0x86 -> Int -> ByteOffset -> DecodedToken ByteOffset
forall a. Int -> a -> DecodedToken a
DecodedToken 1 6
0x87 -> Int -> ByteOffset -> DecodedToken ByteOffset
forall a. Int -> a -> DecodedToken a
DecodedToken 1 7
0x88 -> Int -> ByteOffset -> DecodedToken ByteOffset
forall a. Int -> a -> DecodedToken a
DecodedToken 1 8
0x89 -> Int -> ByteOffset -> DecodedToken ByteOffset
forall a. Int -> a -> DecodedToken a
DecodedToken 1 9
0x8a -> Int -> ByteOffset -> DecodedToken ByteOffset
forall a. Int -> a -> DecodedToken a
DecodedToken 1 10
0x8b -> Int -> ByteOffset -> DecodedToken ByteOffset
forall a. Int -> a -> DecodedToken a
DecodedToken 1 11
0x8c -> Int -> ByteOffset -> DecodedToken ByteOffset
forall a. Int -> a -> DecodedToken a
DecodedToken 1 12
0x8d -> Int -> ByteOffset -> DecodedToken ByteOffset
forall a. Int -> a -> DecodedToken a
DecodedToken 1 13
0x8e -> Int -> ByteOffset -> DecodedToken ByteOffset
forall a. Int -> a -> DecodedToken a
DecodedToken 1 14
0x8f -> Int -> ByteOffset -> DecodedToken ByteOffset
forall a. Int -> a -> DecodedToken a
DecodedToken 1 15
0x90 -> Int -> ByteOffset -> DecodedToken ByteOffset
forall a. Int -> a -> DecodedToken a
DecodedToken 1 16
0x91 -> Int -> ByteOffset -> DecodedToken ByteOffset
forall a. Int -> a -> DecodedToken a
DecodedToken 1 17
0x92 -> Int -> ByteOffset -> DecodedToken ByteOffset
forall a. Int -> a -> DecodedToken a
DecodedToken 1 18
0x93 -> Int -> ByteOffset -> DecodedToken ByteOffset
forall a. Int -> a -> DecodedToken a
DecodedToken 1 19
0x94 -> Int -> ByteOffset -> DecodedToken ByteOffset
forall a. Int -> a -> DecodedToken a
DecodedToken 1 20
0x95 -> Int -> ByteOffset -> DecodedToken ByteOffset
forall a. Int -> a -> DecodedToken a
DecodedToken 1 21
0x96 -> Int -> ByteOffset -> DecodedToken ByteOffset
forall a. Int -> a -> DecodedToken a
DecodedToken 1 22
0x97 -> Int -> ByteOffset -> DecodedToken ByteOffset
forall a. Int -> a -> DecodedToken a
DecodedToken 1 23
0x98 -> Int -> ByteOffset -> DecodedToken ByteOffset
forall a. Int -> a -> DecodedToken a
DecodedToken 2 (ByteOffset -> DecodedToken ByteOffset)
-> ByteOffset -> DecodedToken ByteOffset
forall a b. (a -> b) -> a -> b
$! (Word8 -> ByteOffset
word8ToInt64 (ByteString -> Word8
eatTailWord8 ByteString
bs))
0x99 -> Int -> ByteOffset -> DecodedToken ByteOffset
forall a. Int -> a -> DecodedToken a
DecodedToken 3 (ByteOffset -> DecodedToken ByteOffset)
-> ByteOffset -> DecodedToken ByteOffset
forall a b. (a -> b) -> a -> b
$! (Word16 -> ByteOffset
word16ToInt64 (ByteString -> Word16
eatTailWord16 ByteString
bs))
0x9a -> Int -> ByteOffset -> DecodedToken ByteOffset
forall a. Int -> a -> DecodedToken a
DecodedToken 5 (ByteOffset -> DecodedToken ByteOffset)
-> ByteOffset -> DecodedToken ByteOffset
forall a b. (a -> b) -> a -> b
$! (Word32 -> ByteOffset
word32ToInt64 (ByteString -> Word32
eatTailWord32 ByteString
bs))
0x9b -> case Word64 -> Maybe ByteOffset
word64ToInt64 (ByteString -> Word64
eatTailWord64 ByteString
bs) of
Just n :: ByteOffset
n -> Int -> ByteOffset -> DecodedToken ByteOffset
forall a. Int -> a -> DecodedToken a
DecodedToken 9 ByteOffset
n
Nothing -> DecodedToken ByteOffset
forall a. DecodedToken a
DecodeFailure
_ -> DecodedToken ByteOffset
forall a. DecodedToken a
DecodeFailure
{-# INLINE tryConsumeListLen64 #-}
tryConsumeMapLen64 :: Word8 -> ByteString -> DecodedToken Int64
tryConsumeMapLen64 :: Word8 -> ByteString -> DecodedToken ByteOffset
tryConsumeMapLen64 hdr :: Word8
hdr !ByteString
bs = case Word8 -> Word
word8ToWord Word8
hdr of
0xa0 -> Int -> ByteOffset -> DecodedToken ByteOffset
forall a. Int -> a -> DecodedToken a
DecodedToken 1 0
0xa1 -> Int -> ByteOffset -> DecodedToken ByteOffset
forall a. Int -> a -> DecodedToken a
DecodedToken 1 1
0xa2 -> Int -> ByteOffset -> DecodedToken ByteOffset
forall a. Int -> a -> DecodedToken a
DecodedToken 1 2
0xa3 -> Int -> ByteOffset -> DecodedToken ByteOffset
forall a. Int -> a -> DecodedToken a
DecodedToken 1 3
0xa4 -> Int -> ByteOffset -> DecodedToken ByteOffset
forall a. Int -> a -> DecodedToken a
DecodedToken 1 4
0xa5 -> Int -> ByteOffset -> DecodedToken ByteOffset
forall a. Int -> a -> DecodedToken a
DecodedToken 1 5
0xa6 -> Int -> ByteOffset -> DecodedToken ByteOffset
forall a. Int -> a -> DecodedToken a
DecodedToken 1 6
0xa7 -> Int -> ByteOffset -> DecodedToken ByteOffset
forall a. Int -> a -> DecodedToken a
DecodedToken 1 7
0xa8 -> Int -> ByteOffset -> DecodedToken ByteOffset
forall a. Int -> a -> DecodedToken a
DecodedToken 1 8
0xa9 -> Int -> ByteOffset -> DecodedToken ByteOffset
forall a. Int -> a -> DecodedToken a
DecodedToken 1 9
0xaa -> Int -> ByteOffset -> DecodedToken ByteOffset
forall a. Int -> a -> DecodedToken a
DecodedToken 1 10
0xab -> Int -> ByteOffset -> DecodedToken ByteOffset
forall a. Int -> a -> DecodedToken a
DecodedToken 1 11
0xac -> Int -> ByteOffset -> DecodedToken ByteOffset
forall a. Int -> a -> DecodedToken a
DecodedToken 1 12
0xad -> Int -> ByteOffset -> DecodedToken ByteOffset
forall a. Int -> a -> DecodedToken a
DecodedToken 1 13
0xae -> Int -> ByteOffset -> DecodedToken ByteOffset
forall a. Int -> a -> DecodedToken a
DecodedToken 1 14
0xaf -> Int -> ByteOffset -> DecodedToken ByteOffset
forall a. Int -> a -> DecodedToken a
DecodedToken 1 15
0xb0 -> Int -> ByteOffset -> DecodedToken ByteOffset
forall a. Int -> a -> DecodedToken a
DecodedToken 1 16
0xb1 -> Int -> ByteOffset -> DecodedToken ByteOffset
forall a. Int -> a -> DecodedToken a
DecodedToken 1 17
0xb2 -> Int -> ByteOffset -> DecodedToken ByteOffset
forall a. Int -> a -> DecodedToken a
DecodedToken 1 18
0xb3 -> Int -> ByteOffset -> DecodedToken ByteOffset
forall a. Int -> a -> DecodedToken a
DecodedToken 1 19
0xb4 -> Int -> ByteOffset -> DecodedToken ByteOffset
forall a. Int -> a -> DecodedToken a
DecodedToken 1 20
0xb5 -> Int -> ByteOffset -> DecodedToken ByteOffset
forall a. Int -> a -> DecodedToken a
DecodedToken 1 21
0xb6 -> Int -> ByteOffset -> DecodedToken ByteOffset
forall a. Int -> a -> DecodedToken a
DecodedToken 1 22
0xb7 -> Int -> ByteOffset -> DecodedToken ByteOffset
forall a. Int -> a -> DecodedToken a
DecodedToken 1 23
0xb8 -> Int -> ByteOffset -> DecodedToken ByteOffset
forall a. Int -> a -> DecodedToken a
DecodedToken 2 (ByteOffset -> DecodedToken ByteOffset)
-> ByteOffset -> DecodedToken ByteOffset
forall a b. (a -> b) -> a -> b
$! (Word8 -> ByteOffset
word8ToInt64 (ByteString -> Word8
eatTailWord8 ByteString
bs))
0xb9 -> Int -> ByteOffset -> DecodedToken ByteOffset
forall a. Int -> a -> DecodedToken a
DecodedToken 3 (ByteOffset -> DecodedToken ByteOffset)
-> ByteOffset -> DecodedToken ByteOffset
forall a b. (a -> b) -> a -> b
$! (Word16 -> ByteOffset
word16ToInt64 (ByteString -> Word16
eatTailWord16 ByteString
bs))
0xba -> Int -> ByteOffset -> DecodedToken ByteOffset
forall a. Int -> a -> DecodedToken a
DecodedToken 5 (ByteOffset -> DecodedToken ByteOffset)
-> ByteOffset -> DecodedToken ByteOffset
forall a b. (a -> b) -> a -> b
$! (Word32 -> ByteOffset
word32ToInt64 (ByteString -> Word32
eatTailWord32 ByteString
bs))
0xbb -> case Word64 -> Maybe ByteOffset
word64ToInt64 (ByteString -> Word64
eatTailWord64 ByteString
bs) of
Just n :: ByteOffset
n -> Int -> ByteOffset -> DecodedToken ByteOffset
forall a. Int -> a -> DecodedToken a
DecodedToken 9 ByteOffset
n
Nothing -> DecodedToken ByteOffset
forall a. DecodedToken a
DecodeFailure
_ -> DecodedToken ByteOffset
forall a. DecodedToken a
DecodeFailure
{-# INLINE tryConsumeMapLen64 #-}
tryConsumeTag64 :: Word8 -> ByteString -> DecodedToken Word64
tryConsumeTag64 :: Word8 -> ByteString -> DecodedToken Word64
tryConsumeTag64 hdr :: Word8
hdr !ByteString
bs = case Word8 -> Word
word8ToWord Word8
hdr of
0xc0 -> Int -> Word64 -> DecodedToken Word64
forall a. Int -> a -> DecodedToken a
DecodedToken 1 0
0xc1 -> Int -> Word64 -> DecodedToken Word64
forall a. Int -> a -> DecodedToken a
DecodedToken 1 1
0xc2 -> Int -> Word64 -> DecodedToken Word64
forall a. Int -> a -> DecodedToken a
DecodedToken 1 2
0xc3 -> Int -> Word64 -> DecodedToken Word64
forall a. Int -> a -> DecodedToken a
DecodedToken 1 3
0xc4 -> Int -> Word64 -> DecodedToken Word64
forall a. Int -> a -> DecodedToken a
DecodedToken 1 4
0xc5 -> Int -> Word64 -> DecodedToken Word64
forall a. Int -> a -> DecodedToken a
DecodedToken 1 5
0xc6 -> Int -> Word64 -> DecodedToken Word64
forall a. Int -> a -> DecodedToken a
DecodedToken 1 6
0xc7 -> Int -> Word64 -> DecodedToken Word64
forall a. Int -> a -> DecodedToken a
DecodedToken 1 7
0xc8 -> Int -> Word64 -> DecodedToken Word64
forall a. Int -> a -> DecodedToken a
DecodedToken 1 8
0xc9 -> Int -> Word64 -> DecodedToken Word64
forall a. Int -> a -> DecodedToken a
DecodedToken 1 9
0xca -> Int -> Word64 -> DecodedToken Word64
forall a. Int -> a -> DecodedToken a
DecodedToken 1 10
0xcb -> Int -> Word64 -> DecodedToken Word64
forall a. Int -> a -> DecodedToken a
DecodedToken 1 11
0xcc -> Int -> Word64 -> DecodedToken Word64
forall a. Int -> a -> DecodedToken a
DecodedToken 1 12
0xcd -> Int -> Word64 -> DecodedToken Word64
forall a. Int -> a -> DecodedToken a
DecodedToken 1 13
0xce -> Int -> Word64 -> DecodedToken Word64
forall a. Int -> a -> DecodedToken a
DecodedToken 1 14
0xcf -> Int -> Word64 -> DecodedToken Word64
forall a. Int -> a -> DecodedToken a
DecodedToken 1 15
0xd0 -> Int -> Word64 -> DecodedToken Word64
forall a. Int -> a -> DecodedToken a
DecodedToken 1 16
0xd1 -> Int -> Word64 -> DecodedToken Word64
forall a. Int -> a -> DecodedToken a
DecodedToken 1 17
0xd2 -> Int -> Word64 -> DecodedToken Word64
forall a. Int -> a -> DecodedToken a
DecodedToken 1 18
0xd3 -> Int -> Word64 -> DecodedToken Word64
forall a. Int -> a -> DecodedToken a
DecodedToken 1 19
0xd4 -> Int -> Word64 -> DecodedToken Word64
forall a. Int -> a -> DecodedToken a
DecodedToken 1 20
0xd5 -> Int -> Word64 -> DecodedToken Word64
forall a. Int -> a -> DecodedToken a
DecodedToken 1 21
0xd6 -> Int -> Word64 -> DecodedToken Word64
forall a. Int -> a -> DecodedToken a
DecodedToken 1 22
0xd7 -> Int -> Word64 -> DecodedToken Word64
forall a. Int -> a -> DecodedToken a
DecodedToken 1 23
0xd8 -> Int -> Word64 -> DecodedToken Word64
forall a. Int -> a -> DecodedToken a
DecodedToken 2 (Word64 -> DecodedToken Word64) -> Word64 -> DecodedToken Word64
forall a b. (a -> b) -> a -> b
$! (Word8 -> Word64
word8ToWord64 (ByteString -> Word8
eatTailWord8 ByteString
bs))
0xd9 -> Int -> Word64 -> DecodedToken Word64
forall a. Int -> a -> DecodedToken a
DecodedToken 3 (Word64 -> DecodedToken Word64) -> Word64 -> DecodedToken Word64
forall a b. (a -> b) -> a -> b
$! (Word16 -> Word64
word16ToWord64 (ByteString -> Word16
eatTailWord16 ByteString
bs))
0xda -> Int -> Word64 -> DecodedToken Word64
forall a. Int -> a -> DecodedToken a
DecodedToken 5 (Word64 -> DecodedToken Word64) -> Word64 -> DecodedToken Word64
forall a b. (a -> b) -> a -> b
$! (Word32 -> Word64
word32ToWord64 (ByteString -> Word32
eatTailWord32 ByteString
bs))
0xdb -> Int -> Word64 -> DecodedToken Word64
forall a. Int -> a -> DecodedToken a
DecodedToken 9 (Word64 -> DecodedToken Word64) -> Word64 -> DecodedToken Word64
forall a b. (a -> b) -> a -> b
$! (ByteString -> Word64
eatTailWord64 ByteString
bs)
_ -> DecodedToken Word64
forall a. DecodedToken a
DecodeFailure
{-# INLINE tryConsumeTag64 #-}
#endif
{-# INLINE tryConsumeFloat #-}
tryConsumeFloat :: Word8 -> ByteString -> DecodedToken Float
tryConsumeFloat :: Word8 -> ByteString -> DecodedToken Float
tryConsumeFloat hdr :: Word8
hdr !ByteString
bs = case Word8 -> Word
word8ToWord Word8
hdr of
0xf9 -> Int -> Float -> DecodedToken Float
forall a. Int -> a -> DecodedToken a
DecodedToken 3 (Float -> DecodedToken Float) -> Float -> DecodedToken Float
forall a b. (a -> b) -> a -> b
$! (Word16 -> Float
wordToFloat16 (ByteString -> Word16
eatTailWord16 ByteString
bs))
0xfa -> Int -> Float -> DecodedToken Float
forall a. Int -> a -> DecodedToken a
DecodedToken 5 (Float -> DecodedToken Float) -> Float -> DecodedToken Float
forall a b. (a -> b) -> a -> b
$! (Word32 -> Float
wordToFloat32 (ByteString -> Word32
eatTailWord32 ByteString
bs))
_ -> DecodedToken Float
forall a. DecodedToken a
DecodeFailure
{-# INLINE tryConsumeDouble #-}
tryConsumeDouble :: Word8 -> ByteString -> DecodedToken Double
tryConsumeDouble :: Word8 -> ByteString -> DecodedToken Double
tryConsumeDouble hdr :: Word8
hdr !ByteString
bs = case Word8 -> Word
word8ToWord Word8
hdr of
0xf9 -> Int -> Double -> DecodedToken Double
forall a. Int -> a -> DecodedToken a
DecodedToken 3 (Double -> DecodedToken Double) -> Double -> DecodedToken Double
forall a b. (a -> b) -> a -> b
$! (Float -> Double
float2Double (Float -> Double) -> Float -> Double
forall a b. (a -> b) -> a -> b
$ Word16 -> Float
wordToFloat16 (ByteString -> Word16
eatTailWord16 ByteString
bs))
0xfa -> Int -> Double -> DecodedToken Double
forall a. Int -> a -> DecodedToken a
DecodedToken 5 (Double -> DecodedToken Double) -> Double -> DecodedToken Double
forall a b. (a -> b) -> a -> b
$! (Float -> Double
float2Double (Float -> Double) -> Float -> Double
forall a b. (a -> b) -> a -> b
$ Word32 -> Float
wordToFloat32 (ByteString -> Word32
eatTailWord32 ByteString
bs))
0xfb -> Int -> Double -> DecodedToken Double
forall a. Int -> a -> DecodedToken a
DecodedToken 9 (Double -> DecodedToken Double) -> Double -> DecodedToken Double
forall a b. (a -> b) -> a -> b
$! (Word64 -> Double
wordToFloat64 (ByteString -> Word64
eatTailWord64 ByteString
bs))
_ -> DecodedToken Double
forall a. DecodedToken a
DecodeFailure
{-# INLINE tryConsumeBool #-}
tryConsumeBool :: Word8 -> DecodedToken Bool
tryConsumeBool :: Word8 -> DecodedToken Bool
tryConsumeBool hdr :: Word8
hdr = case Word8 -> Word
word8ToWord Word8
hdr of
0xf4 -> Int -> Bool -> DecodedToken Bool
forall a. Int -> a -> DecodedToken a
DecodedToken 1 Bool
False
0xf5 -> Int -> Bool -> DecodedToken Bool
forall a. Int -> a -> DecodedToken a
DecodedToken 1 Bool
True
_ -> DecodedToken Bool
forall a. DecodedToken a
DecodeFailure
{-# INLINE tryConsumeSimple #-}
tryConsumeSimple :: Word8 -> ByteString -> DecodedToken Word
tryConsumeSimple :: Word8 -> ByteString -> DecodedToken Word
tryConsumeSimple hdr :: Word8
hdr !ByteString
bs = case Word8 -> Word
word8ToWord Word8
hdr of
0xe0 -> Int -> Word -> DecodedToken Word
forall a. Int -> a -> DecodedToken a
DecodedToken 1 0
0xe1 -> Int -> Word -> DecodedToken Word
forall a. Int -> a -> DecodedToken a
DecodedToken 1 1
0xe2 -> Int -> Word -> DecodedToken Word
forall a. Int -> a -> DecodedToken a
DecodedToken 1 2
0xe3 -> Int -> Word -> DecodedToken Word
forall a. Int -> a -> DecodedToken a
DecodedToken 1 3
0xe4 -> Int -> Word -> DecodedToken Word
forall a. Int -> a -> DecodedToken a
DecodedToken 1 4
0xe5 -> Int -> Word -> DecodedToken Word
forall a. Int -> a -> DecodedToken a
DecodedToken 1 5
0xe6 -> Int -> Word -> DecodedToken Word
forall a. Int -> a -> DecodedToken a
DecodedToken 1 6
0xe7 -> Int -> Word -> DecodedToken Word
forall a. Int -> a -> DecodedToken a
DecodedToken 1 7
0xe8 -> Int -> Word -> DecodedToken Word
forall a. Int -> a -> DecodedToken a
DecodedToken 1 8
0xe9 -> Int -> Word -> DecodedToken Word
forall a. Int -> a -> DecodedToken a
DecodedToken 1 9
0xea -> Int -> Word -> DecodedToken Word
forall a. Int -> a -> DecodedToken a
DecodedToken 1 10
0xeb -> Int -> Word -> DecodedToken Word
forall a. Int -> a -> DecodedToken a
DecodedToken 1 11
0xec -> Int -> Word -> DecodedToken Word
forall a. Int -> a -> DecodedToken a
DecodedToken 1 12
0xed -> Int -> Word -> DecodedToken Word
forall a. Int -> a -> DecodedToken a
DecodedToken 1 13
0xee -> Int -> Word -> DecodedToken Word
forall a. Int -> a -> DecodedToken a
DecodedToken 1 14
0xef -> Int -> Word -> DecodedToken Word
forall a. Int -> a -> DecodedToken a
DecodedToken 1 15
0xf0 -> Int -> Word -> DecodedToken Word
forall a. Int -> a -> DecodedToken a
DecodedToken 1 16
0xf1 -> Int -> Word -> DecodedToken Word
forall a. Int -> a -> DecodedToken a
DecodedToken 1 17
0xf2 -> Int -> Word -> DecodedToken Word
forall a. Int -> a -> DecodedToken a
DecodedToken 1 18
0xf3 -> Int -> Word -> DecodedToken Word
forall a. Int -> a -> DecodedToken a
DecodedToken 1 19
0xf4 -> Int -> Word -> DecodedToken Word
forall a. Int -> a -> DecodedToken a
DecodedToken 1 20
0xf5 -> Int -> Word -> DecodedToken Word
forall a. Int -> a -> DecodedToken a
DecodedToken 1 21
0xf6 -> Int -> Word -> DecodedToken Word
forall a. Int -> a -> DecodedToken a
DecodedToken 1 22
0xf7 -> Int -> Word -> DecodedToken Word
forall a. Int -> a -> DecodedToken a
DecodedToken 1 23
0xf8 -> Int -> Word -> DecodedToken Word
forall a. Int -> a -> DecodedToken a
DecodedToken 2 (Word -> DecodedToken Word) -> Word -> DecodedToken Word
forall a b. (a -> b) -> a -> b
$! (Word8 -> Word
word8ToWord (ByteString -> Word8
eatTailWord8 ByteString
bs))
_ -> DecodedToken Word
forall a. DecodedToken a
DecodeFailure
{-# INLINE tryConsumeBytesIndef #-}
tryConsumeBytesIndef :: Word8 -> DecodedToken ()
tryConsumeBytesIndef :: Word8 -> DecodedToken ()
tryConsumeBytesIndef hdr :: Word8
hdr = case Word8 -> Word
word8ToWord Word8
hdr of
0x5f -> Int -> () -> DecodedToken ()
forall a. Int -> a -> DecodedToken a
DecodedToken 1 ()
_ -> DecodedToken ()
forall a. DecodedToken a
DecodeFailure
{-# INLINE tryConsumeStringIndef #-}
tryConsumeStringIndef :: Word8 -> DecodedToken ()
tryConsumeStringIndef :: Word8 -> DecodedToken ()
tryConsumeStringIndef hdr :: Word8
hdr = case Word8 -> Word
word8ToWord Word8
hdr of
0x7f -> Int -> () -> DecodedToken ()
forall a. Int -> a -> DecodedToken a
DecodedToken 1 ()
_ -> DecodedToken ()
forall a. DecodedToken a
DecodeFailure
{-# INLINE tryConsumeNull #-}
tryConsumeNull :: Word8 -> DecodedToken ()
hdr :: Word8
hdr = case Word8 -> Word
word8ToWord Word8
hdr of
0xf6 -> Int -> () -> DecodedToken ()
forall a. Int -> a -> DecodedToken a
DecodedToken 1 ()
_ -> DecodedToken ()
forall a. DecodedToken a
DecodeFailure
{-# INLINE tryConsumeBreakOr #-}
tryConsumeBreakOr :: Word8 -> DecodedToken ()
tryConsumeBreakOr :: Word8 -> DecodedToken ()
tryConsumeBreakOr hdr :: Word8
hdr = case Word8 -> Word
word8ToWord Word8
hdr of
0xff -> Int -> () -> DecodedToken ()
forall a. Int -> a -> DecodedToken a
DecodedToken 1 ()
_ -> DecodedToken ()
forall a. DecodedToken a
DecodeFailure
{-# INLINE readBytesSmall #-}
readBytesSmall :: Int -> ByteString -> DecodedToken (LongToken ByteString)
readBytesSmall :: Int -> ByteString -> DecodedToken (LongToken ByteString)
readBytesSmall n :: Int
n bs :: ByteString
bs
| Int
n Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
hdrsz Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
<= ByteString -> Int
BS.length ByteString
bs
= Int -> LongToken ByteString -> DecodedToken (LongToken ByteString)
forall a. Int -> a -> DecodedToken a
DecodedToken (Int
nInt -> Int -> Int
forall a. Num a => a -> a -> a
+Int
hdrsz) (LongToken ByteString -> DecodedToken (LongToken ByteString))
-> LongToken ByteString -> DecodedToken (LongToken ByteString)
forall a b. (a -> b) -> a -> b
$ Bool -> ByteString -> LongToken ByteString
forall a. Bool -> a -> LongToken a
Fits Bool
True (ByteString -> LongToken ByteString)
-> ByteString -> LongToken ByteString
forall a b. (a -> b) -> a -> b
$
Int -> ByteString -> ByteString
BS.unsafeTake Int
n (Int -> ByteString -> ByteString
BS.unsafeDrop Int
hdrsz ByteString
bs)
| Bool
otherwise
= Int -> LongToken ByteString -> DecodedToken (LongToken ByteString)
forall a. Int -> a -> DecodedToken a
DecodedToken Int
hdrsz (LongToken ByteString -> DecodedToken (LongToken ByteString))
-> LongToken ByteString -> DecodedToken (LongToken ByteString)
forall a b. (a -> b) -> a -> b
$ Bool -> Int -> LongToken ByteString
forall a. Bool -> Int -> LongToken a
TooLong Bool
True Int
n
where
hdrsz :: Int
hdrsz = 1
{-# INLINE readBytes8 #-}
{-# INLINE readBytes16 #-}
{-# INLINE readBytes32 #-}
{-# INLINE readBytes64 #-}
readBytes8, readBytes16, readBytes32, readBytes64
:: ByteString -> DecodedToken (LongToken ByteString)
readBytes8 :: ByteString -> DecodedToken (LongToken ByteString)
readBytes8 bs :: ByteString
bs
| Int
n Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
<= ByteString -> Int
BS.length ByteString
bs Int -> Int -> Int
forall a. Num a => a -> a -> a
- Int
hdrsz
= Int -> LongToken ByteString -> DecodedToken (LongToken ByteString)
forall a. Int -> a -> DecodedToken a
DecodedToken (Int
nInt -> Int -> Int
forall a. Num a => a -> a -> a
+Int
hdrsz) (LongToken ByteString -> DecodedToken (LongToken ByteString))
-> LongToken ByteString -> DecodedToken (LongToken ByteString)
forall a b. (a -> b) -> a -> b
$ Bool -> ByteString -> LongToken ByteString
forall a. Bool -> a -> LongToken a
Fits Bool
lengthCanonical (ByteString -> LongToken ByteString)
-> ByteString -> LongToken ByteString
forall a b. (a -> b) -> a -> b
$
Int -> ByteString -> ByteString
BS.unsafeTake Int
n (Int -> ByteString -> ByteString
BS.unsafeDrop Int
hdrsz ByteString
bs)
| Bool
otherwise
= Int -> LongToken ByteString -> DecodedToken (LongToken ByteString)
forall a. Int -> a -> DecodedToken a
DecodedToken Int
hdrsz (LongToken ByteString -> DecodedToken (LongToken ByteString))
-> LongToken ByteString -> DecodedToken (LongToken ByteString)
forall a b. (a -> b) -> a -> b
$ Bool -> Int -> LongToken ByteString
forall a. Bool -> Int -> LongToken a
TooLong Bool
lengthCanonical Int
n
where
hdrsz :: Int
hdrsz = 2
!n :: Int
n@(I# n# :: Int#
n#) = Word8 -> Int
word8ToInt (ByteString -> Word8
eatTailWord8 ByteString
bs)
lengthCanonical :: Bool
lengthCanonical = Int -> Int# -> Bool
isIntCanonical Int
hdrsz Int#
n#
readBytes16 :: ByteString -> DecodedToken (LongToken ByteString)
readBytes16 bs :: ByteString
bs
| Int
n Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
<= ByteString -> Int
BS.length ByteString
bs Int -> Int -> Int
forall a. Num a => a -> a -> a
- Int
hdrsz
= Int -> LongToken ByteString -> DecodedToken (LongToken ByteString)
forall a. Int -> a -> DecodedToken a
DecodedToken (Int
nInt -> Int -> Int
forall a. Num a => a -> a -> a
+Int
hdrsz) (LongToken ByteString -> DecodedToken (LongToken ByteString))
-> LongToken ByteString -> DecodedToken (LongToken ByteString)
forall a b. (a -> b) -> a -> b
$ Bool -> ByteString -> LongToken ByteString
forall a. Bool -> a -> LongToken a
Fits Bool
lengthCanonical (ByteString -> LongToken ByteString)
-> ByteString -> LongToken ByteString
forall a b. (a -> b) -> a -> b
$
Int -> ByteString -> ByteString
BS.unsafeTake Int
n (Int -> ByteString -> ByteString
BS.unsafeDrop Int
hdrsz ByteString
bs)
| Bool
otherwise
= Int -> LongToken ByteString -> DecodedToken (LongToken ByteString)
forall a. Int -> a -> DecodedToken a
DecodedToken Int
hdrsz (LongToken ByteString -> DecodedToken (LongToken ByteString))
-> LongToken ByteString -> DecodedToken (LongToken ByteString)
forall a b. (a -> b) -> a -> b
$ Bool -> Int -> LongToken ByteString
forall a. Bool -> Int -> LongToken a
TooLong Bool
lengthCanonical Int
n
where
hdrsz :: Int
hdrsz = 3
!n :: Int
n@(I# n# :: Int#
n#) = Word16 -> Int
word16ToInt (ByteString -> Word16
eatTailWord16 ByteString
bs)
lengthCanonical :: Bool
lengthCanonical = Int -> Int# -> Bool
isIntCanonical Int
hdrsz Int#
n#
readBytes32 :: ByteString -> DecodedToken (LongToken ByteString)
readBytes32 bs :: ByteString
bs = case Word32 -> Maybe Int
word32ToInt (ByteString -> Word32
eatTailWord32 ByteString
bs) of
#if defined(ARCH_32bit)
Just n :: Int
n@(I# n# :: Int#
n#)
#else
n@(I# n#)
#endif
| Int
n Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
<= ByteString -> Int
BS.length ByteString
bs Int -> Int -> Int
forall a. Num a => a -> a -> a
- Int
hdrsz
-> Int -> LongToken ByteString -> DecodedToken (LongToken ByteString)
forall a. Int -> a -> DecodedToken a
DecodedToken (Int
nInt -> Int -> Int
forall a. Num a => a -> a -> a
+Int
hdrsz) (LongToken ByteString -> DecodedToken (LongToken ByteString))
-> LongToken ByteString -> DecodedToken (LongToken ByteString)
forall a b. (a -> b) -> a -> b
$ Bool -> ByteString -> LongToken ByteString
forall a. Bool -> a -> LongToken a
Fits (Int -> Int# -> Bool
isIntCanonical Int
hdrsz Int#
n#) (ByteString -> LongToken ByteString)
-> ByteString -> LongToken ByteString
forall a b. (a -> b) -> a -> b
$
Int -> ByteString -> ByteString
BS.unsafeTake Int
n (Int -> ByteString -> ByteString
BS.unsafeDrop Int
hdrsz ByteString
bs)
| Bool
otherwise -> Int -> LongToken ByteString -> DecodedToken (LongToken ByteString)
forall a. Int -> a -> DecodedToken a
DecodedToken Int
hdrsz (LongToken ByteString -> DecodedToken (LongToken ByteString))
-> LongToken ByteString -> DecodedToken (LongToken ByteString)
forall a b. (a -> b) -> a -> b
$ Bool -> Int -> LongToken ByteString
forall a. Bool -> Int -> LongToken a
TooLong (Int -> Int# -> Bool
isIntCanonical Int
hdrsz Int#
n#) Int
n
#if defined(ARCH_32bit)
Nothing -> DecodedToken (LongToken ByteString)
forall a. DecodedToken a
DecodeFailure
#endif
where
hdrsz :: Int
hdrsz = 5
readBytes64 :: ByteString -> DecodedToken (LongToken ByteString)
readBytes64 bs :: ByteString
bs = case Word64 -> Maybe Int
word64ToInt (ByteString -> Word64
eatTailWord64 ByteString
bs) of
Just n :: Int
n@(I# n# :: Int#
n#)
| Int
n Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
<= ByteString -> Int
BS.length ByteString
bs Int -> Int -> Int
forall a. Num a => a -> a -> a
- Int
hdrsz
-> Int -> LongToken ByteString -> DecodedToken (LongToken ByteString)
forall a. Int -> a -> DecodedToken a
DecodedToken (Int
nInt -> Int -> Int
forall a. Num a => a -> a -> a
+Int
hdrsz) (LongToken ByteString -> DecodedToken (LongToken ByteString))
-> LongToken ByteString -> DecodedToken (LongToken ByteString)
forall a b. (a -> b) -> a -> b
$ Bool -> ByteString -> LongToken ByteString
forall a. Bool -> a -> LongToken a
Fits (Int -> Int# -> Bool
isIntCanonical Int
hdrsz Int#
n#) (ByteString -> LongToken ByteString)
-> ByteString -> LongToken ByteString
forall a b. (a -> b) -> a -> b
$
Int -> ByteString -> ByteString
BS.unsafeTake Int
n (Int -> ByteString -> ByteString
BS.unsafeDrop Int
hdrsz ByteString
bs)
| Bool
otherwise -> Int -> LongToken ByteString -> DecodedToken (LongToken ByteString)
forall a. Int -> a -> DecodedToken a
DecodedToken Int
hdrsz (LongToken ByteString -> DecodedToken (LongToken ByteString))
-> LongToken ByteString -> DecodedToken (LongToken ByteString)
forall a b. (a -> b) -> a -> b
$ Bool -> Int -> LongToken ByteString
forall a. Bool -> Int -> LongToken a
TooLong (Int -> Int# -> Bool
isIntCanonical Int
hdrsz Int#
n#) Int
n
Nothing -> DecodedToken (LongToken ByteString)
forall a. DecodedToken a
DecodeFailure
where
hdrsz :: Int
hdrsz = 9
data BigIntToken a = BigIntToken Bool Integer
| BigUIntNeedBody Bool Int
| BigNIntNeedBody Bool Int
|
|
adjustContBigUIntNeedBody, adjustContBigNIntNeedBody
:: (Integer -> ST s (DecodeAction s a))
-> (ByteString -> ST s (DecodeAction s a))
adjustContBigUIntNeedBody :: (Integer -> ST s (DecodeAction s a))
-> ByteString -> ST s (DecodeAction s a)
adjustContBigUIntNeedBody k :: Integer -> ST s (DecodeAction s a)
k = \bs :: ByteString
bs -> Integer -> ST s (DecodeAction s a)
k (Integer -> ST s (DecodeAction s a))
-> Integer -> ST s (DecodeAction s a)
forall a b. (a -> b) -> a -> b
$! ByteString -> Integer
uintegerFromBytes ByteString
bs
adjustContBigNIntNeedBody :: (Integer -> ST s (DecodeAction s a))
-> ByteString -> ST s (DecodeAction s a)
adjustContBigNIntNeedBody k :: Integer -> ST s (DecodeAction s a)
k = \bs :: ByteString
bs -> Integer -> ST s (DecodeAction s a)
k (Integer -> ST s (DecodeAction s a))
-> Integer -> ST s (DecodeAction s a)
forall a b. (a -> b) -> a -> b
$! ByteString -> Integer
nintegerFromBytes ByteString
bs
adjustContCanonicalBigUIntNeedBody, adjustContCanonicalBigNIntNeedBody
:: (Integer -> ST s (DecodeAction s a))
-> (ByteString -> ST s (DecodeAction s a))
adjustContCanonicalBigUIntNeedBody :: (Integer -> ST s (DecodeAction s a))
-> ByteString -> ST s (DecodeAction s a)
adjustContCanonicalBigUIntNeedBody k :: Integer -> ST s (DecodeAction s a)
k = \bs :: ByteString
bs ->
if ByteString -> Bool
isBigIntRepCanonical ByteString
bs
then Integer -> ST s (DecodeAction s a)
k (Integer -> ST s (DecodeAction s a))
-> Integer -> ST s (DecodeAction s a)
forall a b. (a -> b) -> a -> b
$! ByteString -> Integer
uintegerFromBytes ByteString
bs
else DecodeAction s a -> ST s (DecodeAction s a)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (DecodeAction s a -> ST s (DecodeAction s a))
-> DecodeAction s a -> ST s (DecodeAction s a)
forall a b. (a -> b) -> a -> b
$! String -> DecodeAction s a
forall s a. String -> DecodeAction s a
D.Fail ("non-canonical integer")
adjustContCanonicalBigNIntNeedBody :: (Integer -> ST s (DecodeAction s a))
-> ByteString -> ST s (DecodeAction s a)
adjustContCanonicalBigNIntNeedBody k :: Integer -> ST s (DecodeAction s a)
k = \bs :: ByteString
bs ->
if ByteString -> Bool
isBigIntRepCanonical ByteString
bs
then Integer -> ST s (DecodeAction s a)
k (Integer -> ST s (DecodeAction s a))
-> Integer -> ST s (DecodeAction s a)
forall a b. (a -> b) -> a -> b
$! ByteString -> Integer
nintegerFromBytes ByteString
bs
else DecodeAction s a -> ST s (DecodeAction s a)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (DecodeAction s a -> ST s (DecodeAction s a))
-> DecodeAction s a -> ST s (DecodeAction s a)
forall a b. (a -> b) -> a -> b
$! String -> DecodeAction s a
forall s a. String -> DecodeAction s a
D.Fail ("non-canonical integer")
adjustContBigUIntNeedHeader, adjustContBigNIntNeedHeader
:: (Integer -> ST s (DecodeAction s a))
-> DecodeAction s a
k :: Integer -> ST s (DecodeAction s a)
k = (ByteString -> ST s (DecodeAction s a)) -> DecodeAction s a
forall s a.
(ByteString -> ST s (DecodeAction s a)) -> DecodeAction s a
ConsumeBytes (\bs :: ByteString
bs -> Integer -> ST s (DecodeAction s a)
k (Integer -> ST s (DecodeAction s a))
-> Integer -> ST s (DecodeAction s a)
forall a b. (a -> b) -> a -> b
$! ByteString -> Integer
uintegerFromBytes ByteString
bs)
k :: Integer -> ST s (DecodeAction s a)
k = (ByteString -> ST s (DecodeAction s a)) -> DecodeAction s a
forall s a.
(ByteString -> ST s (DecodeAction s a)) -> DecodeAction s a
ConsumeBytes (\bs :: ByteString
bs -> Integer -> ST s (DecodeAction s a)
k (Integer -> ST s (DecodeAction s a))
-> Integer -> ST s (DecodeAction s a)
forall a b. (a -> b) -> a -> b
$! ByteString -> Integer
nintegerFromBytes ByteString
bs)
adjustContCanonicalBigUIntNeedHeader, adjustContCanonicalBigNIntNeedHeader
:: (Integer -> ST s (DecodeAction s a))
-> DecodeAction s a
k :: Integer -> ST s (DecodeAction s a)
k = (ByteString -> ST s (DecodeAction s a)) -> DecodeAction s a
forall s a.
(ByteString -> ST s (DecodeAction s a)) -> DecodeAction s a
ConsumeBytesCanonical ((ByteString -> ST s (DecodeAction s a)) -> DecodeAction s a)
-> (ByteString -> ST s (DecodeAction s a)) -> DecodeAction s a
forall a b. (a -> b) -> a -> b
$ \bs :: ByteString
bs ->
if ByteString -> Bool
isBigIntRepCanonical ByteString
bs
then Integer -> ST s (DecodeAction s a)
k (Integer -> ST s (DecodeAction s a))
-> Integer -> ST s (DecodeAction s a)
forall a b. (a -> b) -> a -> b
$! ByteString -> Integer
uintegerFromBytes ByteString
bs
else DecodeAction s a -> ST s (DecodeAction s a)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (DecodeAction s a -> ST s (DecodeAction s a))
-> DecodeAction s a -> ST s (DecodeAction s a)
forall a b. (a -> b) -> a -> b
$! String -> DecodeAction s a
forall s a. String -> DecodeAction s a
D.Fail ("non-canonical integer")
k :: Integer -> ST s (DecodeAction s a)
k = (ByteString -> ST s (DecodeAction s a)) -> DecodeAction s a
forall s a.
(ByteString -> ST s (DecodeAction s a)) -> DecodeAction s a
ConsumeBytesCanonical ((ByteString -> ST s (DecodeAction s a)) -> DecodeAction s a)
-> (ByteString -> ST s (DecodeAction s a)) -> DecodeAction s a
forall a b. (a -> b) -> a -> b
$ \bs :: ByteString
bs ->
if ByteString -> Bool
isBigIntRepCanonical ByteString
bs
then Integer -> ST s (DecodeAction s a)
k (Integer -> ST s (DecodeAction s a))
-> Integer -> ST s (DecodeAction s a)
forall a b. (a -> b) -> a -> b
$! ByteString -> Integer
nintegerFromBytes ByteString
bs
else DecodeAction s a -> ST s (DecodeAction s a)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (DecodeAction s a -> ST s (DecodeAction s a))
-> DecodeAction s a -> ST s (DecodeAction s a)
forall a b. (a -> b) -> a -> b
$! String -> DecodeAction s a
forall s a. String -> DecodeAction s a
D.Fail ("non-canonical integer")
{-# INLINE readBigUInt #-}
readBigUInt :: ByteString -> DecodedToken (BigIntToken a)
readBigUInt :: ByteString -> DecodedToken (BigIntToken a)
readBigUInt bs :: ByteString
bs
| let bs' :: ByteString
bs' = ByteString -> ByteString
BS.unsafeTail ByteString
bs
, Bool -> Bool
not (ByteString -> Bool
BS.null ByteString
bs')
, let !hdr :: Word8
hdr = ByteString -> Word8
BS.unsafeHead ByteString
bs'
, ByteString -> Int
BS.length ByteString
bs' Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
>= Word8 -> Int
tokenSize Word8
hdr
= case Word8 -> ByteString -> DecodedToken (LongToken ByteString)
tryConsumeBytes Word8
hdr ByteString
bs' of
DecodeFailure -> DecodedToken (BigIntToken a)
forall a. DecodedToken a
DecodeFailure
DecodedToken sz :: Int
sz (Fits canonical :: Bool
canonical bstr :: ByteString
bstr) -> Int -> BigIntToken a -> DecodedToken (BigIntToken a)
forall a. Int -> a -> DecodedToken a
DecodedToken (1Int -> Int -> Int
forall a. Num a => a -> a -> a
+Int
sz)
(Bool -> Integer -> BigIntToken a
forall a. Bool -> Integer -> BigIntToken a
BigIntToken (Bool
canonical Bool -> Bool -> Bool
&& ByteString -> Bool
isBigIntRepCanonical ByteString
bstr)
(ByteString -> Integer
uintegerFromBytes ByteString
bstr))
DecodedToken sz :: Int
sz (TooLong canonical :: Bool
canonical len :: Int
len) ->
Int -> BigIntToken a -> DecodedToken (BigIntToken a)
forall a. Int -> a -> DecodedToken a
DecodedToken (1Int -> Int -> Int
forall a. Num a => a -> a -> a
+Int
sz) (Bool -> Int -> BigIntToken a
forall a. Bool -> Int -> BigIntToken a
BigUIntNeedBody Bool
canonical Int
len)
| Bool
otherwise
= Int -> BigIntToken a -> DecodedToken (BigIntToken a)
forall a. Int -> a -> DecodedToken a
DecodedToken 1 BigIntToken a
forall a. BigIntToken a
BigUIntNeedHeader
{-# INLINE readBigNInt #-}
readBigNInt :: ByteString -> DecodedToken (BigIntToken a)
readBigNInt :: ByteString -> DecodedToken (BigIntToken a)
readBigNInt bs :: ByteString
bs
| let bs' :: ByteString
bs' = ByteString -> ByteString
BS.unsafeTail ByteString
bs
, Bool -> Bool
not (ByteString -> Bool
BS.null ByteString
bs')
, let !hdr :: Word8
hdr = ByteString -> Word8
BS.unsafeHead ByteString
bs'
, ByteString -> Int
BS.length ByteString
bs' Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
>= Word8 -> Int
tokenSize Word8
hdr
= case Word8 -> ByteString -> DecodedToken (LongToken ByteString)
tryConsumeBytes Word8
hdr ByteString
bs' of
DecodeFailure -> DecodedToken (BigIntToken a)
forall a. DecodedToken a
DecodeFailure
DecodedToken sz :: Int
sz (Fits canonical :: Bool
canonical bstr :: ByteString
bstr) -> Int -> BigIntToken a -> DecodedToken (BigIntToken a)
forall a. Int -> a -> DecodedToken a
DecodedToken (1Int -> Int -> Int
forall a. Num a => a -> a -> a
+Int
sz)
(Bool -> Integer -> BigIntToken a
forall a. Bool -> Integer -> BigIntToken a
BigIntToken (Bool
canonical Bool -> Bool -> Bool
&& ByteString -> Bool
isBigIntRepCanonical ByteString
bstr)
(ByteString -> Integer
nintegerFromBytes ByteString
bstr))
DecodedToken sz :: Int
sz (TooLong canonical :: Bool
canonical len :: Int
len) ->
Int -> BigIntToken a -> DecodedToken (BigIntToken a)
forall a. Int -> a -> DecodedToken a
DecodedToken (1Int -> Int -> Int
forall a. Num a => a -> a -> a
+Int
sz) (Bool -> Int -> BigIntToken a
forall a. Bool -> Int -> BigIntToken a
BigNIntNeedBody Bool
canonical Int
len)
| Bool
otherwise
= Int -> BigIntToken a -> DecodedToken (BigIntToken a)
forall a. Int -> a -> DecodedToken a
DecodedToken 1 BigIntToken a
forall a. BigIntToken a
BigNIntNeedHeader
isBigIntRepCanonical :: ByteString -> Bool
isBigIntRepCanonical :: ByteString -> Bool
isBigIntRepCanonical bstr :: ByteString
bstr = ByteString -> Int
BS.length ByteString
bstr Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> 8 Bool -> Bool -> Bool
&& ByteString -> Word8
BS.unsafeHead ByteString
bstr Word8 -> Word8 -> Bool
forall a. Eq a => a -> a -> Bool
/= 0x00