projects
/
ghc-hetmet.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Major refactoring of the type inference engine
[ghc-hetmet.git]
/
compiler
/
utils
/
Serialized.hs
diff --git
a/compiler/utils/Serialized.hs
b/compiler/utils/Serialized.hs
index
82cc065
..
26cca6c
100644
(file)
--- a/
compiler/utils/Serialized.hs
+++ b/
compiler/utils/Serialized.hs
@@
-24,12
+24,7
@@
import Util
import Data.Bits
import Data.Word ( Word8 )
import Data.Bits
import Data.Word ( Word8 )
-#if __GLASGOW_HASKELL__ > 609
import Data.Data
import Data.Data
-#else
-import Data.Generics
-#endif
-import Data.Typeable
-- | Represents a serialized value of a particular type. Attempts can be made to deserialize it at certain types
-- | Represents a serialized value of a particular type. Attempts can be made to deserialize it at certain types
@@
-87,7
+82,8
@@
serializeConstr :: ConstrRep -> [Word8] -> [Word8]
serializeConstr (AlgConstr ix) = serializeWord8 1 . serializeInt ix
serializeConstr (IntConstr i) = serializeWord8 2 . serializeInteger i
serializeConstr (FloatConstr r) = serializeWord8 3 . serializeRational r
serializeConstr (AlgConstr ix) = serializeWord8 1 . serializeInt ix
serializeConstr (IntConstr i) = serializeWord8 2 . serializeInteger i
serializeConstr (FloatConstr r) = serializeWord8 3 . serializeRational r
-serializeConstr (StringConstr s) = serializeWord8 4 . serializeString s
+serializeConstr (CharConstr c) = serializeWord8 4 . serializeChar c
+
deserializeConstr :: [Word8] -> (ConstrRep -> [Word8] -> a) -> a
deserializeConstr bytes k = deserializeWord8 bytes $ \constr_ix bytes ->
deserializeConstr :: [Word8] -> (ConstrRep -> [Word8] -> a) -> a
deserializeConstr bytes k = deserializeWord8 bytes $ \constr_ix bytes ->
@@
-95,7
+91,7
@@
deserializeConstr bytes k = deserializeWord8 bytes $ \constr_ix bytes ->
1 -> deserializeInt bytes $ \ix -> k (AlgConstr ix)
2 -> deserializeInteger bytes $ \i -> k (IntConstr i)
3 -> deserializeRational bytes $ \r -> k (FloatConstr r)
1 -> deserializeInt bytes $ \ix -> k (AlgConstr ix)
2 -> deserializeInteger bytes $ \i -> k (IntConstr i)
3 -> deserializeRational bytes $ \r -> k (FloatConstr r)
- 4 -> deserializeString bytes $ \s -> k (StringConstr s)
+ 4 -> deserializeChar bytes $ \c -> k (CharConstr c)
x -> error $ "deserializeConstr: unrecognised serialized constructor type " ++ show x ++ " in context " ++ show bytes
x -> error $ "deserializeConstr: unrecognised serialized constructor type " ++ show x ++ " in context " ++ show bytes
@@
-154,6
+150,13
@@
deserializeInteger :: [Word8] -> (Integer -> [Word8] -> a) -> a
deserializeInteger bytes k = deserializeString bytes (k . read)
deserializeInteger bytes k = deserializeString bytes (k . read)
+serializeChar :: Char -> [Word8] -> [Word8]
+serializeChar = serializeString . show
+
+deserializeChar :: [Word8] -> (Char -> [Word8] -> a) -> a
+deserializeChar bytes k = deserializeString bytes (k . read)
+
+
serializeString :: String -> [Word8] -> [Word8]
serializeString = serializeList serializeEnum
serializeString :: String -> [Word8] -> [Word8]
serializeString = serializeList serializeEnum