summaryrefslogtreecommitdiff
path: root/compiler/basicTypes
diff options
context:
space:
mode:
authorÖmer Sinan Ağacan <omeragacan@gmail.com>2019-08-05 20:44:33 +0300
committerMarge Bot <ben+marge-bot@smart-cactus.org>2019-08-06 20:26:32 -0400
commit6f116005a144b3f09381e0a5967a364eb57a5aa5 (patch)
treee6fa10c5f1f37790d15dff2b9dce7c700b26366a /compiler/basicTypes
parentc83e39bf91cfeb17a54ccfd5d01bfdfa1b4a72c9 (diff)
downloadhaskell-6f116005a144b3f09381e0a5967a364eb57a5aa5.tar.gz
Introduce a type for "platform word size", use it instead of Int
We introduce a PlatformWordSize type and use it in platformWordSize field. This removes to panic/error calls called when platform word size is not 32 or 64. We now check for this when reading the platform config.
Diffstat (limited to 'compiler/basicTypes')
-rw-r--r--compiler/basicTypes/Literal.hs10
1 files changed, 4 insertions, 6 deletions
diff --git a/compiler/basicTypes/Literal.hs b/compiler/basicTypes/Literal.hs
index abf74a7cbd..527435bfb2 100644
--- a/compiler/basicTypes/Literal.hs
+++ b/compiler/basicTypes/Literal.hs
@@ -309,13 +309,11 @@ Int/Word range.
wrapLitNumber :: DynFlags -> Literal -> Literal
wrapLitNumber dflags v@(LitNumber nt i t) = case nt of
LitNumInt -> case platformWordSize (targetPlatform dflags) of
- 4 -> LitNumber nt (toInteger (fromIntegral i :: Int32)) t
- 8 -> LitNumber nt (toInteger (fromIntegral i :: Int64)) t
- w -> panic ("wrapLitNumber: Unknown platformWordSize: " ++ show w)
+ PW4 -> LitNumber nt (toInteger (fromIntegral i :: Int32)) t
+ PW8 -> LitNumber nt (toInteger (fromIntegral i :: Int64)) t
LitNumWord -> case platformWordSize (targetPlatform dflags) of
- 4 -> LitNumber nt (toInteger (fromIntegral i :: Word32)) t
- 8 -> LitNumber nt (toInteger (fromIntegral i :: Word64)) t
- w -> panic ("wrapLitNumber: Unknown platformWordSize: " ++ show w)
+ PW4 -> LitNumber nt (toInteger (fromIntegral i :: Word32)) t
+ PW8 -> LitNumber nt (toInteger (fromIntegral i :: Word64)) t
LitNumInt64 -> LitNumber nt (toInteger (fromIntegral i :: Int64)) t
LitNumWord64 -> LitNumber nt (toInteger (fromIntegral i :: Word64)) t
LitNumInteger -> v