From: sof Date: Mon, 20 Jul 1998 10:00:36 +0000 (+0000) Subject: [project @ 1998-07-20 10:00:34 by sof] X-Git-Tag: Approx_2487_patches~511 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=71a84ae8038af796185fab59176f6066a1f45098;p=ghc-hetmet.git [project @ 1998-07-20 10:00:34 by sof] non-standard extensions: intToWord and wordToInt coercion functions --- diff --git a/ghc/lib/exts/Int.lhs b/ghc/lib/exts/Int.lhs index 88d6b44..138d668 100644 --- a/ghc/lib/exts/Int.lhs +++ b/ghc/lib/exts/Int.lhs @@ -31,7 +31,8 @@ module Int -- plus Eq, Ord, Num, Bounded, Real, Integral, Ix, Enum, Read, -- Show and Bits instances for each of Int8, Int16, Int32 and Int64 - -- The "official" place to get these from is Addr. + -- The "official" place to get these from is Addr, importing + -- them from Int is a non-standard thing to do. , indexInt8OffAddr , indexInt16OffAddr , indexInt32OffAddr @@ -51,6 +52,9 @@ module Int , sizeofInt16 , sizeofInt32 , sizeofInt64 + + -- non-standard, GHC specific + , intToWord ) where @@ -88,6 +92,10 @@ int16ToInt8 (I16# x) = I8# x int16ToInt32 (I16# x) = I32# x int32ToInt8 (I32# x) = I8# x int32ToInt16 (I32# x) = I16# x + +--GHC specific +intToWord :: Int -> Word +intToWord (I# i#) = W# (int2Word# i#) \end{code} \subsection[Int8]{The @Int8@ interface} diff --git a/ghc/lib/exts/Word.lhs b/ghc/lib/exts/Word.lhs index 5a06a81..75a4749 100644 --- a/ghc/lib/exts/Word.lhs +++ b/ghc/lib/exts/Word.lhs @@ -66,6 +66,9 @@ module Word , sizeofWord32 , sizeofWord64 + -- non-standard, GHC specific + , wordToInt + ) where import GlaExts @@ -97,6 +100,9 @@ intToWord32 (I# x) = W32# ((int2Word# x) `and#` (case (maxBound::Word32) of W3 --intToWord32 (I# x) = W32# (int2Word# x) word32ToInt (W32# x) = I# (word2Int# x) +wordToInt :: Word -> Int +wordToInt (W# w#) = I# (word2Int# w#) + \end{code} \subsection[Word8]{The @Word8@ interface}