X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2Futils%2FBinary.hs;h=2ebc856f584c6d1b384b48e37e12d7135a98574c;hb=e949a913adbc1178a799594306954f24957da5ff;hp=ad048b6674d41ad9c4734cba37361a5d4c84511d;hpb=5cc2c61d5f286fe327419ea5b4dfc31744585f3a;p=ghc-hetmet.git diff --git a/compiler/utils/Binary.hs b/compiler/utils/Binary.hs index ad048b6..2ebc856 100644 --- a/compiler/utils/Binary.hs +++ b/compiler/utils/Binary.hs @@ -61,6 +61,7 @@ import Unique import Panic import UniqFM import FastMutInt +import Util import Foreign import Data.Array.IO @@ -234,9 +235,8 @@ expandBin (BinMem _ _ sz_r arr_r) off = do | i <- [ 0 .. sz-1 ] ] writeFastMutInt sz_r sz' writeIORef arr_r arr' -#ifdef DEBUG - hPutStrLn stderr ("Binary: expanding to size: " ++ show sz') -#endif + when debugIsOn $ + hPutStrLn stderr ("Binary: expanding to size: " ++ show sz') return () expandBin (BinIO _ _ _) _ = return () -- no need to expand a file, we'll assume they expand by themselves. @@ -467,6 +467,14 @@ instance (Binary a, Binary b) => Binary (Either a b) where -- yes, we need Binary Integer and Binary Rational in basicTypes/Literal.lhs instance Binary Integer where + -- XXX This is hideous + put_ bh i = put_ bh (show i) + get bh = do str <- get bh + case reads str of + [(i, "")] -> return i + _ -> fail ("Binary Integer: got " ++ show str) + + {- put_ bh (S# i#) = do putByte bh 0; put_ bh (I# i#) put_ bh (J# s# a#) = do putByte bh 1 @@ -484,6 +492,7 @@ instance Binary Integer where sz <- get bh (BA a#) <- getByteArray bh sz return (J# s# a#) +-} -- As for the rest of this code, even though this module -- exports it, it doesn't seem to be used anywhere else