[MLton-commit] r4358
Matthew Fluet
MLton@mlton.org
Tue, 14 Feb 2006 19:30:31 -0800
Almost done refactoring integer and word
----------------------------------------------------------------------
U mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/build/sources.mlb
A mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/integer/int-global.sml
U mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/integer/int-inf.sig
U mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/integer/int-inf0.sml
U mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/integer/int.sml
U mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/integer/int0.sml
U mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/integer/integer.sig
A mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/integer/word-global.sml
U mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/integer/word.sig
U mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/integer/word.sml
U mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/integer/word0.sml
U mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/primitive/prim-int.sml
U mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/primitive/prim-word.sml
U mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/primitive/primitive.mlb
U mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/text/char.sml
U mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/text/char0.sml
U mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/text/string.sml
----------------------------------------------------------------------
Modified: mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/build/sources.mlb
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/build/sources.mlb 2006-02-14 03:58:19 UTC (rev 4357)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/build/sources.mlb 2006-02-15 03:30:28 UTC (rev 4358)
@@ -89,20 +89,31 @@
../general/bool.sig
../general/bool.sml
../integer/integer.sig
+ ../integer/int.sml
+ ../integer/word.sig
+ ../integer/word.sml
+ ../integer/int-inf.sig
(*
- ../../integer/int.sml
- ../../text/char.sig
- ../../text/char.sml
- ../../text/substring.sig
- ../../text/substring.sml
- ../../text/string.sig
- ../../text/string.sml
+ ../integer/int-inf.sml
+ local in ann "forceUsed" in
+ ../config/default/$(DEFAULT_INT)
+ ../config/default/$(DEFAULT_WORD)
+ ../config/default/large-int.sml
+ ../config/default/large-word.sml
+ end end
+ ../integer/int-global.sml
+ ../integer/word-global.sml
+ ../text/char.sig
+ ../text/char.sml
+ ../text/substring.sig
+ ../text/substring.sml
+ ../text/string.sig
+ ../text/string.sml
+*)
+
+(*
../../misc/C.sig
../../misc/C.sml
- ../../integer/word.sig
- ../../integer/word.sml
- ../../integer/int-inf.sig
- ../../integer/int-inf.sml
../../real/IEEE-real.sig
../../real/IEEE-real.sml
../../real/math.sig
Copied: mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/integer/int-global.sml (from rev 4347, mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/integer/int.sml)
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/integer/int.sml 2006-02-05 14:22:33 UTC (rev 4347)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/integer/int-global.sml 2006-02-15 03:30:28 UTC (rev 4358)
@@ -0,0 +1,10 @@
+(* Copyright (C) 1999-2005 Henry Cejtin, Matthew Fluet, Suresh
+ * Jagannathan, and Stephen Weeks.
+ * Copyright (C) 1997-2000 NEC Research Institute.
+ *
+ * MLton is released under a BSD-style license.
+ * See the file MLton-LICENSE for details.
+ *)
+
+structure IntGlobal: INTEGER_GLOBAL = Int
+open IntGlobal
Modified: mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/integer/int-inf.sig
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/integer/int-inf.sig 2006-02-14 03:58:19 UTC (rev 4357)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/integer/int-inf.sig 2006-02-15 03:30:28 UTC (rev 4358)
@@ -11,20 +11,21 @@
val andb: int * int -> int
val notb: int -> int
val << : int * Word.word -> int
- val ~>> : int * Word.word -> int
+ val ~>> : int * Word.word -> int
end
signature INT_INF_EXTRA =
sig
include INT_INF
+ structure BigWord : WORD
+ structure SmallInt : INTEGER
+
val areSmall: int * int -> bool
- val fromInt64: Int64.int -> int
val gcd: int * int -> int
val isSmall: int -> bool
datatype rep =
- Big of Word.word Vector.vector
- | Small of Int.int
+ Big of BigWord.word Vector.vector
+ | Small of SmallInt.int
val rep: int -> rep
- val toInt64: int -> Int64.int
end
Modified: mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/integer/int-inf0.sml
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/integer/int-inf0.sml 2006-02-14 03:58:19 UTC (rev 4357)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/integer/int-inf0.sml 2006-02-15 03:30:28 UTC (rev 4358)
@@ -47,6 +47,10 @@
val compare: int * int -> Primitive.Order.order
val min: int * int -> int
val max: int * int -> int
+ val ltu: int * int -> bool
+ val leu: int * int -> bool
+ val gtu: int * int -> bool
+ val geu: int * int -> bool
val andb: int * int -> int
val << : int * Primitive.Word32.word -> int
@@ -242,16 +246,16 @@
local
fun 'a make {toMPLimb: 'a -> MPLimb.word,
toObjptrWord: 'a -> ObjptrWord.word,
- other : {wordSize': Int32.int,
+ other : {wordSize: Int32.int,
zero: 'a,
eq: 'a * 'a -> bool,
rshift: 'a * Word32.word -> 'a}}
(isneg, w) =
- if Int32.> (ObjptrWord.wordSize', #wordSize' other)
+ if Int32.> (ObjptrWord.wordSize, #wordSize other)
orelse let
val upperBits =
(#rshift other)
- (w, Word32.- (ObjptrWord.wordSizeWord', 0w2))
+ (w, Word32.- (ObjptrWord.wordSizeWord, 0w2))
in
(#eq other) (upperBits, #zero other)
end
@@ -270,7 +274,7 @@
val limb = toMPLimb w
val w =
(#rshift other)
- (w, MPLimb.wordSizeWord')
+ (w, MPLimb.wordSizeWord)
in
loop (w, S.+ (i, 1), (i, limb) :: acc)
end
@@ -290,7 +294,7 @@
val fromWordAux8 =
make {toMPLimb = MPLimb.fromWord8,
toObjptrWord = ObjptrWord.fromWord8,
- other = {wordSize' = Word8.wordSize',
+ other = {wordSize = Word8.wordSize,
zero = Word8.zero,
eq = ((op =) : Word8.word * Word8.word -> bool),
rshift = Word8.>>}}
@@ -308,7 +312,7 @@
val fromWordAux16 =
make {toMPLimb = MPLimb.fromWord16,
toObjptrWord = ObjptrWord.fromWord16,
- other = {wordSize' = Word16.wordSize',
+ other = {wordSize = Word16.wordSize,
zero = Word16.zero,
eq = ((op =) : Word16.word * Word16.word -> bool),
rshift = Word16.>>}}
@@ -325,7 +329,7 @@
val fromWordAux32 =
make {toMPLimb = MPLimb.fromWord32,
toObjptrWord = ObjptrWord.fromWord32,
- other = {wordSize' = Word32.wordSize',
+ other = {wordSize = Word32.wordSize,
zero = Word32.zero,
eq = ((op =) : Word32.word * Word32.word -> bool),
rshift = Word32.>>}}
@@ -342,7 +346,7 @@
val fromWordAux64 =
make {toMPLimb = MPLimb.fromWord64,
toObjptrWord = ObjptrWord.fromWord64,
- other = {wordSize' = Word64.wordSize',
+ other = {wordSize = Word64.wordSize,
zero = Word64.zero,
eq = ((op =) : Word64.word * Word64.word -> bool),
rshift = Word64.>>}}
@@ -377,8 +381,8 @@
Big of bool * bool * 'a
| Small of ObjptrWord.word
fun 'a make {fromMPLimb: MPLimb.word -> 'a,
- other : {wordSize': Int32.int,
- wordSizeWord': Word32.word,
+ other : {wordSize: Int32.int,
+ wordSizeWord: Word32.word,
zero: 'a,
lshift: 'a * Word32.word -> 'a,
orb: 'a * 'a -> 'a}} i =
@@ -389,22 +393,22 @@
val n = V.length v
val isneg = V.subUnsafe (v, 0) <> 0w0
in
- if Int32.>= (MPLimb.wordSize', #wordSize' other)
+ if Int32.>= (MPLimb.wordSize, #wordSize other)
then let
val limbsPer = 1
val limb = V.subUnsafe (v, 1)
val extra =
S.> (n, S.+ (limbsPer, 1))
orelse
- (MPLimb.>> (limb, #wordSizeWord' other)) <> 0w0
+ (MPLimb.>> (limb, #wordSizeWord other)) <> 0w0
val ans = fromMPLimb limb
in
Big (isneg, extra, ans)
end
else let
val limbsPer =
- S.fromInt32 (Int32.quot (#wordSize' other,
- MPLimb.wordSize'))
+ S.fromInt32 (Int32.quot (#wordSize other,
+ MPLimb.wordSize))
val extra =
S.> (n, S.+ (limbsPer, 1))
val ans =
@@ -416,7 +420,7 @@
val ans =
(#orb other)
((#lshift other)
- (ans, MPLimb.wordSizeWord'),
+ (ans, MPLimb.wordSizeWord),
fromMPLimb limb)
in
loop (S.- (i, 1), ans)
@@ -432,8 +436,8 @@
in
val toWordAux8 =
make {fromMPLimb = MPLimb.toWord8,
- other = {wordSize' = Word8.wordSize',
- wordSizeWord' = Word8.wordSizeWord',
+ other = {wordSize = Word8.wordSize,
+ wordSizeWord = Word8.wordSizeWord,
zero = Word8.zero,
lshift = Word8.<<,
orb = Word8.orb}}
@@ -463,8 +467,8 @@
val toWordAux16 =
make {fromMPLimb = MPLimb.toWord16,
- other = {wordSize' = Word16.wordSize',
- wordSizeWord' = Word16.wordSizeWord',
+ other = {wordSize = Word16.wordSize,
+ wordSizeWord = Word16.wordSizeWord,
zero = Word16.zero,
lshift = Word16.<<,
orb = Word16.orb}}
@@ -494,8 +498,8 @@
val toWordAux32 =
make {fromMPLimb = MPLimb.toWord32,
- other = {wordSize' = Word32.wordSize',
- wordSizeWord' = Word32.wordSizeWord',
+ other = {wordSize = Word32.wordSize,
+ wordSizeWord = Word32.wordSizeWord,
zero = Word32.zero,
lshift = Word32.<<,
orb = Word32.orb}}
@@ -525,8 +529,8 @@
val toWordAux64 =
make {fromMPLimb = MPLimb.toWord64,
- other = {wordSize' = Word64.wordSize',
- wordSizeWord' = Word64.wordSizeWord',
+ other = {wordSize = Word64.wordSize,
+ wordSizeWord = Word64.wordSizeWord,
zero = Word64.zero,
lshift = Word64.<<,
orb = Word64.orb}}
@@ -559,10 +563,10 @@
end
local
- val bytesPerMPLimb = Sz.fromInt32 (Int32.quot (MPLimb.wordSize', 8))
+ val bytesPerMPLimb = Sz.fromInt32 (Int32.quot (MPLimb.wordSize, 8))
val bytesPerCounter = Sz.fromInt32 (Int32.quot (S.precision', 8))
val bytesPerLength = Sz.fromInt32 (Int32.quot (S.precision', 8))
- val bytesPerHeader = Sz.fromInt32 (Int32.quot (HeaderWord.wordSize', 8))
+ val bytesPerHeader = Sz.fromInt32 (Int32.quot (HeaderWord.wordSize, 8))
in
val bytesPerArrayHeader =
Sz.+ (bytesPerCounter, Sz.+ (bytesPerLength, bytesPerHeader))
@@ -582,7 +586,7 @@
* negation and absolute values are not fixnums.
* negBadIntInf is the negation (and absolute value) of that IntInf.int.
*)
- val badObjptrInt: I.int = I.~>> (I.minInt', 0w1)
+ val badObjptrInt: I.int = I.~>>? (I.minInt', 0w1)
val badObjptrWord: W.word = W.fromObjptrInt badObjptrInt
val badObjptrWordTagged: W.word = addTag badObjptrWord
val badObjptrIntTagged: I.int = W.toObjptrIntX badObjptrWordTagged
@@ -703,7 +707,7 @@
open I
fun mod2 x = I.andb (x, 1)
- fun div2 x = I.>> (x, 0w1)
+ fun div2 x = I.>>? (x, 0w1)
fun gcdInt (a, b, acc) =
case (a, b) of
@@ -786,6 +790,7 @@
fun bigMax (lhs: bigInt, rhs: bigInt): bigInt =
if bigLE (lhs, rhs) then rhs else lhs
+(*
fun bigSign' (arg: bigInt): Int32.int =
if isSmall arg
then I.sign' (dropTagCoerceInt arg)
@@ -795,8 +800,27 @@
fun bigSameSign (lhs: bigInt, rhs: bigInt): bool =
bigSign' lhs = bigSign' rhs
+*)
local
+ fun bigLTU (lhs, rhs) =
+ case (bigCompare (lhs, 0), bigCompare (rhs, 0)) of
+ (LESS, LESS) => bigLT (lhs, rhs)
+ | (LESS, GREATER) => false
+ | (_, EQUAL) => false
+ | (EQUAL, _) => true
+ | (GREATER, LESS) => true
+ | (GREATER, GREATER) => bigLT (lhs, rhs)
+ structure S = IntegralComparisons(type t = bigInt
+ val op < = bigLTU)
+ in
+ val bigLTU = S.<
+ val bigLEU = S.<=
+ val bigGTU = S.>
+ val bigGEU = S.>=
+ end
+
+ local
val op + = bigAdd
val op - = bigSub
val op > = bigGT
@@ -864,7 +888,7 @@
else Prim.notb (arg, reserve (numLimbs arg, 0))
local
- val bitsPerLimb = MPLimb.wordSizeWord'
+ val bitsPerLimb = MPLimb.wordSizeWord
fun shiftSize shift = S.fromWord32 (Word32.div (shift, bitsPerLimb))
in
fun bigLshift (arg: bigInt, shift: Word32.word): bigInt =
@@ -915,6 +939,10 @@
val compare = bigCompare
val min = bigMin
val max = bigMax
+ val ltu = bigLTU
+ val leu = bigLEU
+ val gtu = bigGTU
+ val geu = bigGEU
val andb = bigAndb
val << = bigLshift
Modified: mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/integer/int.sml
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/integer/int.sml 2006-02-14 03:58:19 UTC (rev 4357)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/integer/int.sml 2006-02-15 03:30:28 UTC (rev 4358)
@@ -6,88 +6,17 @@
* See the file MLton-LICENSE for details.
*)
-functor Integer (I: PRE_INTEGER_EXTRA) =
+functor Integer (I: PRE_INTEGER_EXTRA) : INTEGER_EXTRA =
struct
open I
-structure PI = Primitive.Int
-val detectOverflow = Primitive.detectOverflow
-
-val (toInt, fromInt) =
- if detectOverflow andalso
- precision' <> PI.precision'
- then if PI.<(precision', PI.precision')
- then (I.toInt,
- fn i =>
- if (PI.<= (I.toInt minInt', i)
- andalso PI.<= (i, I.toInt maxInt'))
- then I.fromInt i
- else raise Overflow)
- else (fn i =>
- if (I.<= (I.fromInt PI.minInt', i)
- andalso I.<= (i, I.fromInt PI.maxInt'))
- then I.toInt i
- else raise Overflow,
- I.fromInt)
- else (I.toInt, I.fromInt)
-
+val precision': Int.int = Primitive.Int32.toInt precision'
val precision: Int.int option = SOME precision'
val maxInt: int option = SOME maxInt'
val minInt: int option = SOME minInt'
-val one: int = fromInt 1
-val zero: int = fromInt 0
-
-fun quot (x, y) =
- if y = zero
- then raise Div
- else if detectOverflow andalso x = minInt' andalso y = ~one
- then raise Overflow
- else I.quot (x, y)
-
-fun rem (x, y) =
- if y = zero
- then raise Div
- else if x = minInt' andalso y = ~one
- then zero
- else I.rem (x, y)
-
-fun x div y =
- if x >= zero
- then if y > zero
- then I.quot (x, y)
- else if y < zero
- then if x = zero
- then zero
- else I.quot (x - one, y) -? one
- else raise Div
- else if y < zero
- then if detectOverflow andalso x = minInt' andalso y = ~one
- then raise Overflow
- else I.quot (x, y)
- else if y > zero
- then I.quot (x + one, y) -? one
- else raise Div
-
-fun x mod y =
- if x >= zero
- then if y > zero
- then I.rem (x, y)
- else if y < zero
- then if x = zero
- then zero
- else I.rem (x - one, y) +? (y + one)
- else raise Div
- else if y < zero
- then if x = minInt' andalso y = ~one
- then zero
- else I.rem (x, y)
- else if y > zero
- then I.rem (x + one, y) +? (y - one)
- else raise Div
-
val sign: int -> Int.int =
fn i => if i = zero
then (0: Int.int)
@@ -97,10 +26,6 @@
fun sameSign (x, y) = sign x = sign y
-fun abs (x: int) = if x < zero then ~ x else x
-
-val {compare, min, max} = Util.makeCompare (op <)
-
(* fmt constructs a string to represent the integer by building it into a
* statically allocated buffer. For the most part, this is a textbook
* algorithm: loop starting at the end of the buffer; we use rem to
@@ -118,7 +43,7 @@
(* Allocate a buffer large enough to hold any formatted integer in any radix.
* The most that will be required is for minInt in binary.
*)
- val maxNumDigits = PI.+ (precision', 1)
+ val maxNumDigits = Int.+ (precision', 1)
val buf = CharArray.array (maxNumDigits, #"\000")
in
fun fmt radix (n: int): string =
@@ -138,7 +63,7 @@
if n < zero
then
let
- val i = PI.- (i, 1)
+ val i = Int.- (i, 1)
val () = CharArray.update (buf, i, #"~")
in
i
@@ -148,10 +73,10 @@
CharArraySlice.vector
(CharArraySlice.slice (buf, start, NONE))
end
- else loop (q, PI.- (i, 1))
+ else loop (q, Int.- (i, 1))
end
in
- loop (if n < zero then n else ~? n, PI.- (maxNumDigits, 1))
+ loop (if n < zero then n else ~? n, Int.- (maxNumDigits, 1))
end
end
@@ -212,34 +137,9 @@
val fromString = StringCvt.scanString (scan StringCvt.DEC)
-fun power {base, exp} =
- if Primitive.safe andalso exp < zero
- then raise Fail "Int.power"
- else let
- fun loop (exp, accum) =
- if exp <= zero
- then accum
- else loop (exp - one, base * accum)
- in loop (exp, one)
- end
end
structure Int8 = Integer (Primitive.Int8)
-
structure Int16 = Integer (Primitive.Int16)
-
structure Int32 = Integer (Primitive.Int32)
-structure Int = Int32
-structure IntGlobal: INTEGER_GLOBAL = Int
-open IntGlobal
-
-structure Int64 =
- struct
- local
- structure P = Primitive.Int64
- structure I = Integer (P)
- in
- open I
- val toWord = P.toWord
- end
- end
+structure Int64 = Integer (Primitive.Int64)
Modified: mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/integer/int0.sml
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/integer/int0.sml 2006-02-14 03:58:19 UTC (rev 4357)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/integer/int0.sml 2006-02-15 03:30:28 UTC (rev 4358)
@@ -21,19 +21,16 @@
val abs: int -> int
val div: int * int -> int
val mod: int * int -> int
- val power: {base:int, exp: int} -> int
val quot: int * int -> int
val rem: int * int -> int
+ val power: {base:int, exp: int} -> int
val << : int * Primitive.Word32.word -> int
val rol : int * Primitive.Word32.word -> int
val ror : int * Primitive.Word32.word -> int
val ~>> : int * Primitive.Word32.word -> int
val >> : int * Primitive.Word32.word -> int
- val sign': int -> Primitive.Int32.int
- val sameSign: int * int -> bool
-
(* Overflow checking, signed interp. *)
val fromInt8: Primitive.Int8.int -> int
val fromInt16: Primitive.Int16.int -> int
@@ -177,16 +174,6 @@
in loop (exp, one)
end
-
- val sign': int -> Primitive.Int32.int =
- fn i => if i = zero
- then 0
- else if i < zero
- then ~1
- else 1
-
- fun sameSign (x, y) = sign' x = sign' y
-
local
fun 'a make {fromIntUnsafe: 'a -> int,
toIntUnsafe: int -> 'a,
@@ -244,19 +231,19 @@
local
fun 'a make {fromWordUnsafe: 'a -> int, fromWordXUnsafe: 'a -> int,
toWordUnsafe: int -> 'a, toWordXUnsafe: int -> 'a,
- other : {wordSize': Primitive.Int32.int,
+ other : {wordSize: Primitive.Int32.int,
gt: 'a * 'a -> bool,
lt: 'a * 'a -> bool}} =
let
fun fromWord w =
if detectOverflow
- andalso Primitive.Int32.>= (#wordSize' other, precision')
+ andalso Primitive.Int32.>= (#wordSize other, precision')
andalso (#gt other) (w, toWordUnsafe maxInt')
then raise Overflow
else fromWordUnsafe w
fun fromWordX w =
if detectOverflow
- andalso Primitive.Int32.> (#wordSize' other, precision')
+ andalso Primitive.Int32.> (#wordSize other, precision')
andalso (#lt other) (toWordUnsafe maxInt', w)
andalso (#lt other) (w, toWordUnsafe maxInt')
then raise Overflow
@@ -273,7 +260,7 @@
fromWordXUnsafe = fromWord8XUnsafe,
toWordUnsafe = toWord8Unsafe,
toWordXUnsafe =toWord8XUnsafe,
- other = {wordSize' = Primitive.Word8.wordSize',
+ other = {wordSize = Primitive.Word8.wordSize,
lt = Primitive.Word8.<,
gt = Primitive.Word8.>}}
val (fromWord16, fromWord16X, toWord16, toWord16X) =
@@ -281,7 +268,7 @@
fromWordXUnsafe = fromWord16XUnsafe,
toWordUnsafe = toWord16Unsafe,
toWordXUnsafe =toWord16XUnsafe,
- other = {wordSize' = Primitive.Word16.wordSize',
+ other = {wordSize = Primitive.Word16.wordSize,
lt = Primitive.Word16.<,
gt = Primitive.Word16.>}}
val (fromWord32, fromWord32X, toWord32, toWord32X) =
@@ -289,7 +276,7 @@
fromWordXUnsafe = fromWord32XUnsafe,
toWordUnsafe = toWord32Unsafe,
toWordXUnsafe =toWord32XUnsafe,
- other = {wordSize' = Primitive.Word32.wordSize',
+ other = {wordSize = Primitive.Word32.wordSize,
lt = Primitive.Word32.<,
gt = Primitive.Word32.>}}
val (fromWord64, fromWord64X, toWord64, toWord64X) =
@@ -297,7 +284,7 @@
fromWordXUnsafe = fromWord64XUnsafe,
toWordUnsafe = toWord64Unsafe,
toWordXUnsafe =toWord64XUnsafe,
- other = {wordSize' = Primitive.Word64.wordSize',
+ other = {wordSize = Primitive.Word64.wordSize,
lt = Primitive.Word64.<,
gt = Primitive.Word64.>}}
end
Modified: mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/integer/integer.sig
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/integer/integer.sig 2006-02-14 03:58:19 UTC (rev 4357)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/integer/integer.sig 2006-02-15 03:30:28 UTC (rev 4358)
@@ -1,13 +1,3 @@
-structure Int =
- struct
- type int = int
- end
-
-structure LargeInt =
- struct
- type int = Primitive.IntInf.int
- end
-
signature INTEGER_GLOBAL =
sig
eqtype int
@@ -17,76 +7,103 @@
sig
include INTEGER_GLOBAL
+ val toLarge: int -> LargeInt.int
+ val fromLarge: LargeInt.int -> int
+ val toInt: int -> Int.int
+ val fromInt: Int.int -> int
+
+ val minInt: int option
+ val maxInt: int option
+
+ val + : int * int -> int
+ val - : int * int -> int
val * : int * int -> int
- val + : int * int -> int
- val - : int * int -> int
+ val div: int * int -> int
+ val mod: int * int -> int
+ val quot: int * int -> int
+ val rem: int * int -> int
+
+ val compare: int * int -> order
val < : int * int -> bool
val <= : int * int -> bool
val > : int * int -> bool
val >= : int * int -> bool
- val fromInt : Int.int -> int
- val quot : int * int -> int
- val rem : int * int -> int
- val toInt : int -> Int.int
+
val ~ : int -> int
+ val abs: int -> int
+ val min: int * int -> int
+ val max: int * int -> int
end
signature PRE_INTEGER_EXTRA =
sig
include PRE_INTEGER
- val << : int * Word.word -> int
- val >> : int * Word.word -> int
- val ~>> : int * Word.word -> int
+ val zero: int
+ val one: int
+
+ val precision' : Primitive.Int32.int
+
+ val maxInt' : int
+ val minInt' : int
+
val *? : int * int -> int
val +? : int * int -> int
val -? : int * int -> int
- val andb : int * int -> int
- val maxInt' : int
- val minInt' : int
- val precision' : Int.int
val ~? : int -> int
+ val power: {base: int, exp: int} -> int
+
+ val andb: int * int -> int
+ val << : int * Primitive.Word32.word -> int
+ val notb: int -> int
+ val orb: int * int -> int
+ val rol: int * Primitive.Word32.word -> int
+ val ror: int * Primitive.Word32.word -> int
+ val ~>> : int * Primitive.Word32.word -> int
+ val >> : int * Primitive.Word32.word -> int
+ val xorb: int * int -> int
end
signature INTEGER =
sig
include PRE_INTEGER
- val abs: int -> int
- val compare: int * int -> order
- val div: int * int -> int
- val fmt: StringCvt.radix -> int -> string
- val fromLarge: LargeInt.int -> int
- val fromString: string -> int option
- val max: int * int -> int
- val maxInt: int option
- val min: int * int -> int
- val minInt: int option
- val mod: int * int -> int
- val precision: Int.int option
- val sameSign: int * int -> bool
- val scan: (StringCvt.radix
- -> (char, 'a) StringCvt.reader
+ val precision: Int.int option
+ val sign: int -> Int.int
+ val sameSign: int * int -> bool
+
+ val fmt: StringCvt.radix -> int -> string
+ val toString: int -> string
+ val scan: (StringCvt.radix
+ -> (char, 'a) StringCvt.reader
-> (int, 'a) StringCvt.reader)
- val sign: int -> Int.int
- val toLarge: int -> LargeInt.int
- val toString: int -> string
+ val fromString: string -> int option
end
signature INTEGER_EXTRA =
sig
include INTEGER
- val << : int * Word.word -> int
- val >> : int * Word.word -> int
- val ~>> : int * Word.word -> int
+ val precision' : Int.int
+ val maxInt' : int
+ val minInt' : int
+
+ val +? : int * int -> int
val *? : int * int -> int
- val +? : int * int -> int
val -? : int * int -> int
val ~? : int -> int
- val andb : int * int -> int
- val maxInt' : int
- val minInt' : int
- val power: {base: int, exp: int} -> int
- val precision' : Int.int
+
+ val andb: int * int -> int
+(*
+ val << : int * Word.word -> int
+*)
+ val notb: int -> int
+ val orb: int * int -> int
+(*
+ val rol: int * Word.word -> int
+ val ror: int * Word.word -> int
+ val ~>> : int * Word.word -> int
+ val >> : int * Word.word -> int
+*)
+ val xorb: int * int -> int
end
Copied: mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/integer/word-global.sml (from rev 4347, mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/integer/word.sml)
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/integer/word.sml 2006-02-05 14:22:33 UTC (rev 4347)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/integer/word-global.sml 2006-02-15 03:30:28 UTC (rev 4358)
@@ -0,0 +1,10 @@
+(* Copyright (C) 1999-2005 Henry Cejtin, Matthew Fluet, Suresh
+ * Jagannathan, and Stephen Weeks.
+ * Copyright (C) 1997-2000 NEC Research Institute.
+ *
+ * MLton is released under a BSD-style license.
+ * See the file MLton-LICENSE for details.
+ *)
+
+structure WordGlobal: WORD_GLOBAL = Word
+open WordGlobal
Modified: mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/integer/word.sig
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/integer/word.sig 2006-02-14 03:58:19 UTC (rev 4357)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/integer/word.sig 2006-02-15 03:30:28 UTC (rev 4358)
@@ -1,13 +1,3 @@
-structure Word =
- struct
- type word = word
- end
-
-structure LargeWord =
- struct
- type word = Primitive.Word64.word
- end
-
signature WORD_GLOBAL =
sig
eqtype word
@@ -17,66 +7,79 @@
sig
include WORD_GLOBAL
- val * : word * word -> word
- val + : word * word -> word
- val - : word * word -> word
- val < : word * word -> bool
- val << : word * Word.word -> word
- val <= : word * word -> bool
- val > : word * word -> bool
- val >= : word * word -> bool
- val >> : word * Word.word -> word
- val andb: word * word -> word
- val div: word * word -> word
- val fromInt: Int.int -> word
- val fromLarge: LargeWord.word -> word
- val mod: word * word -> word
- val notb: word -> word
- val orb: word * word -> word
- val toInt: word -> Int.int
- val toIntX: word -> Int.int
val toLarge: word -> LargeWord.word
val toLargeX: word -> LargeWord.word
- val wordSize: int
- val xorb: word * word -> word
+ val toLargeWord: word -> LargeWord.word
+ val toLargeWordX: word -> LargeWord.word
+ val fromLarge: LargeWord.word -> word
+ val fromLargeWord: LargeWord.word -> word
+ val toLargeInt: word -> LargeInt.int
+ val toLargeIntX: word -> LargeInt.int
+ val fromLargeInt: LargeInt.int -> word
+ val toInt: word -> int
+ val toIntX: word -> int
+ val fromInt: int -> word
+
+ val andb: word * word -> word
+ val orb: word * word -> word
+ val xorb: word * word -> word
+ val notb: word -> word
+
+ val + : word * word -> word
+ val - : word * word -> word
+ val * : word * word -> word
+ val div: word * word -> word
+ val mod: word * word -> word
+
+ val compare: word * word -> order
+ val < : word * word -> bool
+ val <= : word * word -> bool
+ val > : word * word -> bool
+ val >= : word * word -> bool
+
val ~ : word -> word
- val ~>> : word * Word.word -> word
+ val min: word * word -> word
+ val max: word * word -> word
end
signature PRE_WORD_EXTRA =
sig
include PRE_WORD
+
+ val zero: word
+
+ val wordSize: Primitive.Int32.int
+
+ val << : word * Primitive.Word32.word -> word
+ val >> : word * Primitive.Word32.word -> word
+ val ~>> : word * Primitive.Word32.word -> word
+ val rol: word * Primitive.Word32.word -> word
+ val ror: word * Primitive.Word32.word -> word
end
signature WORD =
sig
include PRE_WORD
+
+ val wordSize: Int.int
+
+(*
+ val << : word * Word.word -> word
+ val >> : word * Word.word -> word
+ val ~>> : word * Word.word -> word
+*)
- val compare: word * word -> order
- val fmt: StringCvt.radix -> word -> string
- val fromLargeInt: LargeInt.int -> word
- val fromLargeWord: LargeWord.word -> word
- val fromString: string -> word option
- val max: word * word -> word
- val min: word * word -> word
+ val fmt: StringCvt.radix -> word -> string
+ val toString: word -> string
val scan: (StringCvt.radix
-> (char, 'a) StringCvt.reader
-> (word, 'a) StringCvt.reader)
- val toLargeInt: word -> LargeInt.int
- val toLargeIntX: word -> LargeInt.int
- val toLargeWord: word -> LargeWord.word
- val toLargeWordX: word -> LargeWord.word
- val toString: word -> string
+ val fromString: string -> word option
end
signature WORD_EXTRA =
sig
include WORD
- (* include PRE_WORD_EXTRA *)
- end
-signature WORD32_EXTRA =
- sig
- include WORD_EXTRA
-
-(* val toReal: word -> real *)
+ val rol: word * Word.word -> word
+ val ror: word * Word.word -> word
end
Modified: mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/integer/word.sml
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/integer/word.sml 2006-02-14 03:58:19 UTC (rev 4357)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/integer/word.sml 2006-02-15 03:30:28 UTC (rev 4358)
@@ -10,48 +10,10 @@
struct
open W
-structure PW = Primitive.Word
-val detectOverflow = Primitive.detectOverflow
+val wordSize = Primitive.Int32.toInt wordSize
-(* These are overriden in patch.sml after int-inf.sml has been defined. *)
-val toLargeInt: word -> LargeInt.int = fn _ => raise Fail "toLargeInt"
-val toLargeIntX: word -> LargeInt.int = fn _ => raise Fail "toLargeIntX"
-val fromLargeInt: LargeInt.int -> word = fn _ => raise Fail "fromLargeInt"
-
-val wordSizeWord: Word.word = PW.fromInt wordSize
-val wordSizeMinusOneWord: Word.word = PW.fromInt (Int.-? (wordSize, 1))
-val zero: word = fromInt 0
-
-val toLargeWord = toLarge
-val toLargeWordX = toLargeX
-val fromLargeWord = fromLarge
-
-fun toInt w =
- if detectOverflow
- andalso Int.>= (wordSize, Int.precision')
- andalso w > fromInt Int.maxInt'
- then raise Overflow
- else W.toInt w
-
-fun toIntX w =
- if detectOverflow
- andalso Int.> (wordSize, Int.precision')
- andalso fromInt Int.maxInt' < w
- andalso w < fromInt Int.minInt'
- then raise Overflow
- else W.toIntX w
-
-local
- fun make f (w, w') =
- if Primitive.safe andalso w' = zero
- then raise Div
- else f (w, w')
-in
- val op div = make (op div)
- val op mod = make (op mod)
-end
-
+(*
fun << (i, n)
= if PW.>=(n ,wordSizeWord)
then zero
@@ -66,9 +28,8 @@
= if PW.<(n, wordSizeWord)
then W.~>>(i, n)
else W.~>>(i, wordSizeMinusOneWord)
+*)
-val {compare, min, max} = Util.makeCompare(op <)
-
fun fmt radix (w: word): string =
let val radix = fromInt (StringCvt.radixToInt radix)
fun loop (q, chars) =
@@ -154,6 +115,3 @@
structure Word16 = Word (Primitive.Word16)
structure Word32 = Word (Primitive.Word32)
structure Word64 = Word (Primitive.Word64)
-structure Word = Word32
-structure WordGlobal: WORD_GLOBAL = Word
-open WordGlobal
Modified: mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/integer/word0.sml
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/integer/word0.sml 2006-02-14 03:58:19 UTC (rev 4357)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/integer/word0.sml 2006-02-15 03:30:28 UTC (rev 4358)
@@ -10,7 +10,7 @@
sig
include PRIM_WORD
- val wordSizeWord': Primitive.Word32.word
+ val wordSizeWord: Primitive.Word32.word
val zero: word
val one: word
@@ -30,11 +30,13 @@
val fromInt32: Primitive.Int32.int -> word
val fromInt64: Primitive.Int64.int -> word
+(*
(* Lowbits or zero extend. *)
val fromInt8Z: Primitive.Int8.int -> word
val fromInt16Z: Primitive.Int16.int -> word
val fromInt32Z: Primitive.Int32.int -> word
val fromInt64Z: Primitive.Int64.int -> word
+*)
(* Lowbits or zero extend. *)
val fromWord8: Primitive.Word8.word -> word
@@ -80,8 +82,8 @@
val detectOverflow = Primitive.Controls.detectOverflow
- val wordSizeWord' = Primitive.Word32.fromInt32Unsafe wordSize'
- val wordSizeMinusOneWord' = Primitive.Word32.- (wordSizeWord', 0w1)
+ val wordSizeWord = Primitive.Word32.fromInt32Unsafe wordSize
+ val wordSizeMinusOneWord = Primitive.Word32.- (wordSizeWord, 0w1)
val zero: word = fromWord32Unsafe 0w0
val one: word = fromWord32Unsafe 0w1
@@ -97,20 +99,20 @@
end
fun << (w, n) =
- if Primitive.Word32.>= (n, wordSizeWord')
+ if Primitive.Word32.>= (n, wordSizeWord)
then zero
else <<? (w, n)
fun >> (w, n) =
- if Primitive.Word32.>= (n, wordSizeWord')
+ if Primitive.Word32.>= (n, wordSizeWord)
then zero
else >>? (w, n)
fun ~>> (w, n) =
- if Primitive.Word32.< (n, wordSizeWord')
+ if Primitive.Word32.< (n, wordSizeWord)
then ~>>? (w, n)
- else ~>>? (w, wordSizeMinusOneWord')
+ else ~>>? (w, wordSizeMinusOneWord)
fun rol (w, n) =
let
- val n = Primitive.Word32.remUnsafe (n, wordSizeWord')
+ val n = Primitive.Word32.remUnsafe (n, wordSizeWord)
in
if n = 0w0
then w
@@ -118,7 +120,7 @@
end
fun ror (w, n) =
let
- val n = Primitive.Word32.remUnsafe (n, wordSizeWord')
+ val n = Primitive.Word32.remUnsafe (n, wordSizeWord)
in
if n = 0w0
then w
@@ -126,7 +128,7 @@
end
local
- fun 'a make {fromIntUnsafe: 'a -> word, fromIntZUnsafe: 'a -> word,
+ fun 'a make {fromIntUnsafe: 'a -> word, (* fromIntZUnsafe: 'a -> word, *)
toIntUnsafe: word -> 'a, toIntXUnsafe: word -> 'a,
other : {precision': Primitive.Int32.int,
maxInt': 'a,
@@ -134,51 +136,51 @@
let
fun toInt w =
if detectOverflow
- andalso Primitive.Int32.>= (wordSize', #precision' other)
+ andalso Primitive.Int32.>= (wordSize, #precision' other)
andalso w > fromIntUnsafe (#maxInt' other)
then raise Overflow
else toIntUnsafe w
fun toIntX w =
if detectOverflow
- andalso Primitive.Int32.> (wordSize', #precision' other)
+ andalso Primitive.Int32.> (wordSize, #precision' other)
andalso fromIntUnsafe (#maxInt' other) < w
andalso w < fromIntUnsafe (#minInt' other)
then raise Overflow
else toIntXUnsafe w
in
(fromIntUnsafe,
- fromIntZUnsafe,
+ (* fromIntZUnsafe, *)
toInt,
toIntX)
end
in
- val (fromInt8, fromInt8Z, toInt8, toInt8X) =
+ val (fromInt8, (* fromInt8Z, *) toInt8, toInt8X) =
make {fromIntUnsafe = fromInt8Unsafe,
- fromIntZUnsafe = fromInt8ZUnsafe,
+ (* fromIntZUnsafe = fromInt8ZUnsafe, *)
toIntUnsafe = toInt8Unsafe,
toIntXUnsafe = toInt8XUnsafe,
other = {precision' = Primitive.Int8.precision',
maxInt' = Primitive.Int8.maxInt',
minInt' = Primitive.Int8.minInt'}}
- val (fromInt16, fromInt16Z, toInt16, toInt16X) =
+ val (fromInt16, (* fromInt16Z, *) toInt16, toInt16X) =
make {fromIntUnsafe = fromInt16Unsafe,
- fromIntZUnsafe = fromInt16ZUnsafe,
+ (* fromIntZUnsafe = fromInt16ZUnsafe, *)
toIntUnsafe = toInt16Unsafe,
toIntXUnsafe = toInt16XUnsafe,
other = {precision' = Primitive.Int16.precision',
maxInt' = Primitive.Int16.maxInt',
minInt' = Primitive.Int16.minInt'}}
- val (fromInt32, fromInt32Z, toInt32, toInt32X) =
+ val (fromInt32, (* fromInt32Z, *) toInt32, toInt32X) =
make {fromIntUnsafe = fromInt32Unsafe,
- fromIntZUnsafe = fromInt32ZUnsafe,
+ (* fromIntZUnsafe = fromInt32ZUnsafe, *)
toIntUnsafe = toInt32Unsafe,
toIntXUnsafe = toInt32XUnsafe,
other = {precision' = Primitive.Int32.precision',
maxInt' = Primitive.Int32.maxInt',
minInt' = Primitive.Int32.minInt'}}
- val (fromInt64, fromInt64Z, toInt64, toInt64X) =
+ val (fromInt64, (* fromInt64Z, *) toInt64, toInt64X) =
make {fromIntUnsafe = fromInt64Unsafe,
- fromIntZUnsafe = fromInt64ZUnsafe,
+ (* fromIntZUnsafe = fromInt64ZUnsafe, *)
toIntUnsafe = toInt64Unsafe,
toIntXUnsafe = toInt64XUnsafe,
other = {precision' = Primitive.Int64.precision',
Modified: mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/primitive/prim-int.sml
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/primitive/prim-int.sml 2006-02-14 03:58:19 UTC (rev 4357)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/primitive/prim-int.sml 2006-02-15 03:30:28 UTC (rev 4358)
@@ -56,11 +56,13 @@
val fromInt32Unsafe: Primitive.Int32.int -> int
val fromInt64Unsafe: Primitive.Int64.int -> int
+(*
(* Lowbits or zero extend. *)
val fromInt8ZUnsafe: Primitive.Int8.int -> int
val fromInt16ZUnsafe: Primitive.Int16.int -> int
val fromInt32ZUnsafe: Primitive.Int32.int -> int
val fromInt64ZUnsafe: Primitive.Int64.int -> int
+*)
(* Lowbits or zero extend. *)
val fromWord8Unsafe: Primitive.Word8.word -> int
@@ -80,11 +82,13 @@
val toInt32Unsafe: int -> Primitive.Int32.int
val toInt64Unsafe: int -> Primitive.Int64.int
+(*
(* Lowbits or zero extend. *)
val toInt8ZUnsafe: int -> Primitive.Int8.int
val toInt16ZUnsafe: int -> Primitive.Int16.int
val toInt32ZUnsafe: int -> Primitive.Int32.int
val toInt64ZUnsafe: int -> Primitive.Int64.int
+*)
(* Lowbits or zero extend. *)
val toWord8Unsafe: int -> Primitive.Word8.word
@@ -206,10 +210,12 @@
val fromInt32Unsafe = _prim "WordS32_toWord8": Int32.int -> int;
val fromInt64Unsafe = _prim "WordS64_toWord8": Int64.int -> int;
+(*
val fromInt8ZUnsafe = _prim "WordU8_toWord8": Int8.int -> int;
val fromInt16ZUnsafe = _prim "WordU16_toWord8": Int16.int -> int;
val fromInt32ZUnsafe = _prim "WordU32_toWord8": Int32.int -> int;
val fromInt64ZUnsafe = _prim "WordU64_toWord8": Int64.int -> int;
+*)
val fromWord8Unsafe = _prim "WordU8_toWord8": Word8.word -> int;
val fromWord16Unsafe = _prim "WordU16_toWord8": Word16.word -> int;
@@ -226,10 +232,12 @@
val toInt32Unsafe = _prim "WordS8_toWord32": int -> Int32.int;
val toInt64Unsafe = _prim "WordS8_toWord64": int -> Int64.int;
+(*
val toInt8ZUnsafe = _prim "WordU8_toWord8": int -> Int8.int;
val toInt16ZUnsafe = _prim "WordU8_toWord16": int -> Int16.int;
val toInt32ZUnsafe = _prim "WordU8_toWord32": int -> Int32.int;
val toInt64ZUnsafe = _prim "WordU8_toWord64": int -> Int64.int;
+*)
val toWord8Unsafe = _prim "WordU8_toWord8": int -> Word8.word;
val toWord16Unsafe = _prim "WordU8_toWord16": int -> Word16.word;
@@ -362,10 +370,12 @@
val fromInt32Unsafe = _prim "WordS32_toWord16": Int32.int -> int;
val fromInt64Unsafe = _prim "WordS64_toWord16": Int64.int -> int;
+(*
val fromInt8ZUnsafe = _prim "WordU8_toWord16": Int8.int -> int;
val fromInt16ZUnsafe = _prim "WordU16_toWord16": Int16.int -> int;
val fromInt32ZUnsafe = _prim "WordU32_toWord16": Int32.int -> int;
val fromInt64ZUnsafe = _prim "WordU64_toWord16": Int64.int -> int;
+*)
val fromWord8Unsafe = _prim "WordU8_toWord16": Word8.word -> int;
val fromWord16Unsafe = _prim "WordU16_toWord16": Word16.word -> int;
@@ -382,10 +392,12 @@
val toInt32Unsafe = _prim "WordS16_toWord32": int -> Int32.int;
val toInt64Unsafe = _prim "WordS16_toWord64": int -> Int64.int;
+(*
val toInt8ZUnsafe = _prim "WordU16_toWord8": int -> Int8.int;
val toInt16ZUnsafe = _prim "WordU16_toWord16": int -> Int16.int;
val toInt32ZUnsafe = _prim "WordU16_toWord32": int -> Int32.int;
val toInt64ZUnsafe = _prim "WordU16_toWord64": int -> Int64.int;
+*)
val toWord8Unsafe = _prim "WordU16_toWord8": int -> Word8.word;
val toWord16Unsafe = _prim "WordU16_toWord16": int -> Word16.word;
@@ -582,10 +594,12 @@
val fromInt32Unsafe = _prim "WordS32_toWord32": Int32.int -> int;
val fromInt64Unsafe = _prim "WordS64_toWord32": Int64.int -> int;
+(*
val fromInt8ZUnsafe = _prim "WordU8_toWord32": Int8.int -> int;
val fromInt16ZUnsafe = _prim "WordU16_toWord32": Int16.int -> int;
val fromInt32ZUnsafe = _prim "WordU32_toWord32": Int32.int -> int;
val fromInt64ZUnsafe = _prim "WordU64_toWord32": Int64.int -> int;
+*)
val fromWord8Unsafe = _prim "WordU8_toWord32": Word8.word -> int;
val fromWord16Unsafe = _prim "WordU16_toWord32": Word16.word -> int;
@@ -602,10 +616,12 @@
val toInt32Unsafe = _prim "WordS32_toWord32": int -> Int32.int;
val toInt64Unsafe = _prim "WordS32_toWord64": int -> Int64.int;
+(*
val toInt8ZUnsafe = _prim "WordU32_toWord8": int -> Int8.int;
val toInt16ZUnsafe = _prim "WordU32_toWord16": int -> Int16.int;
val toInt32ZUnsafe = _prim "WordU32_toWord32": int -> Int32.int;
val toInt64ZUnsafe = _prim "WordU32_toWord64": int -> Int64.int;
+*)
val toWord8Unsafe = _prim "WordU32_toWord8": int -> Word8.word;
val toWord16Unsafe = _prim "WordU32_toWord16": int -> Word16.word;
@@ -682,10 +698,12 @@
val fromInt32Unsafe = _prim "WordS32_toWord64": Int32.int -> int;
val fromInt64Unsafe = _prim "WordS64_toWord64": Int64.int -> int;
+(*
val fromInt8ZUnsafe = _prim "WordU8_toWord64": Int8.int -> int;
val fromInt16ZUnsafe = _prim "WordU16_toWord64": Int16.int -> int;
val fromInt32ZUnsafe = _prim "WordU32_toWord64": Int32.int -> int;
val fromInt64ZUnsafe = _prim "WordU64_toWord64": Int64.int -> int;
+*)
val fromWord8Unsafe = _prim "WordU8_toWord64": Word8.word -> int;
val fromWord16Unsafe = _prim "WordU16_toWord64": Word16.word -> int;
@@ -702,10 +720,12 @@
val toInt32Unsafe = _prim "WordS64_toWord32": int -> Int32.int;
val toInt64Unsafe = _prim "WordS64_toWord64": int -> Int64.int;
+(*
val toInt8ZUnsafe = _prim "WordU64_toWord8": int -> Int8.int;
val toInt16ZUnsafe = _prim "WordU64_toWord16": int -> Int16.int;
val toInt32ZUnsafe = _prim "WordU64_toWord32": int -> Int32.int;
val toInt64ZUnsafe = _prim "WordU64_toWord64": int -> Int64.int;
+*)
val toWord8Unsafe = _prim "WordU64_toWord8": int -> Word8.word;
val toWord16Unsafe = _prim "WordU64_toWord16": int -> Word16.word;
Modified: mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/primitive/prim-word.sml
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/primitive/prim-word.sml 2006-02-14 03:58:19 UTC (rev 4357)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/primitive/prim-word.sml 2006-02-15 03:30:28 UTC (rev 4358)
@@ -13,7 +13,7 @@
eqtype word
type t = word
- val wordSize': Primitive.Int32.int
+ val wordSize: Primitive.Int32.int
val + : word * word -> word
val andb : word * word -> word
@@ -45,11 +45,13 @@
val fromInt32Unsafe: Primitive.Int32.int -> word
val fromInt64Unsafe: Primitive.Int64.int -> word
+(*
(* Lowbits or zero extend. *)
val fromInt8ZUnsafe: Primitive.Int8.int -> word
val fromInt16ZUnsafe: Primitive.Int16.int -> word
val fromInt32ZUnsafe: Primitive.Int32.int -> word
val fromInt64ZUnsafe: Primitive.Int64.int -> word
+*)
(* Lowbits or zero extend. *)
val fromWord8Unsafe: Primitive.Word8.word -> word
@@ -98,7 +100,7 @@
type big = Word8.word
val fromBigUnsafe = _prim "WordU8_toWord1": big -> word;
val toBig = _prim "WordU1_toWord8": word -> big;
- val wordSize' : Int32.int = 1
+ val wordSize: Int32.int = 1
end
structure Word2 =
struct
@@ -106,7 +108,7 @@
type big = Word8.word
val fromBigUnsafe = _prim "WordU8_toWord2": big -> word;
val toBig = _prim "WordU2_toWord8": word -> big;
- val wordSize' : Int32.int = 2
+ val wordSize: Int32.int = 2
end
structure Word3 =
struct
@@ -114,7 +116,7 @@
type big = Word8.word
val fromBigUnsafe = _prim "WordU8_toWord3": big -> word;
val toBig = _prim "WordU3_toWord8": word -> big;
- val wordSize' : Int32.int = 3
+ val wordSize: Int32.int = 3
end
structure Word4 =
struct
@@ -122,7 +124,7 @@
type big = Word8.word
val fromBigUnsafe = _prim "WordU8_toWord4": big -> word;
val toBig = _prim "WordU4_toWord8": word -> big;
- val wordSize' : Int32.int = 4
+ val wordSize: Int32.int = 4
end
structure Word5 =
struct
@@ -130,7 +132,7 @@
type big = Word8.word
val fromBigUnsafe = _prim "WordU8_toWord5": big -> word;
val toBig = _prim "WordU5_toWord8": word -> big;
- val wordSize' : Int32.int = 5
+ val wordSize: Int32.int = 5
end
structure Word6 =
struct
@@ -138,7 +140,7 @@
type big = Word8.word
val fromBigUnsafe = _prim "WordU8_toWord6": big -> word;
val toBig = _prim "WordU6_toWord8": word -> big;
- val wordSize' : Int32.int = 6
+ val wordSize: Int32.int = 6
end
structure Word7 =
struct
@@ -146,13 +148,13 @@
type big = Word8.word
val fromBigUnsafe = _prim "WordU8_toWord7": big -> word;
val toBig = _prim "WordU7_toWord8": word -> big;
- val wordSize' : Int32.int = 7
+ val wordSize: Int32.int = 7
end
structure Word8 =
struct
open Word8
- val wordSize' : Int32.int = 8
+ val wordSize: Int32.int = 8
val + = _prim "Word8_add": word * word -> word;
val andb = _prim "Word8_andb": word * word -> word;
@@ -177,10 +179,12 @@
val fromInt32Unsafe = _prim "WordS32_toWord8": Int32.int -> word;
val fromInt64Unsafe = _prim "WordS64_toWord8": Int64.int -> word;
+(*
val fromInt8ZUnsafe = _prim "WordU8_toWord8": Int8.int -> word;
val fromInt16ZUnsafe = _prim "WordU16_toWord8": Int16.int -> word;
val fromInt32ZUnsafe = _prim "WordU32_toWord8": Int32.int -> word;
val fromInt64ZUnsafe = _prim "WordU64_toWord8": Int64.int -> word;
+*)
val fromWord8Unsafe = _prim "WordU8_toWord8": Word8.word -> word;
val fromWord16Unsafe = _prim "WordU16_toWord8": Word16.word -> word;
@@ -227,7 +231,7 @@
type big = Word16.word
val fromBigUnsafe = _prim "WordU16_toWord9": big -> word;
val toBig = _prim "WordU9_toWord16": word -> big;
- val wordSize' : Int32.int = 9
+ val wordSize: Int32.int = 9
end
structure Word10 =
struct
@@ -235,7 +239,7 @@
type big = Word16.word
val fromBigUnsafe = _prim "WordU16_toWord10": big -> word;
val toBig = _prim "WordU10_toWord16": word -> big;
- val wordSize' : Int32.int = 10
+ val wordSize: Int32.int = 10
end
structure Word11 =
struct
@@ -243,7 +247,7 @@
type big = Word16.word
val fromBigUnsafe = _prim "WordU16_toWord11": big -> word;
val toBig = _prim "WordU11_toWord16": word -> big;
- val wordSize' : Int32.int = 11
+ val wordSize: Int32.int = 11
end
structure Word12 =
struct
@@ -251,7 +255,7 @@
type big = Word16.word
val fromBigUnsafe = _prim "WordU16_toWord12": big -> word;
val toBig = _prim "WordU12_toWord16": word -> big;
- val wordSize' : Int32.int = 12
+ val wordSize: Int32.int = 12
end
structure Word13 =
struct
@@ -259,7 +263,7 @@
type big = Word16.word
val fromBigUnsafe = _prim "WordU16_toWord13": big -> word;
val toBig = _prim "WordU13_toWord16": word -> big;
- val wordSize' : Int32.int = 13
+ val wordSize: Int32.int = 13
end
structure Word14 =
struct
@@ -267,7 +271,7 @@
type big = Word16.word
val fromBigUnsafe = _prim "WordU16_toWord14": big -> word;
val toBig = _prim "WordU14_toWord16": word -> big;
- val wordSize' : Int32.int = 14
+ val wordSize: Int32.int = 14
end
structure Word15 =
struct
@@ -275,13 +279,13 @@
type big = Word16.word
val fromBigUnsafe = _prim "WordU16_toWord15": big -> word;
val toBig = _prim "WordU15_toWord16": word -> big;
- val wordSize' : Int32.int = 15
+ val wordSize: Int32.int = 15
end
structure Word16 =
struct
open Word16
- val wordSize' : Int32.int = 16
+ val wordSize: Int32.int = 16
val + = _prim "Word16_add": word * word -> word;
val andb = _prim "Word16_andb": word * word -> word;
@@ -306,10 +310,12 @@
val fromInt32Unsafe = _prim "WordS32_toWord16": Int32.int -> word;
val fromInt64Unsafe = _prim "WordS64_toWord16": Int64.int -> word;
+(*
val fromInt8ZUnsafe = _prim "WordU8_toWord16": Int8.int -> word;
val fromInt16ZUnsafe = _prim "WordU16_toWord16": Int16.int -> word;
val fromInt32ZUnsafe = _prim "WordU32_toWord16": Int32.int -> word;
val fromInt64ZUnsafe = _prim "WordU64_toWord16": Int64.int -> word;
+*)
val fromWord8Unsafe = _prim "WordU8_toWord16": Word8.word -> word;
val fromWord16Unsafe = _prim "WordU16_toWord16": Word16.word -> word;
@@ -356,7 +362,7 @@
type big = Word32.word
val fromBigUnsafe = _prim "WordU32_toWord17": big -> word;
val toBig = _prim "WordU17_toWord32": word -> big;
- val wordSize' : Int32.int = 17
+ val wordSize: Int32.int = 17
end
structure Word18 =
struct
@@ -364,7 +370,7 @@
type big = Word32.word
val fromBigUnsafe = _prim "WordU32_toWord18": big -> word;
val toBig = _prim "WordU18_toWord32": word -> big;
- val wordSize' : Int32.int = 18
+ val wordSize: Int32.int = 18
end
structure Word19 =
struct
@@ -372,7 +378,7 @@
type big = Word32.word
val fromBigUnsafe = _prim "WordU32_toWord19": big -> word;
val toBig = _prim "WordU19_toWord32": word -> big;
- val wordSize' : Int32.int = 19
+ val wordSize: Int32.int = 19
end
structure Word20 =
struct
@@ -380,7 +386,7 @@
type big = Word32.word
val fromBigUnsafe = _prim "WordU32_toWord20": big -> word;
val toBig = _prim "WordU20_toWord32": word -> big;
- val wordSize' : Int32.int = 20
+ val wordSize: Int32.int = 20
end
structure Word21 =
struct
@@ -388,7 +394,7 @@
type big = Word32.word
val fromBigUnsafe = _prim "WordU32_toWord21": big -> word;
val toBig = _prim "WordU21_toWord32": word -> big;
- val wordSize' : Int32.int = 21
+ val wordSize: Int32.int = 21
end
structure Word22 =
struct
@@ -396,7 +402,7 @@
type big = Word32.word
val fromBigUnsafe = _prim "WordU32_toWord22": big -> word;
val toBig = _prim "WordU22_toWord32": word -> big;
- val wordSize' : Int32.int = 22
+ val wordSize: Int32.int = 22
end
structure Word23 =
struct
@@ -404,7 +410,7 @@
type big = Word32.word
val fromBigUnsafe = _prim "WordU32_toWord23": big -> word;
val toBig = _prim "WordU23_toWord32": word -> big;
- val wordSize' : Int32.int = 23
+ val wordSize: Int32.int = 23
end
structure Word24 =
struct
@@ -412,7 +418,7 @@
type big = Word32.word
val fromBigUnsafe = _prim "WordU32_toWord24": big -> word;
val toBig = _prim "WordU24_toWord32": word -> big;
- val wordSize' : Int32.int = 24
+ val wordSize: Int32.int = 24
end
structure Word25 =
struct
@@ -420,7 +426,7 @@
type big = Word32.word
val fromBigUnsafe = _prim "WordU32_toWord25": big -> word;
val toBig = _prim "WordU25_toWord32": word -> big;
- val wordSize' : Int32.int = 25
+ val wordSize: Int32.int = 25
end
structure Word26 =
struct
@@ -428,7 +434,7 @@
type big = Word32.word
val fromBigUnsafe = _prim "WordU32_toWord26": big -> word;
val toBig = _prim "WordU26_toWord32": word -> big;
- val wordSize' : Int32.int = 26
+ val wordSize: Int32.int = 26
end
structure Word27 =
struct
@@ -436,7 +442,7 @@
type big = Word32.word
val fromBigUnsafe = _prim "WordU32_toWord27": big -> word;
val toBig = _prim "WordU27_toWord32": word -> big;
- val wordSize' : Int32.int = 27
+ val wordSize: Int32.int = 27
end
structure Word28 =
struct
@@ -444,7 +450,7 @@
type big = Word32.word
val fromBigUnsafe = _prim "WordU32_toWord28": big -> word;
val toBig = _prim "WordU28_toWord32": word -> big;
- val wordSize' : Int32.int = 28
+ val wordSize: Int32.int = 28
end
structure Word29 =
struct
@@ -452,7 +458,7 @@
type big = Word32.word
val fromBigUnsafe = _prim "WordU32_toWord29": big -> word;
val toBig = _prim "WordU29_toWord32": word -> big;
- val wordSize' : Int32.int = 29
+ val wordSize: Int32.int = 29
end
structure Word30 =
struct
@@ -460,7 +466,7 @@
type big = Word32.word
val fromBigUnsafe = _prim "WordU32_toWord30": big -> word;
val toBig = _prim "WordU30_toWord32": word -> big;
- val wordSize' : Int32.int = 30
+ val wordSize: Int32.int = 30
end
structure Word31 =
struct
@@ -468,13 +474,13 @@
type big = Word32.word
val fromBigUnsafe = _prim "WordU32_toWord31": big -> word;
val toBig = _prim "WordU31_toWord32": word -> big;
- val wordSize' : Int32.int = 31
+ val wordSize: Int32.int = 31
end
structure Word32 =
struct
open Word32
- val wordSize' : Int32.int = 32
+ val wordSize: Int32.int = 32
val + = _prim "Word32_add": word * word -> word;
val andb = _prim "Word32_andb": word * word -> word;
@@ -499,10 +505,12 @@
val fromInt32Unsafe = _prim "WordS32_toWord32": Int32.int -> word;
val fromInt64Unsafe = _prim "WordS64_toWord32": Int64.int -> word;
+(*
val fromInt8ZUnsafe = _prim "WordU8_toWord32": Int8.int -> word;
val fromInt16ZUnsafe = _prim "WordU16_toWord32": Int16.int -> word;
val fromInt32ZUnsafe = _prim "WordU32_toWord32": Int32.int -> word;
val fromInt64ZUnsafe = _prim "WordU64_toWord32": Int64.int -> word;
+*)
val fromWord8Unsafe = _prim "WordU8_toWord32": Word8.word -> word;
val fromWord16Unsafe = _prim "WordU16_toWord32": Word16.word -> word;
@@ -547,7 +555,7 @@
struct
open Word64
- val wordSize' : Int32.int = 64
+ val wordSize: Int32.int = 64
val + = _prim "Word64_add": word * word -> word;
val andb = _prim "Word64_andb": word * word -> word;
@@ -572,10 +580,12 @@
val fromInt32Unsafe = _prim "WordS32_toWord64": Int32.int -> word;
val fromInt64Unsafe = _prim "WordS64_toWord64": Int64.int -> word;
+(*
val fromInt8ZUnsafe = _prim "WordU8_toWord64": Int8.int -> word;
val fromInt16ZUnsafe = _prim "WordU16_toWord64": Int16.int -> word;
val fromInt32ZUnsafe = _prim "WordU32_toWord64": Int32.int -> word;
val fromInt64ZUnsafe = _prim "WordU64_toWord64": Int64.int -> word;
+*)
val fromWord8Unsafe = _prim "WordU8_toWord64": Word8.word -> word;
val fromWord16Unsafe = _prim "WordU16_toWord64": Word16.word -> word;
Modified: mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/primitive/primitive.mlb
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/primitive/primitive.mlb 2006-02-14 03:58:19 UTC (rev 4357)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/primitive/primitive.mlb 2006-02-15 03:30:28 UTC (rev 4358)
@@ -19,13 +19,10 @@
ann "allowRebindEquals true" in
prim1.sml
end
- local
- ../util/integral-comparisons.sml
- in
- prim-char.sml
- prim-word.sml
- prim-int.sml
- end
+ ../util/integral-comparisons.sml
+ prim-char.sml
+ prim-word.sml
+ prim-int.sml
local ../config/bind-for-config0.sml in ann "forceUsed" in
../config/choose.sml
end end
Modified: mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/text/char.sml
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/text/char.sml 2006-02-14 03:58:19 UTC (rev 4357)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/text/char.sml 2006-02-15 03:30:28 UTC (rev 4358)
@@ -15,7 +15,7 @@
NONE => NONE
| SOME (c, state) =>
if #"@" <= c andalso c <= #"_"
- then SOME (chr (ord c -? ord #"@"), state)
+ then SOME (chr (Int.-? (ord c, ord #"@")), state)
else NONE
fun formatChar reader state =
@@ -160,7 +160,7 @@
fun padLeft (s: string, n: int): string =
let
val m = String.size s
- val diff = n -? m
+ val diff = Int.-? (n, m)
in if Int.> (diff, 0)
then String.concat [String.new (diff, #"0"), s]
else if diff = 0
@@ -189,7 +189,7 @@
| _ =>
if c < #" "
then (String.concat
- ["\\^", String0.str (chr (ord c +? ord #"@"))])
+ ["\\^", String0.str (chr (Int.+? (ord c, ord #"@")))])
else String.concat
["\\", padLeft (Int.fmt StringCvt.DEC (ord c), 3)])
Modified: mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/text/char0.sml
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/text/char0.sml 2006-02-14 03:58:19 UTC (rev 4357)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/text/char0.sml 2006-02-15 03:30:28 UTC (rev 4358)
@@ -55,8 +55,7 @@
fun chrOpt c =
if Primitive.Controls.safe
- andalso (Int.< (c, 0) orelse Int.> (c, maxOrd))
- (* andalso Int.gtu (c, maxOrd) *)
+ andalso Int.gtu (c, maxOrd)
then NONE
else SOME (chrUnsafe c)
Modified: mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/text/string.sml
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/text/string.sml 2006-02-14 03:58:19 UTC (rev 4357)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/text/string.sml 2006-02-15 03:30:28 UTC (rev 4358)
@@ -63,7 +63,7 @@
structure NullString =
struct
- open NullString
+ open Primitive.NullString8
val nullTerm = fromString o String.nullTerm
end