[project @ 2000-04-10 16:02:58 by simonpj]
[ghc-hetmet.git] / ghc / lib / std / PrelAddr.lhs
index d7febe7..8a0ba32 100644 (file)
@@ -5,7 +5,7 @@
 \section[PrelAddr]{Module @PrelAddr@}
 
 \begin{code}
-{-# OPTIONS -fno-implicit-prelude #-}
+{-# OPTIONS -fcompiling-prelude -fno-implicit-prelude #-}
 
 module PrelAddr (
          Addr(..)
@@ -13,29 +13,56 @@ module PrelAddr (
        , plusAddr                      -- :: Addr -> Int -> Addr
        , indexAddrOffAddr              -- :: Addr -> Int -> Addr
 
+       , Word(..)
+       , wordToInt
+       , intToWord
+
+       , Word64(..)
+       , Int64(..)
    ) where
 
 import PrelGHC
 import PrelBase
-import PrelST
-import PrelCCall
+
+infixl 5 `plusAddr`
 \end{code}
 
 \begin{code}
 data Addr = A# Addr#   deriving (Eq, Ord)
+data Word = W# Word#   deriving (Eq, Ord)
 
-instance Show Addr where
-   showsPrec p (A# a) = showsPrec p (I# (addr2Int# a))
-
-nullAddr = ``NULL'' :: Addr
+nullAddr :: Addr
+nullAddr = A# (int2Addr# 0#)
 
 plusAddr :: Addr -> Int -> Addr
 plusAddr (A# addr) (I# off) = A# (int2Addr# (addr2Int# addr +# off))
 
 instance CCallable Addr
-instance CCallable Addr#
 instance CReturnable Addr
 
+instance CCallable Word
+instance CReturnable Word
+
+wordToInt :: Word -> Int
+wordToInt (W# w#) = I# (word2Int# w#)
+
+intToWord :: Int -> Word
+intToWord (I# i#) = W# (int2Word# i#)
+
+#if WORD_SIZE_IN_BYTES == 8
+data Word64 = W64# Word#
+data Int64  = I64# Int#
+#else
+data Word64 = W64# Word64# --deriving (Eq, Ord) -- Glasgow extension
+data Int64  = I64# Int64#  --deriving (Eq, Ord) -- Glasgow extension
+#endif
+
+instance CCallable   Word64
+instance CReturnable Word64
+
+instance CCallable   Int64
+instance CReturnable Int64
+
 indexAddrOffAddr   :: Addr -> Int -> Addr
 indexAddrOffAddr (A# addr#) n
   = case n                             of { I# n# ->