From: sof Date: Wed, 8 Jul 1998 10:00:17 +0000 (+0000) Subject: [project @ 1998-07-08 10:00:17 by sof] X-Git-Tag: Approx_2487_patches~527 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=ef6dd2be061f3204b535f7dc3c2679e0573b3724;p=ghc-hetmet.git [project @ 1998-07-08 10:00:17 by sof] Int <-> Addr (non-std) conversions --- diff --git a/ghc/lib/exts/Addr.lhs b/ghc/lib/exts/Addr.lhs index b9b789c..19636d7 100644 --- a/ghc/lib/exts/Addr.lhs +++ b/ghc/lib/exts/Addr.lhs @@ -10,6 +10,10 @@ module Addr , module Word , module Int , module Addr + + -- (non-standard) coercions + , addrToInt -- :: Addr -> Int + , intToAddr -- :: Int -> Addr ) where @@ -34,6 +38,16 @@ import Int ( indexInt8OffAddr, indexInt16OffAddr \end{code} +Coercing between machine ints and words + +\begin{code} +addrToInt :: Addr -> Int +addrToInt (A# a#) = I# (addr2Int# a#) + +intToAddr :: Int -> Addr +intToAddr (I# i#) = A# (int2Addr# i#) +\end{code} + Indexing immutable memory: \begin{code}