Skip to content
Snippets Groups Projects
Commit 680c1a9e authored by Ian Lynagh's avatar Ian Lynagh
Browse files

Define mkInteger

Now used by GHC to generate Integer literals.
parent 9935359f
No related merge requests found
......@@ -18,7 +18,7 @@
#include "MachDeps.h"
module GHC.Integer (
Integer,
Integer, mkInteger,
smallInteger, wordToInteger, integerToWord, integerToInt,
#if WORD_SIZE_IN_BITS < 64
integerToWord64, word64ToInteger,
......
......@@ -72,6 +72,16 @@ data Integer
= S# Int# -- small integers
| J# Int# ByteArray# -- large integers
mkInteger :: Bool -- non-negative?
-> [Int] -- absolute value in 31 bit chunks, least significant first
-- ideally these would be Words rather than Ints, but
-- we don't have Word available at the moment.
-> Integer
mkInteger nonNegative is = let abs = f is
in if nonNegative then abs else negateInteger abs
where f [] = S# 0#
f (I# i : is') = S# i `orInteger` shiftLInteger (f is') 31#
{-# NOINLINE smallInteger #-}
smallInteger :: Int# -> Integer
smallInteger i = S# i
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment