Commit 1631a17d authored by Simon Marlow's avatar Simon Marlow

Use explicit Word32/Int32 in place of Int in the on-disk .hi file

For: FastStrings, Names, and Bin values.  This makes .hi files smaller
on 64-bit platforms, while also making the format a bit more robust.
parent 1118ecad
......@@ -83,6 +83,7 @@ import FastString
import Outputable
import Data.Array
import Data.Word ( Word32 )
\end{code}
%************************************************************************
......@@ -368,7 +369,7 @@ instance Binary Name where
get bh = do
i <- get bh
return $! (ud_symtab (getUserData bh) ! i)
return $! (ud_symtab (getUserData bh) ! fromIntegral (i::Word32))
\end{code}
%************************************************************************
......
......@@ -287,13 +287,13 @@ putName BinSymbolTable{
= do
symtab_map <- readIORef symtab_map_ref
case lookupUFM symtab_map name of
Just (off,_) -> put_ bh off
Just (off,_) -> put_ bh (fromIntegral off :: Word32)
Nothing -> do
off <- readFastMutInt symtab_next
writeFastMutInt symtab_next (off+1)
writeIORef symtab_map_ref
$! addToUFM symtab_map name (off,name)
put_ bh off
put_ bh (fromIntegral off :: Word32)
data BinSymbolTable = BinSymbolTable {
......@@ -310,10 +310,10 @@ putFastString BinDictionary { bin_dict_next = j_r,
out <- readIORef out_r
let uniq = getUnique f
case lookupUFM out uniq of
Just (j, _) -> put_ bh j
Just (j, _) -> put_ bh (fromIntegral j :: Word32)
Nothing -> do
j <- readFastMutInt j_r
put_ bh j
put_ bh (fromIntegral j :: Word32)
writeFastMutInt j_r (j + 1)
writeIORef out_r $! addToUFM out uniq (j, f)
......
......@@ -551,8 +551,8 @@ instance (Integral a, Binary a) => Binary (Ratio a) where
#endif
instance Binary (Bin a) where
put_ bh (BinPtr i) = put_ bh i
get bh = do i <- get bh; return (BinPtr i)
put_ bh (BinPtr i) = put_ bh (fromIntegral i :: Int32)
get bh = do i <- get bh; return (BinPtr (fromIntegral (i :: Int32)))
-- -----------------------------------------------------------------------------
-- Instances for Data.Typeable stuff
......@@ -707,7 +707,7 @@ instance Binary FastString where
get bh = do
j <- get bh
return $! (ud_dict (getUserData bh) ! j)
return $! (ud_dict (getUserData bh) ! (fromIntegral (j :: Word32)))
-- Here to avoid loop
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment