Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Alex D
GHC
Commits
09dc0da9
Commit
09dc0da9
authored
Jan 19, 2009
by
dreixel
Browse files
#2875: Correct SYB's representation of Char
parent
fa1e4ffe
Changes
1
Hide whitespace changes
Inline
Side-by-side
compiler/utils/Serialized.hs
View file @
09dc0da9
...
...
@@ -87,7 +87,12 @@ 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
#
if
__GLASGOW_HASKELL__
<
611
serializeConstr
(
StringConstr
s
)
=
serializeWord8
4
.
serializeString
s
#
else
serializeConstr
(
CharConstr
c
)
=
serializeWord8
4
.
serializeChar
c
#
endif
deserializeConstr
::
[
Word8
]
->
(
ConstrRep
->
[
Word8
]
->
a
)
->
a
deserializeConstr
bytes
k
=
deserializeWord8
bytes
$
\
constr_ix
bytes
->
...
...
@@ -95,7 +100,11 @@ 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
)
#
if
__GLASGOW_HASKELL__
>=
611
4
->
deserializeChar
bytes
$
\
c
->
k
(
CharConstr
c
)
#
else
4
->
deserializeString
bytes
$
\
s
->
k
(
StringConstr
s
)
#
endif
x
->
error
$
"deserializeConstr: unrecognised serialized constructor type "
++
show
x
++
" in context "
++
show
bytes
...
...
@@ -154,6 +163,15 @@ deserializeInteger :: [Word8] -> (Integer -> [Word8] -> a) -> a
deserializeInteger
bytes
k
=
deserializeString
bytes
(
k
.
read
)
#
if
__GLASGOW_HASKELL__
>=
611
serializeChar
::
Char
->
[
Word8
]
->
[
Word8
]
serializeChar
=
serializeString
.
show
deserializeChar
::
[
Word8
]
->
(
Char
->
[
Word8
]
->
a
)
->
a
deserializeChar
bytes
k
=
deserializeString
bytes
(
k
.
read
)
#
endif
serializeString
::
String
->
[
Word8
]
->
[
Word8
]
serializeString
=
serializeList
serializeEnum
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment