Skip to content

Commit 9de5238

Browse files
committed
Has Call Stack
1 parent 3e4d369 commit 9de5238

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

src/Data/BitCode/Writer/Monad.hs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -259,20 +259,20 @@ withOffset n x = Bitstream $ do
259259
put $ BitstreamState ss' (pos + pos')
260260
return r
261261

262-
loc :: Bitstream Position
262+
loc :: HasCallStack => Bitstream Position
263263
loc = Bitstream $ gets bssPosition
264264

265-
locBytes :: Bitstream Word32
265+
locBytes :: HasCallStack => Bitstream Word32
266266
locBytes = Bitstream $ gets $ fromIntegral . (`div` 8) . bssPosition
267267

268-
locWords :: Bitstream Word32
268+
locWords :: HasCallStack => Bitstream Word32
269269
locWords = Bitstream $ gets $ fromIntegral . (`div` 32) . bssPosition
270270

271-
emitBit :: Bool -> Bitstream ()
272-
emitBit True = bitstream [] (Buff 1 0b00000001) 1
273-
emitBit False = bitstream [] (Buff 1 0b00000000) 1
271+
emitBit :: HasCallStack => Bool -> Bitstream ()
272+
emitBit True = bitstream [] (Buff 1 (setBit zeroBits bSize)) 1
273+
emitBit False = bitstream [] (Buff 1 0) 1
274274

275-
emitBits :: Int -> BType -> Bitstream ()
275+
emitBits :: HasCallStack => Int -> BType -> Bitstream ()
276276
emitBits 0 _ = pure ()
277277
emitBits n b | n < 8 = do
278278
-- traceM $ "emitting " ++ show n ++ " bits; value = " ++ show b
@@ -345,22 +345,22 @@ emitVBR n w = do
345345
then emitBit False
346346
else emitBit True >> emitVBR n tail
347347

348-
emitChar6 :: Char -> Bitstream ()
348+
emitChar6 :: HasCallStack => Char -> Bitstream ()
349349
emitChar6 '_' = emitBits 6 63
350350
emitChar6 '.' = emitBits 6 62
351351
emitChar6 c | 'a' <= c && c <= 'z' = emitBits 6 . fromIntegral $ (fromEnum c - fromEnum 'a')
352352
| 'A' <= c && c <= 'Z' = emitBits 6 . fromIntegral $ (fromEnum c - fromEnum 'A') + 26
353353
| '0' <= c && c <= '9' = emitBits 6 . fromIntegral $ (fromEnum c - fromEnum '0') + 52
354354
| otherwise = fail $ "char '" ++ c:"' not in [a-zA-Z0-9._]"
355355

356-
alignWord8 :: Bitstream ()
356+
alignWord8 :: HasCallStack => Bitstream ()
357357
alignWord8 = do
358358
bits <- (`mod` 8) <$> loc
359359
case bits of
360360
0 -> pure ()
361361
x -> emitBits (8 - x) 0
362362

363-
alignWord32 :: Bitstream ()
363+
alignWord32 :: HasCallStack => Bitstream ()
364364
alignWord32 = flip mod 32 <$> loc >>= \case
365365
0 -> pure ()
366366
x | 32 - x < 8 -> emitBits (32 - x) 0

0 commit comments

Comments
 (0)