Characters bigger than '\xff' should be represented as int
literals in External Core. (This was originally fixed five years ago
and broken again four and a half years ago...)
import IO
import FastString
import IO
import FastString
emitExternalCore :: DynFlags -> NameSet -> CgGuts -> IO ()
emitExternalCore dflags exports cg_guts
| opt_EmitExternalCore
emitExternalCore :: DynFlags -> NameSet -> CgGuts -> IO ()
emitExternalCore dflags exports cg_guts
| opt_EmitExternalCore
make_lit :: Literal -> C.Lit
make_lit l =
case l of
make_lit :: Literal -> C.Lit
make_lit l =
case l of
- MachChar i -> C.Lchar i t
+ -- Note that we need to check whether the character is "big".
+ -- External Core only allows character literals up to '\xff'.
+ MachChar i | i <= chr 0xff -> C.Lchar i t
+ -- For a character bigger than 0xff, we represent it in ext-core
+ -- as an int lit with a char type.
+ MachChar i -> C.Lint (fromIntegral $ ord i) t
MachStr s -> C.Lstring (unpackFS s) t
MachNullAddr -> C.Lint 0 t
MachInt i -> C.Lint i t
MachStr s -> C.Lstring (unpackFS s) t
MachNullAddr -> C.Lint 0 t
MachInt i -> C.Lint i t