[commit: ghc] master: Remove the Target* types from HaskellConstants (f21dabc)

Ian Lynagh <[email protected]>
Newsgroups gmane.comp.lang.haskell.cvs.ghc
Message-ID <[email protected]>
Repository : ssh://darcs.haskell.org//srv/darcs/ghc

On branch  : master

http://hackage.haskell.org/trac/ghc/changeset/f21dabc31b1125692d804f93ef470fe555f846ad

>---------------------------------------------------------------

commit f21dabc31b1125692d804f93ef470fe555f846ad
Author: Ian Lynagh <[email protected]>
Date:   Mon Sep 17 18:06:54 2012 +0100

    Remove the Target* types from HaskellConstants

>---------------------------------------------------------------

 compiler/prelude/PrelRules.lhs |   20 +++++++++++++-------
 includes/HaskellConstants.hs   |   13 -------------
 2 files changed, 13 insertions(+), 20 deletions(-)

diff --git a/compiler/prelude/PrelRules.lhs b/compiler/prelude/PrelRules.lhs
index 0d4229f..3f12365 100644
--- a/compiler/prelude/PrelRules.lhs
+++ b/compiler/prelude/PrelRules.lhs
@@ -43,15 +43,15 @@ import Name        ( Name, nameOccName )
 import Outputable
 import FastString
 import StaticFlags ( opt_SimplExcessPrecision )
-import Constants
 import BasicTypes
 import DynFlags
+import Platform
 import Util
 
 import Control.Monad
 import Data.Bits as Bits
-import Data.Int    ( Int64 )
-import Data.Word   ( Word, Word64 )
+import Data.Int
+import Data.Word
 \end{code}
 
 
@@ -424,12 +424,18 @@ isMaxBound _              = False
 -- would yield a warning. Instead we simply squash the value into the
 -- *target* Int/Word range.
 intResult :: DynFlags -> Integer -> Maybe CoreExpr
-intResult dflags result
-  = Just (mkIntVal dflags (toInteger (fromInteger result :: TargetInt)))
+intResult dflags result = Just (mkIntVal dflags result')
+    where result' = case platformWordSize (targetPlatform dflags) of
+                    4 -> toInteger (fromInteger result :: Int32)
+                    8 -> toInteger (fromInteger result :: Int64)
+                    w -> panic ("intResult: Unknown platformWordSize: " ++ show w)
 
 wordResult :: DynFlags -> Integer -> Maybe CoreExpr
-wordResult dflags result
-  = Just (mkWordVal dflags (toInteger (fromInteger result :: TargetWord)))
+wordResult dflags result = Just (mkWordVal dflags result')
+    where result' = case platformWordSize (targetPlatform dflags) of
+                    4 -> toInteger (fromInteger result :: Word32)
+                    8 -> toInteger (fromInteger result :: Word64)
+                    w -> panic ("wordResult: Unknown platformWordSize: " ++ show w)
 
 inversePrimOp :: PrimOp -> RuleM CoreExpr
 inversePrimOp primop = do
diff --git a/includes/HaskellConstants.hs b/includes/HaskellConstants.hs
index bf0e99e..5b7e3dd 100644
--- a/includes/HaskellConstants.hs
+++ b/includes/HaskellConstants.hs
@@ -1,5 +1,4 @@
 
-import Data.Word
 import Data.Int
 
 -- This magical #include brings in all the everybody-knows-these magic
@@ -36,18 +35,6 @@ mAX_CONTEXT_REDUCTION_DEPTH = 200
 wORD64_SIZE :: Int
 wORD64_SIZE = 8
 
--- Define a fixed-range integral type equivalent to the target Int/Word
-
-#if SIZEOF_HSWORD == 4
-type TargetInt  = Int32
-type TargetWord = Word32
-#elif SIZEOF_HSWORD == 8
-type TargetInt  = Int64
-type TargetWord = Word64
-#else
-#error unknown SIZEOF_HSWORD
-#endif
-
 tARGET_MAX_CHAR :: Int
 tARGET_MAX_CHAR = 0x10ffff
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.