<commit_before>%
% (c) The AQUA Project, Glasgow University, 1994-1998
%

\section[PrelAddr]{Module @PrelAddr@}

\begin{code}
{-# OPTIONS -fcompiling-prelude -fno-implicit-prelude #-}

module PrelAddr (
	  Addr(..)
	, nullAddr			-- :: Addr
	, plusAddr			-- :: Addr -> Int -> Addr
	, indexAddrOffAddr	        -- :: Addr -> Int -> Addr

	, Word(..)
	, wordToInt
	, intToWord

	, Word64(..)
	, Int64(..)
   ) where

import PrelGHC
import PrelBase

infixl 5 `plusAddr`
\end{code}

\begin{code}
data Addr = A# Addr# 	deriving (Eq, Ord)
data Word = W# Word# 	deriving (Eq, Ord)

nullAddr :: Addr
nullAddr = A# (int2Addr# 0#)

plusAddr :: Addr -> Int -> Addr
plusAddr (A# addr) (I# off) = A# (int2Addr# (addr2Int# addr +# off))

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#<commit_msg>[project @ 2000-04-12 15:32:11 by panne] Cleaned up Addr, AddrOff added<commit_after>%
% (c) The AQUA Project, Glasgow University, 1994-1998
%

\section[PrelAddr]{Module @PrelAddr@}

\begin{code}
{-# OPTIONS -fcompiling-prelude -fno-implicit-prelude #-}

module PrelAddr (
	  Addr(..)
	, AddrOff(..)
	, nullAddr		-- :: Addr
	, alignAddr		-- :: Addr -> Int -> Addr
	, plusAddr		-- :: Addr -> AddrOff -> Addr
	, minusAddr		-- :: Addr -> Addr -> AddrOff

	, indexAddrOffAddr	-- :: Addr -> Int -> Addr

	, Word(..)
	, wordToInt
	, intToWord

	, Word64(..)
	, Int64(..)
   ) where

import PrelGHC
import PrelBase

infixl 5 `plusAddr`, `minusAddr`
\end{code}

\begin{code}
data Addr = A# Addr# 	deriving (Eq, Ord)
data Word = W# Word# 	deriving (Eq, Ord)

newtype AddrOff = AddrOff# Int

nullAddr :: Addr
nullAddr = A# (int2Addr# 0#)

alignAddr :: Addr -> Int -> Addr
alignAddr addr@(A# a) (I# i)
  = case addr2Int# a	of { ai ->
    case remInt# ai i	of {
      0# -> addr;
      n  -> A# (int2Addr# (ai +# (i -# n))) }}

plusAddr :: Addr -> AddrOff -> Addr
plusAddr (A# addr) (AddrOff# (I# off)) = A# (int2Addr# (addr2Int# addr +# off))

minusAddr :: Addr -> Addr -> AddrOff
minusAddr (A# a1) (A# a2) = AddrOff# (I# (addr2Int# a1 -# addr2Int# a2))

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#
{'fraction_non_alphanumeric': 0.1667953667953668, 'fraction_numerical': 0.0305019305019305, 'mean_word_length': 3.2615131578947367, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 30, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5968641', 'n_tokens_mistral': 1149, 'n_tokens_neox': 1097, 'n_words': 299}