[MLton-commit] r4350

Matthew Fluet MLton@mlton.org
Thu, 9 Feb 2006 16:42:07 -0800


Numerous fixes to IntInf.{to,from}{Int,Word{,X}}{8,16,32,64} code.


----------------------------------------------------------------------

U   mlton/branches/on-20050822-x86_64-branch/basis-library/primitive/basis-ffi.sml
U   mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/Makefile
U   mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/build/sources.mlb
U   mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/config/choose.sml
U   mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/config/default/default-char8.sml
U   mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/config/default/default-int32.sml
U   mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/config/default/default-int64.sml
U   mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/config/default/default-intinf.sml
U   mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/config/default/default-word32.sml
U   mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/config/default/default-word64.sml
A   mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/config/header/
A   mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/config/header/header-word32.sml
A   mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/config/header/header-word64.sml
D   mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/config/seq/seq-index32.sml
D   mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/config/seq/seq-index64.sml
A   mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/config/seq/seqindex-int32.sml
A   mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/config/seq/seqindex-int64.sml
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/int0.sml
U   mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/integer/word0.sml
A   mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/maps/header-word32.map
A   mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/maps/header-word64.map
D   mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/maps/seq-index32.map
D   mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/maps/seq-index64.map
A   mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/maps/seqindex-int32.map
A   mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/maps/seqindex-int64.map
U   mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/misc/reader.sig
U   mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/primitive/basis-ffi.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-nullstring.sml
U   mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/primitive/prim-seq.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/test/Makefile
A   mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/test/print.c
U   mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/test/test.mlb
U   mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/test/test.sml
U   mlton/branches/on-20050822-x86_64-branch/runtime/basis/Stdio.c
U   mlton/branches/on-20050822-x86_64-branch/runtime/gen/basis-ffi.def

----------------------------------------------------------------------

Modified: mlton/branches/on-20050822-x86_64-branch/basis-library/primitive/basis-ffi.sml
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library/primitive/basis-ffi.sml	2006-02-10 00:38:30 UTC (rev 4349)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library/primitive/basis-ffi.sml	2006-02-10 00:42:03 UTC (rev 4350)
@@ -983,6 +983,8 @@
 structure Stdio = 
 struct
 val print = _import "Stdio_print" : String8.t -> unit;
+val printStderr = _import "Stdio_printStderr" : String8.t -> unit;
+val printStdout = _import "Stdio_printStdout" : String8.t -> unit;
 end
 structure Time = 
 struct

Modified: mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/Makefile
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/Makefile	2006-02-10 00:38:30 UTC (rev 4349)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/Makefile	2006-02-10 00:42:03 UTC (rev 4350)
@@ -20,28 +20,31 @@
 	../bin/clean
 
 
+OBJPTR_REP_MAPS = objptr-rep32.map objptr-rep64.map 
+HEADER_MAPS = header-word32.map header-word64.map
+SEQ_INDEX_MAPS = seqindex-int32.map seqindex-int64.map 
 CTYPES_MAPS = c-types.m32.map c-types.m64.map c-types.weird.map
 DEFAULT_CHAR_MAPS = default-char8.map
 DEFAULT_INT_MAPS = default-int32.map default-int64.map default-intinf.map 
 DEFAULT_WORD_MAPS = default-word32.map default-word64.map
-OBJPTR_REP_MAPS = objptr-rep32.map objptr-rep64.map 
-SEQ_INDEX_MAPS = seq-index32.map seq-index64.map 
 
 .PHONY: type-check
 type-check:
+	for objptrrep in $(OBJPTR_REP_MAPS); do \
+	for header in $(HEADER_MAPS); do \
+	for seqindex in $(SEQ_INDEX_MAPS); do \
 	for ctypes in $(CTYPES_MAPS); do \
 	for defchar in $(DEFAULT_CHAR_MAPS); do \
 	for defint in $(DEFAULT_INT_MAPS); do \
 	for defword in $(DEFAULT_WORD_MAPS); do \
-	for objptrrep in $(OBJPTR_REP_MAPS); do \
-	for seqindex in $(SEQ_INDEX_MAPS); do \
-	echo "Type checking: $$ctypes $$defchar $$defint $$defword $$objptrrep $$seqindex"; \
+	echo "Type checking: $$objptrrep $$header $$seqindex $$ctypes $$defchar $$defint $$defword"; \
 	$(MLTON) -disable-ann deadCode -stop tc -show-types true \
+		-mlb-path-map "maps/$$objptrrep" \
+		-mlb-path-map "maps/$$header" \
+		-mlb-path-map "maps/$$seqindex" \
 		-mlb-path-map "maps/$$ctypes" \
 		-mlb-path-map "maps/$$defchar" \
 		-mlb-path-map "maps/$$defint" \
 		-mlb-path-map "maps/$$defword" \
-		-mlb-path-map "maps/$$objptrrep" \
-		-mlb-path-map "maps/$$seqindex" \
 		build/sources.mlb; \
-	done; done; done; done; done; done
+	done; done; done; done; done; done; done

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-10 00:38:30 UTC (rev 4349)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/build/sources.mlb	2006-02-10 00:42:03 UTC (rev 4350)
@@ -20,9 +20,10 @@
    ../integer/int0.sml
    ../integer/word0.sml
    local ../config/bind-for-config0.sml in ann "forceUsed" in
-      ../config/c/misc/$(CTYPES)
       ../config/objptr/$(OBJPTR_REP)
+      ../config/header/$(HEADER_WORD)
       ../config/seq/$(SEQ_INDEX)
+      ../config/c/misc/$(CTYPES)
    end end
    ../integer/int-inf0.sml
    local ../config/bind-for-config0.sml in ann "forceUsed" in
@@ -31,9 +32,10 @@
       ../config/default/$(DEFAULT_WORD)
    end end
    local ../config/bind-for-config0.sml in ann "forceUsed" in
-      ../config/c/misc/$(CTYPES)
       ../config/objptr/$(OBJPTR_REP)
+      ../config/header/$(HEADER_WORD)
       ../config/seq/$(SEQ_INDEX)
+      ../config/c/misc/$(CTYPES)
    end end
 
 (*

Modified: mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/config/choose.sml
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/config/choose.sml	2006-02-10 00:38:30 UTC (rev 4349)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/config/choose.sml	2006-02-10 00:42:03 UTC (rev 4350)
@@ -5,6 +5,24 @@
  * See the file MLton-LICENSE for details.
  *)
 
+signature CHOOSE_CHARN_ARG =
+   sig
+      type 'a t
+      val fChar8: Char8.char t
+      val fChar16: Char16.char t
+      val fChar32: Char32.char t
+   end
+   
+functor ChooseCharN_Char8 (A : CHOOSE_CHARN_ARG) : 
+   sig val f : Char8.char A.t end = 
+   struct val f = A.fChar8 end
+functor ChooseCharN_Char16 (A : CHOOSE_CHARN_ARG) : 
+   sig val f : Char16.char A.t end = 
+   struct val f = A.fChar16 end
+functor ChooseCharN_Char32 (A : CHOOSE_CHARN_ARG) : 
+   sig val f : Char32.char A.t end = 
+   struct val f = A.fChar32 end
+
 signature CHOOSE_INTN_ARG =
    sig
       type 'a t
@@ -27,6 +45,32 @@
    sig val f : Int64.int A.t end = 
    struct val f = A.fInt64 end
 
+signature CHOOSE_INT_ARG =
+   sig
+      type 'a t
+      val fInt8: Int8.int t
+      val fInt16: Int16.int t
+      val fInt32: Int32.int t
+      val fInt64: Int64.int t
+      val fIntInf: IntInf.int t
+   end
+
+functor ChooseInt_Int8 (A : CHOOSE_INT_ARG) : 
+   sig val f : Int8.int A.t end = 
+   struct val f = A.fInt8 end
+functor ChooseInt_Int16 (A : CHOOSE_INT_ARG) : 
+   sig val f : Int16.int A.t end = 
+   struct val f = A.fInt16 end
+functor ChooseInt_Int32 (A : CHOOSE_INT_ARG) : 
+   sig val f : Int32.int A.t end = 
+   struct val f = A.fInt32 end
+functor ChooseInt_Int64 (A : CHOOSE_INT_ARG) : 
+   sig val f : Int64.int A.t end = 
+   struct val f = A.fInt64 end
+functor ChooseInt_IntInf (A : CHOOSE_INT_ARG) : 
+   sig val f : IntInf.int A.t end = 
+   struct val f = A.fIntInf end
+
 signature CHOOSE_REALN_ARG =
    sig
       type 'a t
@@ -41,6 +85,24 @@
    sig val f : Real64.real A.t end = 
    struct val f = A.fReal64 end
 
+signature CHOOSE_STRINGN_ARG =
+   sig
+      type 'a t
+      val fString8: String8.string t
+      val fString16: String16.string t
+      val fString32: String32.string t
+   end
+   
+functor ChooseStringN_String8 (A : CHOOSE_STRINGN_ARG) : 
+   sig val f : String8.string A.t end = 
+   struct val f = A.fString8 end
+functor ChooseStringN_String16 (A : CHOOSE_STRINGN_ARG) : 
+   sig val f : String16.string A.t end = 
+   struct val f = A.fString16 end
+functor ChooseStringN_String32 (A : CHOOSE_STRINGN_ARG) : 
+   sig val f : String32.string A.t end = 
+   struct val f = A.fString32 end
+
 signature CHOOSE_WORDN_ARG =
    sig
       type 'a t

Modified: mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/config/default/default-char8.sml
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/config/default/default-char8.sml	2006-02-10 00:38:30 UTC (rev 4349)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/config/default/default-char8.sml	2006-02-10 00:42:03 UTC (rev 4350)
@@ -9,3 +9,11 @@
 type char = Char.char
 structure String = String8
 type string = String.string
+
+functor Char_ChooseChar (A: CHOOSE_CHARN_ARG) :
+   sig val f : Char.char A.t end =
+   ChooseCharN_Char8 (A)
+
+functor String_ChooseString (A: CHOOSE_STRINGN_ARG) :
+   sig val f : String.string A.t end =
+   ChooseStringN_String8 (A)

Modified: mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/config/default/default-int32.sml
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/config/default/default-int32.sml	2006-02-10 00:38:30 UTC (rev 4349)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/config/default/default-int32.sml	2006-02-10 00:42:03 UTC (rev 4350)
@@ -8,26 +8,6 @@
 structure Int = Int32
 type int = Int.int
 
-functor CharAddToFromInt(type char
-                         val fromInt32 : Int32.int -> char
-                         val toInt32 : char -> Int32.int) =
-   struct
-      val fromInt = fromInt32
-      val toInt = toInt32
-   end
-functor IntAddToFromInt(type int
-                        val fromInt32 : Int32.int -> int
-                        val toInt32 : int -> Int32.int) =
-   struct
-      val fromInt = fromInt32
-      val toInt = toInt32
-   end
-functor WordAddToFromInt(type word
-                         val fromInt32 : Int32.int -> word
-                         val toInt32 : word -> Int32.int
-                         val toInt32X : word -> Int32.int) =
-   struct
-      val fromInt = fromInt32
-      val toInt = toInt32
-      val toIntX = toInt32X
-   end
+functor Int_ChooseInt (A: CHOOSE_INT_ARG) :
+   sig val f : Int.int A.t end =
+   ChooseInt_Int32 (A)

Modified: mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/config/default/default-int64.sml
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/config/default/default-int64.sml	2006-02-10 00:38:30 UTC (rev 4349)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/config/default/default-int64.sml	2006-02-10 00:42:03 UTC (rev 4350)
@@ -8,26 +8,6 @@
 structure Int = Int64
 type int = Int.int
 
-functor CharAddToFromInt(type char
-                         val fromInt64 : Int64.int -> char
-                         val toInt64 : char -> Int64.int) =
-   struct
-      val fromInt = fromInt64
-      val toInt = toInt64
-   end
-functor IntAddToFromInt(type int
-                        val fromInt64 : Int64.int -> int
-                        val toInt64 : int -> Int64.int) =
-   struct
-      val fromInt = fromInt64
-      val toInt = toInt64
-   end
-functor WordAddToFromInt(type word
-                         val fromInt64 : Int64.int -> word
-                         val toInt64 : word -> Int64.int
-                         val toInt64X : word -> Int64.int) =
-   struct
-      val fromInt = fromInt64
-      val toInt = toInt64
-      val toIntX = toInt64X
-   end
+functor Int_ChooseInt (A: CHOOSE_INT_ARG) :
+   sig val f : Int.int A.t end =
+   ChooseInt_Int64 (A)

Modified: mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/config/default/default-intinf.sml
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/config/default/default-intinf.sml	2006-02-10 00:38:30 UTC (rev 4349)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/config/default/default-intinf.sml	2006-02-10 00:42:03 UTC (rev 4350)
@@ -8,26 +8,6 @@
 structure Int = IntInf
 type int = Int.int
 
-functor CharAddToFromInt(type char
-                         val fromInt32 : Int32.int -> char
-                         val toInt32 : char -> Int32.int) =
-   struct
-      val fromInt = fromInt32
-      val toInt = toInt32
-   end
-functor IntAddToFromInt(type int
-                        val fromInt32 : Int32.int -> int
-                        val toInt32 : int -> Int32.int) =
-   struct
-      val fromInt = fromInt32
-      val toInt = toInt32
-   end
-functor WordAddToFromInt(type word
-                         val fromInt32 : Int32.int -> word
-                         val toInt32 : word -> Int32.int
-                         val toInt32X : word -> Int32.int) =
-   struct
-      val fromInt = fromInt32
-      val toInt = toInt32
-      val toIntX = toInt32X
-   end
+functor Int_ChooseInt (A: CHOOSE_INT_ARG) :
+   sig val f : Int.int A.t end =
+   ChooseInt_IntInf (A)

Modified: mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/config/default/default-word32.sml
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/config/default/default-word32.sml	2006-02-10 00:38:30 UTC (rev 4349)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/config/default/default-word32.sml	2006-02-10 00:42:03 UTC (rev 4350)
@@ -8,12 +8,6 @@
 structure Word = Word32
 type word = Word.word
 
-functor WordAddToFromWord(type word
-                          val fromWord32 : Word32.word -> word
-                          val toWord32 : word -> Word32.word
-                          val toWord32X : word -> Word32.word) =
-   struct
-      val fromWord = fromWord32
-      val toWord = toWord32
-      val toWordX = toWord32X
-   end
+functor Word_ChooseWordN (A: CHOOSE_WORDN_ARG) :
+   sig val f : Word.word A.t end =
+   ChooseWordN_Word32 (A)

Modified: mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/config/default/default-word64.sml
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/config/default/default-word64.sml	2006-02-10 00:38:30 UTC (rev 4349)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/config/default/default-word64.sml	2006-02-10 00:42:03 UTC (rev 4350)
@@ -8,12 +8,6 @@
 structure Word = Word64
 type word = Word.word
 
-functor WordAddToFromWord(type word
-                          val fromWord64 : Word64.word -> word
-                          val toWord64 : word -> Word64.word
-                          val toWord64X : word -> Word64.word) =
-   struct
-      val fromWord = fromWord64
-      val toWord = toWord64
-      val toWordX = toWord64X
-   end
+functor Word_ChooseWordN (A: CHOOSE_WORDN_ARG) :
+   sig val f : Word.word A.t end =
+   ChooseWordN_Word64 (A)

Copied: mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/config/header/header-word32.sml (from rev 4348, mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/config/seq/seq-index32.sml)
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/config/seq/seq-index32.sml	2006-02-05 15:30:17 UTC (rev 4348)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/config/header/header-word32.sml	2006-02-10 00:42:03 UTC (rev 4350)
@@ -0,0 +1,12 @@
+(* Copyright (C) 1999-2006 Henry Cejtin, Matthew Fluet, Suresh
+ *    Jagannathan, and Stephen Weeks.
+ *
+ * MLton is released under a BSD-style license.
+ * See the file MLton-LICENSE for details.
+ *)
+
+structure HeaderWord = Word32
+
+functor HeaderWord_ChooseWordN (A: CHOOSE_WORDN_ARG) :
+   sig val f : HeaderWord.word A.t end = 
+   ChooseWordN_Word32 (A)

Copied: mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/config/header/header-word64.sml (from rev 4348, mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/config/seq/seq-index64.sml)
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/config/seq/seq-index64.sml	2006-02-05 15:30:17 UTC (rev 4348)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/config/header/header-word64.sml	2006-02-10 00:42:03 UTC (rev 4350)
@@ -0,0 +1,12 @@
+(* Copyright (C) 1999-2006 Henry Cejtin, Matthew Fluet, Suresh
+ *    Jagannathan, and Stephen Weeks.
+ *
+ * MLton is released under a BSD-style license.
+ * See the file MLton-LICENSE for details.
+ *)
+
+structure HeaderWord = Word64
+
+functor HeaderWord_ChooseWordN (A: CHOOSE_WORDN_ARG) :
+   sig val f : HeaderWord.word A.t end = 
+   ChooseWordN_Word64 (A)

Deleted: mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/config/seq/seq-index32.sml
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/config/seq/seq-index32.sml	2006-02-10 00:38:30 UTC (rev 4349)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/config/seq/seq-index32.sml	2006-02-10 00:42:03 UTC (rev 4350)
@@ -1,12 +0,0 @@
-(* Copyright (C) 1999-2006 Henry Cejtin, Matthew Fluet, Suresh
- *    Jagannathan, and Stephen Weeks.
- *
- * MLton is released under a BSD-style license.
- * See the file MLton-LICENSE for details.
- *)
-
-structure SeqIndex = Int32
-
-functor SeqIndex_ChooseIntN (A: CHOOSE_INTN_ARG) :
-   sig val f : SeqIndex.int A.t end = 
-   ChooseIntN_Int32 (A)

Deleted: mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/config/seq/seq-index64.sml
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/config/seq/seq-index64.sml	2006-02-10 00:38:30 UTC (rev 4349)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/config/seq/seq-index64.sml	2006-02-10 00:42:03 UTC (rev 4350)
@@ -1,12 +0,0 @@
-(* Copyright (C) 1999-2006 Henry Cejtin, Matthew Fluet, Suresh
- *    Jagannathan, and Stephen Weeks.
- *
- * MLton is released under a BSD-style license.
- * See the file MLton-LICENSE for details.
- *)
-
-structure SeqIndex = Int64
-
-functor SeqIndex_ChooseIntN (A: CHOOSE_INTN_ARG) :
-   sig val f : SeqIndex.int A.t end = 
-   ChooseIntN_Int64 (A)

Copied: mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/config/seq/seqindex-int32.sml (from rev 4348, mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/config/seq/seq-index32.sml)

Copied: mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/config/seq/seqindex-int64.sml (from rev 4348, mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/config/seq/seq-index64.sml)

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-10 00:38:30 UTC (rev 4349)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/integer/int-inf0.sml	2006-02-10 00:42:03 UTC (rev 4350)
@@ -24,16 +24,20 @@
       val one: int
 
       val abs: int -> int
+      val +? : int * int -> int
       val + : int * int -> int
       val divMod: int * int -> int * int
       val div: int * int -> int
       val gcd: int * int -> int
       val mod: int * int -> int
+      val *? : int * int -> int
       val * : int * int -> int
+      val ~? : int -> int
       val ~ : int -> int
       val quotRem: int * int -> int * int
       val quot: int * int -> int
       val rem: int * int -> int
+      val -? : int * int -> int
       val - : int * int -> int
 
       val < : int * int -> bool
@@ -53,33 +57,39 @@
 
       val toString8: int -> Primitive.String8.string
 
+      (* Sign extend. *)
       val fromInt8: Primitive.Int8.int -> int
       val fromInt16: Primitive.Int16.int -> int
       val fromInt32: Primitive.Int32.int -> int
       val fromInt64: Primitive.Int64.int -> int
       val fromIntInf: Primitive.IntInf.int -> int
 
+      (* Zero extend. *)
       val fromWord8: Primitive.Word8.word -> int
       val fromWord16: Primitive.Word16.word -> int
       val fromWord32: Primitive.Word32.word -> int
       val fromWord64: Primitive.Word64.word -> int
 
+      (* Sign extend. *)
       val fromWordX8: Primitive.Word8.word -> int
       val fromWordX16: Primitive.Word16.word -> int
       val fromWordX32: Primitive.Word32.word -> int
       val fromWordX64: Primitive.Word64.word -> int
 
+      (* Overflow checking. *)
       val toInt8: int -> Primitive.Int8.int
       val toInt16: int -> Primitive.Int16.int
       val toInt32: int -> Primitive.Int32.int
       val toInt64: int -> Primitive.Int64.int
       val toIntInf: int -> Primitive.IntInf.int
 
+      (* Lowbits. *)
       val toWord8: int -> Primitive.Word8.word
       val toWord16: int -> Primitive.Word16.word
       val toWord32: int -> Primitive.Word32.word
       val toWord64: int -> Primitive.Word64.word
 
+      (* Lowbits. *)
       val toWordX8: int -> Primitive.Word8.word
       val toWordX16: int -> Primitive.Word16.word
       val toWordX32: int -> Primitive.Word32.word
@@ -98,7 +108,43 @@
       structure V = Primitive.Vector
       structure S = SeqIndex
 
-      structure W = ObjptrWord
+      structure W = struct
+                       open ObjptrWord
+                       local
+                          structure S =
+                             ObjptrInt_ChooseIntN
+                             (type 'a t = 'a -> ObjptrWord.word
+                              val fInt8 = ObjptrWord.fromInt8
+                              val fInt16 = ObjptrWord.fromInt16
+                              val fInt32 = ObjptrWord.fromInt32
+                              val fInt64 = ObjptrWord.fromInt64)
+                       in
+                          val fromObjptrInt = S.f
+                       end
+                       local
+                          structure S =
+                             ObjptrInt_ChooseIntN
+                             (type 'a t = ObjptrWord.word -> 'a
+                              val fInt8 = ObjptrWord.toInt8
+                              val fInt16 = ObjptrWord.toInt16
+                              val fInt32 = ObjptrWord.toInt32
+                              val fInt64 = ObjptrWord.toInt64)
+                       in
+                          val toObjptrInt = S.f
+                       end
+                       local
+                          structure S =
+                             ObjptrInt_ChooseIntN
+                             (type 'a t = ObjptrWord.word -> 'a
+                              val fInt8 = ObjptrWord.toIntX8
+                              val fInt16 = ObjptrWord.toIntX16
+                              val fInt32 = ObjptrWord.toIntX32
+                              val fInt64 = ObjptrWord.toIntX64)
+                       in
+                          val toObjptrIntX = S.f
+                       end
+                    end
+
       structure I = ObjptrInt
       structure MPLimb = C_MPLimb
       structure Sz = struct 
@@ -142,10 +188,10 @@
 
       fun dropTag (w: W.word): W.word = W.~>> (w, 0w1)
       fun dropTagCoerce (i: bigInt): W.word = dropTag (Prim.toWord i)
-      fun dropTagCoerceInt (i: bigInt): I.int = W.toIntXEq (dropTagCoerce i)
+      fun dropTagCoerceInt (i: bigInt): I.int = W.toObjptrIntX (dropTagCoerce i)
       fun addTag (w: W.word): W.word = W.orb (W.<< (w, 0w1), 0w1)
       fun addTagCoerce (w: W.word): bigInt = Prim.fromWord (addTag w)
-      fun addTagCoerceInt (i: I.int): bigInt = addTagCoerce (W.fromIntEq i)
+      fun addTagCoerceInt (i: I.int): bigInt = addTagCoerce (W.fromObjptrInt i)
       fun zeroTag (w: W.word): W.word = W.andb (w, W.notb 0w1)
       fun oneTag (w: W.word): W.word = W.orb (w, 0w1)
       fun oneTagCoerce (w: W.word): bigInt = Prim.fromWord (oneTag w)
@@ -155,394 +201,303 @@
             then Small (dropTagCoerceInt i)
             else Big (Prim.toVector i)
 
-      fun 'a buildBigInt {toMPLimb: 'a -> MPLimb.word,
-                          other : {zero: 'a,
-                                   eq: 'a * 'a -> bool,
-                                   rshift: 'a * Word32.word -> 'a}} 
-                         (isneg, ans) =
-         let
-            fun loop (ans, i, acc) =
-               if (#eq other) (ans, (#zero other))
-                  then (i, acc)
-                  else let
-                          val limb = toMPLimb ans
-                          val ans = (#rshift other) (ans, MPLimb.wordSizeWord')
-                       in
-                          loop (ans, S.+ (i, 1), (i, limb) :: acc)
-                       end
-            val (n, acc) = loop (ans, 1, [(0, if isneg then 0w1 else 0w0)])
-            val a = A.array n
-            fun loop acc =
-               case acc of
-                  [] => ()
-                | (i, v) :: acc => (A.update (a, i, v)
-                                    ; loop acc)
-            val () = loop acc
-         in
-            Prim.fromVector (V.fromArray a)
-         end
-
       local
          fun 'a make {toMPLimb: 'a -> MPLimb.word,
                       toObjptrWord: 'a -> ObjptrWord.word,
-                      toObjptrWordX: 'a -> ObjptrWord.word,
-                      other : {precision': Int32.int,
-                               zero: 'a,
-                               one: 'a,
-                               neg: 'a -> 'a,
-                               eq: 'a * 'a -> bool,
-                               lt: 'a * 'a -> bool,
-                               rashift: 'a * Word32.word -> 'a,
-                               rshift: 'a * Word32.word -> 'a}} =
-            let
-               fun fromInt i =
-                  if Int32.> (ObjptrWord.wordSize', #precision' other)
-                     then Prim.fromWord (addTag (toObjptrWordX i))
-                     else let
-                             val upperBits =
-                                (#rashift other)
-                                (i, Word32.- (ObjptrWord.wordSizeWord', 0w2))
-                          in
-                             if (#eq other) (upperBits, #zero other)
-                                orelse (#eq other) (upperBits, (#neg other) (#one other))
-                                then Prim.fromWord (addTag (toObjptrWord i))
-                                else let
-                                        val (isneg, ans) = 
-                                           if (#lt other) (i, (#zero other))
-                                              then (true, (#neg other) i)
-                                              else (false, i)
-                                     in
-                                        buildBigInt 
-                                        {toMPLimb = toMPLimb,
-                                         other = {zero = #zero other,
-                                                  eq = #eq other,
-                                                  rshift = #rshift other}}
-                                        (isneg, ans)
-                                     end
-                          end
-            in
-               fromInt
-            end
-      in
-         val fromInt8 =
-            make {toMPLimb = MPLimb.fromIntZ8,
-                  toObjptrWord = ObjptrWord.fromIntZ8,
-                  toObjptrWordX = ObjptrWord.fromInt8,
-                  other = {precision' = Int8.precision',
-                           zero = Int8.zero,
-                           one = Int8.one,
-                           neg = Int8.~,
-                           eq = ((op =) : Int8.int * Int8.int -> bool),
-                           lt = Int8.<,
-                           rashift = Int8.~>>,
-                           rshift = Int8.>>}}
-         val fromInt16 =
-            make {toMPLimb = MPLimb.fromIntZ16,
-                  toObjptrWord = ObjptrWord.fromIntZ16,
-                  toObjptrWordX = ObjptrWord.fromInt16,
-                  other = {precision' = Int16.precision',
-                           zero = Int16.zero,
-                           one = Int16.one,
-                           neg = Int16.~,
-                           eq = ((op =) : Int16.int * Int16.int -> bool),
-                           lt = Int16.<,
-                           rashift = Int16.~>>,
-                           rshift = Int16.>>}}
-         val fromInt32 =
-            make {toMPLimb = MPLimb.fromIntZ32,
-                  toObjptrWord = ObjptrWord.fromIntZ32,
-                  toObjptrWordX = ObjptrWord.fromInt32,
-                  other = {precision' = Int32.precision',
-                           zero = Int32.zero,
-                           one = Int32.one,
-                           neg = Int32.~,
-                           eq = ((op =) : Int32.int * Int32.int -> bool),
-                           lt = Int32.<,
-                           rashift = Int32.~>>,
-                           rshift = Int32.>>}}
-         val fromInt64 =
-            make {toMPLimb = MPLimb.fromIntZ64,
-                  toObjptrWord = ObjptrWord.fromIntZ64,
-                  toObjptrWordX = ObjptrWord.fromInt64,
-                  other = {precision' = Int64.precision',
-                           zero = Int64.zero,
-                           one = Int64.one,
-                           neg = Int64.~,
-                           eq = ((op =) : Int64.int * Int64.int -> bool),
-                           lt = Int64.<,
-                           rashift = Int64.~>>,
-                           rshift = Int64.>>}}
-         val fromIntInf = fn i => i
-      end
-
-      local
-         structure S =
-            ObjptrInt_ChooseIntN
-            (type 'a t = 'a -> bigInt
-             val fInt8 = fromInt8
-             val fInt16 = fromInt16
-             val fInt32 = fromInt32
-             val fInt64 = fromInt64)
-      in
-         val fromObjptrInt = S.f
-      end
-
-      local
-         fun 'a make {toMPLimb: 'a -> MPLimb.word,
-                      toObjptrWord: 'a -> ObjptrWord.word,
                       other : {wordSize': Int32.int,
                                zero: 'a,
-                               one: 'a,
                                eq: 'a * 'a -> bool,
-                               lt: 'a * 'a -> bool,
-                               rshift: 'a * Word32.word -> 'a}} =
-            let
-               fun fromWord w =
-                  if Int32.> (ObjptrWord.wordSize', #wordSize' other)
-                     then Prim.fromWord (addTag (toObjptrWord w))
-                     else let
-                             val upperBits =
-                                (#rshift other)
-                                (w, Word32.- (ObjptrWord.wordSizeWord', 0w2))
-                          in
-                             if (#eq other) (upperBits, #zero other)
-                                then Prim.fromWord (addTag (toObjptrWord w))
-                                else let
-                                        val ans = w
-                                     in
-                                        buildBigInt 
-                                        {toMPLimb = toMPLimb,
-                                         other = {zero = #zero other,
-                                                  eq = #eq other,
-                                                  rshift = #rshift other}}
-                                        (false, ans)
-                                     end
-                          end
-            in
-               fromWord
-            end
+                               rshift: 'a * Word32.word -> 'a}} 
+                     (isneg, w) =
+            if Int32.> (ObjptrWord.wordSize', #wordSize' other)
+               orelse let
+                         val upperBits =
+                            (#rshift other)
+                            (w, Word32.- (ObjptrWord.wordSizeWord', 0w2))
+                      in
+                         (#eq other) (upperBits, #zero other)
+                      end
+               then let
+                       val ans = toObjptrWord w
+                       val ans = if isneg then ObjptrWord.~ ans else ans
+                    in 
+                       Prim.fromWord (addTag ans)
+                    end
+               else let
+                       fun loop (w, i, acc) =
+                          if (#eq other) (w, (#zero other))
+                             then (i, acc)
+                             else 
+                                let
+                                   val limb = toMPLimb w
+                                   val w = 
+                                      (#rshift other) 
+                                      (w, MPLimb.wordSizeWord')
+                                in
+                                   loop (w, S.+ (i, 1), (i, limb) :: acc)
+                                end
+                       val (n, acc) = 
+                          loop (w, 1, [(0, if isneg then 0w1 else 0w0)])
+                       val a = A.array n
+                       fun loop acc =
+                          case acc of
+                             [] => ()
+                           | (i, v) :: acc => (A.updateUnsafe (a, i, v)
+                                               ; loop acc)
+                       val () = loop acc
+                    in
+                       Prim.fromVector (V.fromArray a)
+                    end
       in
-         val fromWord8 =
+         val fromWordAux8 =
             make {toMPLimb = MPLimb.fromWord8,
                   toObjptrWord = ObjptrWord.fromWord8,
                   other = {wordSize' = Word8.wordSize',
                            zero = Word8.zero,
-                           one = Word8.one,
                            eq = ((op =) : Word8.word * Word8.word -> bool),
-                           lt = Word8.<,
                            rshift = Word8.>>}}
-         val fromWord16 =
+         fun fromWord8 w = fromWordAux8 (false, w)
+         fun fromInt8 i =
+            if Int8.>= (i, 0)
+               then fromWordAux8 (false, Word8.fromInt8 i)
+               else fromWordAux8 (true, Word8.~ (Word8.fromInt8 i))
+         fun fromWordX8 w = fromInt8 (Word8.toIntX8 w)
+
+         val fromWordAux16 =
             make {toMPLimb = MPLimb.fromWord16,
                   toObjptrWord = ObjptrWord.fromWord16,
                   other = {wordSize' = Word16.wordSize',
                            zero = Word16.zero,
-                           one = Word16.one,
                            eq = ((op =) : Word16.word * Word16.word -> bool),
-                           lt = Word16.<,
                            rshift = Word16.>>}}
-         val fromWord32 =
+         fun fromWord16 w = fromWordAux16 (false, w)
+         fun fromInt16 i =
+            if Int16.>= (i, 0)
+               then fromWordAux16 (false, Word16.fromInt16 i)
+               else fromWordAux16 (true, Word16.~ (Word16.fromInt16 i))
+         fun fromWordX16 w = fromInt16 (Word16.toIntX16 w)
+
+         val fromWordAux32 =
             make {toMPLimb = MPLimb.fromWord32,
                   toObjptrWord = ObjptrWord.fromWord32,
                   other = {wordSize' = Word32.wordSize',
                            zero = Word32.zero,
-                           one = Word32.one,
                            eq = ((op =) : Word32.word * Word32.word -> bool),
-                           lt = Word32.<,
                            rshift = Word32.>>}}
-         val fromWord64 =
+         fun fromWord32 w = fromWordAux32 (false, w)
+         fun fromInt32 i =
+            if Int32.>= (i, 0)
+               then fromWordAux32 (false, Word32.fromInt32 i)
+               else fromWordAux32 (true, Word32.~ (Word32.fromInt32 i))
+         fun fromWordX32 w = fromInt32 (Word32.toIntX32 w)
+
+         val fromWordAux64 =
             make {toMPLimb = MPLimb.fromWord64,
                   toObjptrWord = ObjptrWord.fromWord64,
                   other = {wordSize' = Word64.wordSize',
                            zero = Word64.zero,
-                           one = Word64.one,
                            eq = ((op =) : Word64.word * Word64.word -> bool),
-                           lt = Word64.<,
                            rshift = Word64.>>}}
+         fun fromWord64 w = fromWordAux64 (false, w)
+         fun fromInt64 i =
+            if Int64.>= (i, 0)
+               then fromWordAux64 (false, Word64.fromInt64 i)
+               else fromWordAux64 (true, Word64.~ (Word64.fromInt64 i))
+         fun fromWordX64 w = fromInt64 (Word64.toIntX64 w)
+
+         fun fromIntInf i = i
       end
 
-      val fromWordX8 : Word8.word -> bigInt =
-         fn w => fromInt8 (Int8.fromWordX8 w)
-      val fromWordX16 : Word16.word -> bigInt =
-         fn w => fromInt16 (Int16.fromWordX16 w)
-      val fromWordX32 : Word32.word -> bigInt =
-         fn w => fromInt32 (Int32.fromWordX32 w)
-      val fromWordX64 : Word64.word -> bigInt =
-         fn w => fromInt64 (Int64.fromWordX64 w)
-
       local
-         fun 'a make {fromMPLimb: MPLimb.word -> 'a,
-                      fromObjptrWordX: ObjptrWord.word -> 'a, 
-                      other : {precision': Int32.int,
-                               zero: 'a,
-                               lshift: 'a * Word32.word -> 'a,
-                               neg: 'a -> 'a,
-                               orb: 'a * 'a -> 'a}} =
-            let
-               val limbsPer =
-                  if Int32.>= (MPLimb.wordSize', #precision' other)
-                     then 1
-                     else S.fromInt32 (Int32.quot (#precision' other, MPLimb.wordSize'))
-               fun toInt i =
-                  if isSmall i
-                     then fromObjptrWordX (dropTagCoerce i)
-                     else if Int32.> (ObjptrWord.wordSize', #precision' other)
-                             then raise Overflow
-                             else 
-                             let
-                                val v = Prim.toVector i
-                                val n = V.length v
-                                val isneg = V.sub (v, 0) <> 0w0
-                                val ans =
-                                   if S.> (S.- (n, 1), limbsPer)
-                                      then raise Overflow
-                                   else if Int32.>= (MPLimb.wordSize', #precision' other)
-                                      then fromMPLimb (V.sub (v, 1))
-                                   else 
-                                   let
-                                      fun loop (i, ans) =
-                                         if S.> (i, 0)
-                                            then let
-                                                    val ans = 
-                                                       (#orb other) 
-                                                       ((#lshift other) 
-                                                        (ans, MPLimb.wordSizeWord'),
-                                                        fromMPLimb (V.sub (v, i)))
-                                                 in
-                                                    loop (S.- (i, 1), ans)
-                                                 end
-                                            else ans
-                                   in
-                                      loop (S.- (n, 1), #zero other)
-                                   end
-                             in
-                                if isneg then (#neg other) ans else ans
-                             end
-            in
-               toInt
-            end
+         structure S =
+            ObjptrInt_ChooseIntN
+            (type 'a t = 'a -> bigInt
+             val fInt8 = fromInt8
+             val fInt16 = fromInt16
+             val fInt32 = fromInt32
+             val fInt64 = fromInt64)
       in
-         val toInt8 =
-            make {fromMPLimb = MPLimb.toInt8,
-                  fromObjptrWordX = ObjptrWord.toIntX8,
-                  other = {precision' = Int8.precision',
-                           zero = Int8.zero,
-                           lshift = Int8.<<,
-                           neg = Int8.~,
-                           orb = Int8.orb}}
-         val toInt16 =
-            make {fromMPLimb = MPLimb.toInt16,
-                  fromObjptrWordX = ObjptrWord.toIntX16,
-                  other = {precision' = Int16.precision',
-                           zero = Int16.zero,
-                           lshift = Int16.<<,
-                           neg = Int16.~,
-                           orb = Int16.orb}}
-         val toInt32 =
-            make {fromMPLimb = MPLimb.toInt32,
-                  fromObjptrWordX = ObjptrWord.toIntX32,
-                  other = {precision' = Int32.precision',
-                           zero = Int32.zero,
-                           lshift = Int32.<<,
-                           neg = Int32.~,
-                           orb = Int32.orb}}
-         val toInt64 =
-            make {fromMPLimb = MPLimb.toInt64,
-                  fromObjptrWordX = ObjptrWord.toIntX64,
-                  other = {precision' = Int64.precision',
-                           zero = Int64.zero,
-                           lshift = Int64.<<,
-                           neg = Int64.~,
-                           orb = Int64.orb}}
-         val toIntInf = fn i => i
+         val fromObjptrInt = S.f
       end
 
       local
+         datatype 'a ans =
+            Big of bool * bool * 'a
+          | Small of ObjptrWord.word
          fun 'a make {fromMPLimb: MPLimb.word -> 'a,
-                      fromObjptrWordX: ObjptrWord.word -> 'a, 
                       other : {wordSize': Int32.int,
+                               wordSizeWord': Word32.word,
                                zero: 'a,
                                lshift: 'a * Word32.word -> 'a,
-                               neg: 'a -> 'a,
-                               orb: 'a * 'a -> 'a}} = 
-            let
-               val limbsPer =
-                  if Int32.>= (MPLimb.wordSize', #wordSize' other)
-                     then 1
-                     else S.fromInt32 (Int32.quot (#wordSize' other, MPLimb.wordSize'))
-               fun toWord i =
-                  if isSmall i
-                     then fromObjptrWordX (dropTagCoerce i)
-                     else let
-                             val v = Prim.toVector i
-                             val n = V.length v
-                             val isneg = V.sub (v, 0) <> 0w0
-                             val ans =
-                                let
-                                   fun loop (i, ans) =
-                                      if S.> (i, 0)
-                                         then let
-                                                 val ans = 
-                                                    (#orb other) 
-                                                    ((#lshift other) 
-                                                     (ans, MPLimb.wordSizeWord'),
-                                                     fromMPLimb (V.sub (v, i)))
-                                              in
-                                                 loop (S.- (i, 1), ans)
-                                              end
-                                         else ans
-                                in
-                                   loop (S.min (S.- (n, 1), limbsPer), #zero other)
-                                end
-                          in
-                             if isneg then (#neg other) ans else ans
-                          end
-            in
-               toWord
-            end
+                               orb: 'a * 'a -> 'a}} i =
+            if isSmall i
+               then Small (dropTagCoerce i)
+               else let
+                       val v = Prim.toVector i
+                       val n = V.length v
+                       val isneg = V.subUnsafe (v, 0) <> 0w0
+                    in
+                       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
+                                  val ans = fromMPLimb limb
+                               in
+                                  Big (isneg, extra, ans)
+                               end
+                          else let
+                                  val limbsPer =
+                                     S.fromInt32 (Int32.quot (#wordSize' other, 
+                                                              MPLimb.wordSize'))
+                                  val extra =
+                                     S.> (n, S.+ (limbsPer, 1))
+                                  val ans =
+                                     let
+                                        fun loop (i, ans) =
+                                           if S.> (i, 0)
+                                              then let
+                                                      val limb = V.subUnsafe (v, i)
+                                                      val ans = 
+                                                         (#orb other) 
+                                                         ((#lshift other) 
+                                                          (ans, MPLimb.wordSizeWord'),
+                                                          fromMPLimb limb)
+                                                   in
+                                                      loop (S.- (i, 1), ans)
+                                                   end
+                                              else ans
+                                     in
+                                        loop (S.min (S.- (n, 1), limbsPer), #zero other)
+                                     end
+                               in
+                                  Big (isneg, extra, ans)
+                               end
+                    end
       in
-         val toWord8 =
+         val toWordAux8 =
             make {fromMPLimb = MPLimb.toWord8,
-                  fromObjptrWordX = ObjptrWord.toWordX8,
                   other = {wordSize' = Word8.wordSize',
+                           wordSizeWord' = Word8.wordSizeWord',
                            zero = Word8.zero,
                            lshift = Word8.<<,
-                           neg = Word8.~,
                            orb = Word8.orb}}
-         val toWordX8 = toWord8
-         val toWord16 =
+         fun toWordX8 i =
+            case toWordAux8 i of
+               Small w => ObjptrWord.toWordX8 w
+             | Big (isneg, _, ans) => if isneg then Word8.~ ans else ans
+         fun toWord8 i = toWordX8 i
+         fun toInt8 i =
+            case toWordAux8 i of
+               Small w => ObjptrWord.toIntX8 w
+             | Big (isneg, extra, ans) =>
+                  if extra
+                     then raise Overflow
+                  else if isneg
+                     then let
+                             val ans = Word8.toIntX8 (Word8.~ ans)
+                          in
+                             if Int8.>= (ans, 0)
+                                then raise Overflow
+                                else ans
+                          end
+                  else Word8.toInt8 ans
+
+         val toWordAux16 =
             make {fromMPLimb = MPLimb.toWord16,
-                  fromObjptrWordX = ObjptrWord.toWordX16,
                   other = {wordSize' = Word16.wordSize',
+                           wordSizeWord' = Word16.wordSizeWord',
                            zero = Word16.zero,
                            lshift = Word16.<<,
-                           neg = Word16.~,
                            orb = Word16.orb}}
-         val toWordX16 = toWord16
-         val toWord32 =
+         fun toWordX16 i =
+            case toWordAux16 i of
+               Small w => ObjptrWord.toWordX16 w
+             | Big (isneg, _, ans) => if isneg then Word16.~ ans else ans
+         fun toWord16 i = toWordX16 i
+         fun toInt16 i =
+            case toWordAux16 i of
+               Small w => ObjptrWord.toIntX16 w
+             | Big (isneg, extra, ans) =>
+                  if extra
+                     then raise Overflow
+                  else if isneg
+                     then let
+                             val ans = Word16.toIntX16 (Word16.~ ans)
+                          in
+                             if Int16.>= (ans, 0)
+                                then raise Overflow
+                                else ans
+                          end
+                  else Word16.toInt16 ans
+                           
+         val toWordAux32 =
             make {fromMPLimb = MPLimb.toWord32,
-                  fromObjptrWordX = ObjptrWord.toWordX32,
                   other = {wordSize' = Word32.wordSize',
+                           wordSizeWord' = Word32.wordSizeWord',
                            zero = Word32.zero,
                            lshift = Word32.<<,
-                           neg = Word32.~,
                            orb = Word32.orb}}
-         val toWordX32 = toWord32
-         val toWord64 =
+         fun toWordX32 i =
+            case toWordAux32 i of
+               Small w => ObjptrWord.toWordX32 w
+             | Big (isneg, _, ans) => if isneg then Word32.~ ans else ans
+         fun toWord32 i = toWordX32 i
+         fun toInt32 i =
+            case toWordAux32 i of
+               Small w => ObjptrWord.toIntX32 w
+             | Big (isneg, extra, ans) =>
+                  if extra
+                     then raise Overflow
+                  else if isneg
+                     then let
+                             val ans = Word32.toIntX32 (Word32.~ ans)
+                          in
+                             if Int32.>= (ans, 0)
+                                then raise Overflow
+                                else ans
+                          end
+                  else Word32.toInt32 ans
+
+         val toWordAux64 =
             make {fromMPLimb = MPLimb.toWord64,
-                  fromObjptrWordX = ObjptrWord.toWordX64,
                   other = {wordSize' = Word64.wordSize',
+                           wordSizeWord' = Word64.wordSizeWord',
                            zero = Word64.zero,
                            lshift = Word64.<<,
-                           neg = Word64.~,
                            orb = Word64.orb}}
-         val toWordX64 = toWord64
+         fun toWordX64 i =
+            case toWordAux64 i of
+               Small w => ObjptrWord.toWordX64 w
+             | Big (isneg, _, ans) => if isneg then Word64.~ ans else ans
+         fun toWord64 i = toWordX64 i
+         fun toInt64 i =
+            case toWordAux64 i of
+               Small w => ObjptrWord.toIntX64 w
+             | Big (isneg, extra, ans) =>
+                  if extra
+                     then raise Overflow
+                  else if isneg
+                     then let
+                             val ans = Word64.toIntX64 (Word64.~ ans)
+                          in
+                             if Int64.>= (ans, 0)
+                                then raise Overflow
+                                else ans
+                          end
+                  else Word64.toInt64 ans
+
+         fun toIntInf i = i
       end
 
       local
          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 4
+         val bytesPerHeader = Sz.fromInt32 (Int32.quot (HeaderWord.wordSize', 8))
       in
          val bytesPerArrayHeader =
             Sz.+ (bytesPerCounter, Sz.+ (bytesPerLength, bytesPerHeader))
@@ -563,20 +518,20 @@
        * negBadIntInf is the negation (and absolute value) of that IntInf.int.
        *)
       val badObjptrInt: I.int = I.~>> (I.minInt', 0w1)
-      val badObjptrWord: W.word = W.fromIntEq badObjptrInt
+      val badObjptrWord: W.word = W.fromObjptrInt badObjptrInt
       val badObjptrWordTagged: W.word = addTag badObjptrWord
-      val badObjptrIntTagged: I.int = W.toIntXEq badObjptrWordTagged
+      val badObjptrIntTagged: I.int = W.toObjptrIntX badObjptrWordTagged
       val negBadIntInf: bigInt = fromObjptrInt (I.~ badObjptrInt)
 
       (* Given two ObjptrWord.word's, check if they have the same `high'/'sign' bit.
        *)
       fun sameSignBit (lhs: W.word, rhs: W.word): bool =
-         I.>= (W.toIntXEq (W.xorb (lhs, rhs)), 0)
+         I.>= (W.toObjptrIntX (W.xorb (lhs, rhs)), 0)
 
       (* Given a bignum bigint, test if it is (strictly) negative.
        *)
       fun bigIsNeg (arg: bigInt): bool =
-         V.sub (Prim.toVector arg, 0) <> 0w0
+         V.subUnsafe (Prim.toVector arg, 0) <> 0w0
 
       local
          fun make (smallOp, bigOp, limbsFn, extra)
@@ -586,11 +541,11 @@
                   if areSmall (lhs, rhs)
                      then let
                              val lhsw = dropTagCoerce lhs
-                             val lhsi = W.toIntXEq lhsw
+                             val lhsi = W.toObjptrIntX lhsw
                              val rhsw = dropTagCoerce rhs
-                             val rhsi = W.toIntXEq rhsw
+                             val rhsi = W.toObjptrIntX rhsw
                              val ansi = smallOp (lhsi, rhsi)
-                             val answ = W.fromIntEq ansi
+                             val answ = W.fromObjptrInt ansi
                              val ans = addTag answ
                           in
                              if sameSignBit (ans, answ)
@@ -626,16 +581,16 @@
          if areSmall (num, den)
             then let
                     val numw = dropTagCoerce num
-                    val numi = W.toIntXEq numw
+                    val numi = W.toObjptrIntX numw
                     val denw = dropTagCoerce den
-                    val deni = W.toIntXEq numw
+                    val deni = W.toObjptrIntX numw
                  in
                     if numw = badObjptrWord 
                        andalso deni = ~1
                        then negBadIntInf
                        else let
                                val ansi = I.quot (numi, deni)
-                               val answ = W.fromIntEq ansi
+                               val answ = W.fromObjptrInt ansi
                                val ans = addTag answ
                             in 
                                Prim.fromWord ans
@@ -650,18 +605,18 @@
                        else if den = zero
                                then raise Div
                                else Prim.quot (num, den, 
-                                               reserve (S.- (nlimbs, dlimbs), 1))
+                                               reserve (S.- (nlimbs, dlimbs), 2))
                  end
 
       fun bigRem (num: bigInt, den: bigInt): bigInt =
          if areSmall (num, den)
             then let 
                     val numw = dropTagCoerce num
-                    val numi = W.toIntXEq numw
+                    val numi = W.toObjptrIntX numw
                     val denw = dropTagCoerce den
-                    val deni = W.toIntXEq numw
+                    val deni = W.toObjptrIntX numw
                     val ansi = I.rem (numi, deni)
-                    val answ = W.fromIntEq ansi
+                    val answ = W.fromObjptrInt ansi
                     val ans = addTag answ
                  in 
                     Prim.fromWord ans
@@ -727,16 +682,16 @@
 
       fun bigCompare (lhs: bigInt, rhs: bigInt): order =
          if areSmall (lhs, rhs)
-            then I.compare (W.toIntXEq (Prim.toWord lhs),
-                            W.toIntXEq (Prim.toWord rhs))
+            then I.compare (W.toObjptrIntX (Prim.toWord lhs),
+                            W.toObjptrIntX (Prim.toWord rhs))
             else Int32.compare (Prim.compare (lhs, rhs), 0)
 
       local
          fun make (smallTest, int32Test)
                   (lhs: bigInt, rhs: bigInt): bool =
             if areSmall (lhs, rhs)
-               then smallTest (W.toIntXEq (Prim.toWord lhs),
-                               W.toIntXEq (Prim.toWord rhs))
+               then smallTest (W.toObjptrIntX (Prim.toWord lhs),
+                               W.toObjptrIntX (Prim.toWord rhs))
                else int32Test (Prim.compare (lhs, rhs), 0)
       in
          val bigLT = make (I.<, Int32.<)
@@ -752,7 +707,7 @@
                  in 
                     if argw = badObjptrWordTagged
                        then negBadIntInf
-                       else if I.< (W.toIntXEq argw, 0)
+                       else if I.< (W.toObjptrIntX argw, 0)
                                then Prim.fromWord (W.- (0w2, argw))
                                else arg
                  end
@@ -872,16 +827,20 @@
       val minInt = NONE
 
       val abs = bigAbs
+      val op +? = bigAdd
       val op + = bigAdd
       val divMod = bigDivMod
       val op div = bigDiv
       val gcd = bigGcd
       val op mod = bigMod
+      val op *? = bigMul
       val op * = bigMul
+      val op ~? = bigNeg
       val op ~ = bigNeg
       val quotRem = bigQuotRem
       val quot = bigQuot
       val rem = bigRem
+      val op -? = bigSub
       val op - = bigSub
 
       val op < = bigLT

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-10 00:38:30 UTC (rev 4349)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/integer/int0.sml	2006-02-10 00:42:03 UTC (rev 4350)
@@ -34,31 +34,37 @@
       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
       val fromInt32: Primitive.Int32.int -> int
       val fromInt64: Primitive.Int64.int -> int
 
+      (* Overflow checking, unsigned interp. *)
       val fromWord8: Primitive.Word8.word -> int
       val fromWord16: Primitive.Word16.word -> int
       val fromWord32: Primitive.Word32.word -> int
       val fromWord64: Primitive.Word64.word -> int
 
+      (* Overflow checking, signed interp. *)
       val fromWordX8: Primitive.Word8.word -> int
       val fromWordX16: Primitive.Word16.word -> int
       val fromWordX32: Primitive.Word32.word -> int
       val fromWordX64: Primitive.Word64.word -> int
 
+      (* Overflow checking. *)
       val toInt8: int -> Primitive.Int8.int
       val toInt16: int -> Primitive.Int16.int
       val toInt32: int -> Primitive.Int32.int
       val toInt64: int -> Primitive.Int64.int
 
+      (* Lowbits or zero extend. *)
       val toWord8: int -> Primitive.Word8.word
       val toWord16: int -> Primitive.Word16.word
       val toWord32: int -> Primitive.Word32.word
       val toWord64: int -> Primitive.Word64.word
 
+      (* Lowbits or sign extend. *)
       val toWordX8: int -> Primitive.Word8.word
       val toWordX16: int -> Primitive.Word16.word
       val toWordX32: int -> Primitive.Word32.word

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-10 00:38:30 UTC (rev 4349)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/integer/word0.sml	2006-02-10 00:42:03 UTC (rev 4350)
@@ -24,45 +24,49 @@
       val ror : word * Primitive.Word32.word -> word
       val ~>> : word * Primitive.Word32.word -> word
 
+      (* Lowbits or sign extend. *)
       val fromInt8: Primitive.Int8.int -> word
       val fromInt16: Primitive.Int16.int -> word
       val fromInt32: Primitive.Int32.int -> word
       val fromInt64: Primitive.Int64.int -> word
-      val fromIntEq: intEq -> word
-         
+
+      (* Lowbits or zero extend. *)
       val fromIntZ8: Primitive.Int8.int -> word
       val fromIntZ16: Primitive.Int16.int -> word
       val fromIntZ32: Primitive.Int32.int -> word
       val fromIntZ64: Primitive.Int64.int -> word
-      val fromIntZEq: intEq -> word
 
+      (* Lowbits or zero extend. *)
       val fromWord8: Primitive.Word8.word -> word
       val fromWord16: Primitive.Word16.word -> word
       val fromWord32: Primitive.Word32.word -> word
       val fromWord64: Primitive.Word64.word -> word
          
+      (* Lowbits or sign extend. *)
       val fromWordX8: Primitive.Word8.word -> word
       val fromWordX16: Primitive.Word16.word -> word
       val fromWordX32: Primitive.Word32.word -> word
       val fromWordX64: Primitive.Word64.word -> word
 
+      (* Overflow checking, unsigned interp. *)
       val toInt8: word -> Primitive.Int8.int
       val toInt16: word -> Primitive.Int16.int
       val toInt32: word -> Primitive.Int32.int
       val toInt64: word -> Primitive.Int64.int
-      val toIntEq: word -> intEq
-         
+
+      (* Overflow checking, signed interp. *)
       val toIntX8: word -> Primitive.Int8.int
       val toIntX16: word -> Primitive.Int16.int
       val toIntX32: word -> Primitive.Int32.int
       val toIntX64: word -> Primitive.Int64.int   
-      val toIntXEq: word -> intEq
 
+      (* Lowbits or zero extend. *)
       val toWord8: word -> Primitive.Word8.word
       val toWord16: word -> Primitive.Word16.word
       val toWord32: word -> Primitive.Word32.word
       val toWord64: word -> Primitive.Word64.word
-         
+
+      (* Lowbits or sign extend. *)
       val toWordX8: word -> Primitive.Word8.word
       val toWordX16: word -> Primitive.Word16.word
       val toWordX32: word -> Primitive.Word32.word
@@ -180,15 +184,6 @@
                   other = {precision' = Primitive.Int64.precision',
                            maxInt' = Primitive.Int64.maxInt',
                            minInt' = Primitive.Int64.minInt'}}
-         val (fromIntEq, fromIntZEq, toIntEq, toIntXEq) =
-            (fromIntEqUnsafe, 
-             fromIntZEqUnsafe,
-             fn w =>
-             if detectOverflow
-                andalso w > (>> (notb zero, 0w1))
-                then raise Overflow
-                else toIntEqUnsafe w,
-                   toIntXEqUnsafe)
       end
 
       val (fromWord8, fromWordX8, toWord8, toWordX8) =

Added: mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/maps/header-word32.map
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/maps/header-word32.map	2006-02-10 00:38:30 UTC (rev 4349)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/maps/header-word32.map	2006-02-10 00:42:03 UTC (rev 4350)
@@ -0,0 +1 @@
+HEADER_WORD header-word32.sml

Added: mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/maps/header-word64.map
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/maps/header-word64.map	2006-02-10 00:38:30 UTC (rev 4349)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/maps/header-word64.map	2006-02-10 00:42:03 UTC (rev 4350)
@@ -0,0 +1 @@
+HEADER_WORD header-word64.sml

Deleted: mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/maps/seq-index32.map
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/maps/seq-index32.map	2006-02-10 00:38:30 UTC (rev 4349)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/maps/seq-index32.map	2006-02-10 00:42:03 UTC (rev 4350)
@@ -1 +0,0 @@
-SEQ_INDEX seq-index32.sml

Deleted: mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/maps/seq-index64.map
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/maps/seq-index64.map	2006-02-10 00:38:30 UTC (rev 4349)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/maps/seq-index64.map	2006-02-10 00:42:03 UTC (rev 4350)
@@ -1 +0,0 @@
-SEQ_INDEX seq-index64.sml

Copied: mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/maps/seqindex-int32.map (from rev 4348, mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/maps/seq-index32.map)
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/maps/seq-index32.map	2006-02-05 15:30:17 UTC (rev 4348)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/maps/seqindex-int32.map	2006-02-10 00:42:03 UTC (rev 4350)
@@ -0,0 +1 @@
+SEQ_INDEX seqindex-int32.sml

Copied: mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/maps/seqindex-int64.map (from rev 4348, mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/maps/seq-index64.map)
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/maps/seq-index64.map	2006-02-05 15:30:17 UTC (rev 4348)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/maps/seqindex-int64.map	2006-02-10 00:42:03 UTC (rev 4350)
@@ -0,0 +1 @@
+SEQ_INDEX seqindex-int64.sml

Modified: mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/misc/reader.sig
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/misc/reader.sig	2006-02-10 00:38:30 UTC (rev 4349)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/misc/reader.sig	2006-02-10 00:42:03 UTC (rev 4350)
@@ -14,8 +14,8 @@
       val list: ('a, 'b) reader -> ('a list, 'b) reader
 
       (* never return NONE *)
-(*      val tokens: ('a -> bool) -> ('a, 'b) reader -> ('a list list, 'b) reader*)
-(*      val fields: ('a -> bool) -> ('a, 'b) reader -> ('a list list, 'b) reader *)
+      (* val tokens: ('a -> bool) -> ('a, 'b) reader -> ('a list list, 'b) reader *)
+      (* val fields: ('a -> bool) -> ('a, 'b) reader -> ('a list list, 'b) reader *)
          
       val map: ('a -> 'c) -> ('a, 'b) reader -> ('c, 'b) reader
       val mapOpt: ('a -> 'c option) -> ('a, 'b) reader -> ('c, 'b) reader

Modified: mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/primitive/basis-ffi.sml
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/primitive/basis-ffi.sml	2006-02-10 00:38:30 UTC (rev 4349)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/primitive/basis-ffi.sml	2006-02-10 00:42:03 UTC (rev 4350)
@@ -983,6 +983,8 @@
 structure Stdio = 
 struct
 val print = _import "Stdio_print" : String8.t -> unit;
+val printStderr = _import "Stdio_printStderr" : String8.t -> unit;
+val printStdout = _import "Stdio_printStdout" : String8.t -> unit;
 end
 structure Time = 
 struct

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-10 00:38:30 UTC (rev 4349)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/primitive/prim-int.sml	2006-02-10 00:42:03 UTC (rev 4350)
@@ -50,45 +50,53 @@
       val >>? : int * Primitive.Word32.word -> int
       val xorb: int * int -> int
 
-      type wordEq
-
+      (* Lowbits or sign extend. *)
       val fromInt8Unsafe: Primitive.Int8.int -> int
       val fromInt16Unsafe: Primitive.Int16.int -> int
       val fromInt32Unsafe: Primitive.Int32.int -> int
       val fromInt64Unsafe: Primitive.Int64.int -> int
+
+      (* Lowbits or zero extend. *)
       val fromIntZ8Unsafe: Primitive.Int8.int -> int
       val fromIntZ16Unsafe: Primitive.Int16.int -> int
       val fromIntZ32Unsafe: Primitive.Int32.int -> int
       val fromIntZ64Unsafe: Primitive.Int64.int -> int
+
+      (* Lowbits or zero extend. *)
       val fromWord8Unsafe: Primitive.Word8.word -> int
       val fromWord16Unsafe: Primitive.Word16.word -> int
       val fromWord32Unsafe: Primitive.Word32.word -> int
       val fromWord64Unsafe: Primitive.Word64.word -> int
-      val fromWordEqUnsafe: wordEq -> int
+
+      (* Lowbits or sign extend. *)
       val fromWordX8Unsafe: Primitive.Word8.word -> int
       val fromWordX16Unsafe: Primitive.Word16.word -> int
       val fromWordX32Unsafe: Primitive.Word32.word -> int
       val fromWordX64Unsafe: Primitive.Word64.word -> int
-      val fromWordXEqUnsafe: wordEq -> int
 
+      (* Lowbits or sign extend. *)
       val toInt8Unsafe: int -> Primitive.Int8.int
       val toInt16Unsafe: int -> Primitive.Int16.int
       val toInt32Unsafe: int -> Primitive.Int32.int
       val toInt64Unsafe: int -> Primitive.Int64.int
+
+      (* Lowbits or zero extend. *)
       val toIntZ8Unsafe: int -> Primitive.Int8.int
       val toIntZ16Unsafe: int -> Primitive.Int16.int
       val toIntZ32Unsafe: int -> Primitive.Int32.int
       val toIntZ64Unsafe: int -> Primitive.Int64.int
+
+      (* Lowbits or zero extend. *)
       val toWord8Unsafe: int -> Primitive.Word8.word
       val toWord16Unsafe: int -> Primitive.Word16.word
       val toWord32Unsafe: int -> Primitive.Word32.word
       val toWord64Unsafe: int -> Primitive.Word64.word
-      val toWordEqUnsafe: int -> wordEq
+
+      (* Lowbits or sign extend. *)
       val toWordX8Unsafe: int -> Primitive.Word8.word
       val toWordX16Unsafe: int -> Primitive.Word16.word
       val toWordX32Unsafe: int -> Primitive.Word32.word
       val toWordX64Unsafe: int -> Primitive.Word64.word
-      val toWordXEqUnsafe: int -> wordEq
    end
 
 structure Primitive = struct
@@ -193,8 +201,6 @@
       val >>? = _prim "WordU8_rshift": int * Word32.word -> int;
       val xorb = _prim "Word8_xorb": int * int -> int;
 
-      type wordEq = Word8.word
-
       val fromInt8Unsafe = _prim "WordS8_toWord8": Int8.int -> int;
       val fromInt16Unsafe = _prim "WordS16_toWord8": Int16.int -> int;
       val fromInt32Unsafe = _prim "WordS32_toWord8": Int32.int -> int;
@@ -209,13 +215,11 @@
       val fromWord16Unsafe = _prim "WordU16_toWord8": Word16.word -> int;
       val fromWord32Unsafe = _prim "WordU32_toWord8": Word32.word -> int;
       val fromWord64Unsafe = _prim "WordU64_toWord8": Word64.word -> int;
-      val fromWordEqUnsafe = fromWord8Unsafe
 
       val fromWordX8Unsafe = _prim "WordS8_toWord8": Word8.word -> int;
       val fromWordX16Unsafe = _prim "WordS16_toWord8": Word16.word -> int;
       val fromWordX32Unsafe = _prim "WordS32_toWord8": Word32.word -> int;
       val fromWordX64Unsafe = _prim "WordS64_toWord8": Word64.word -> int;
-      val fromWordXEqUnsafe = fromWordX8Unsafe
 
       val toInt8Unsafe = _prim "WordS8_toWord8": int -> Int8.int;
       val toInt16Unsafe = _prim "WordS8_toWord16": int -> Int16.int;
@@ -231,13 +235,11 @@
       val toWord16Unsafe = _prim "WordU8_toWord16": int -> Word16.word;
       val toWord32Unsafe = _prim "WordU8_toWord32": int -> Word32.word;
       val toWord64Unsafe = _prim "WordU8_toWord64": int -> Word64.word;
-      val toWordEqUnsafe = toWord8Unsafe
 
       val toWordX8Unsafe = _prim "WordS8_toWord8": int -> Word8.word;
       val toWordX16Unsafe = _prim "WordS8_toWord16": int -> Word16.word;
       val toWordX32Unsafe = _prim "WordS8_toWord32": int -> Word32.word;
       val toWordX64Unsafe = _prim "WordS8_toWord64": int -> Word64.word;
-      val toWordXEqUnsafe = toWordX8Unsafe
    end
 structure Int8 : PRIM_INTEGER =
    struct
@@ -355,8 +357,6 @@
       val >>? = _prim "WordU16_rshift": int * Word32.word -> int;
       val xorb = _prim "Word16_xorb": int * int -> int;
 
-      type wordEq = Word16.word
-
       val fromInt8Unsafe = _prim "WordS8_toWord16": Int8.int -> int;
       val fromInt16Unsafe = _prim "WordS16_toWord16": Int16.int -> int;
       val fromInt32Unsafe = _prim "WordS32_toWord16": Int32.int -> int;
@@ -371,13 +371,11 @@
       val fromWord16Unsafe = _prim "WordU16_toWord16": Word16.word -> int;
       val fromWord32Unsafe = _prim "WordU32_toWord16": Word32.word -> int;
       val fromWord64Unsafe = _prim "WordU64_toWord16": Word64.word -> int;
-      val fromWordEqUnsafe = fromWord16Unsafe
 
       val fromWordX8Unsafe = _prim "WordS8_toWord16": Word8.word -> int;
       val fromWordX16Unsafe = _prim "WordS16_toWord16": Word16.word -> int;
       val fromWordX32Unsafe = _prim "WordS32_toWord16": Word32.word -> int;
       val fromWordX64Unsafe = _prim "WordS64_toWord16": Word64.word -> int;
-      val fromWordXEqUnsafe = fromWordX16Unsafe
 
       val toInt8Unsafe = _prim "WordS16_toWord8": int -> Int8.int;
       val toInt16Unsafe = _prim "WordS16_toWord16": int -> Int16.int;
@@ -393,13 +391,11 @@
       val toWord16Unsafe = _prim "WordU16_toWord16": int -> Word16.word;
       val toWord32Unsafe = _prim "WordU16_toWord32": int -> Word32.word;
       val toWord64Unsafe = _prim "WordU16_toWord64": int -> Word64.word;
-      val toWordEqUnsafe = toWord16Unsafe
 
       val toWordX8Unsafe = _prim "WordS16_toWord8": int -> Word8.word;
       val toWordX16Unsafe = _prim "WordS16_toWord16": int -> Word16.word;
       val toWordX32Unsafe = _prim "WordS16_toWord32": int -> Word32.word;
       val toWordX64Unsafe = _prim "WordS16_toWord64": int -> Word64.word;
-      val toWordXEqUnsafe = toWordX16Unsafe
    end
 structure Int16 : PRIM_INTEGER =
    struct
@@ -581,8 +577,6 @@
       val >>? = _prim "WordU32_rshift": int * Word32.word -> int;
       val xorb = _prim "Word32_xorb": int * int -> int;
 
-      type wordEq = Word32.word
-
       val fromInt8Unsafe = _prim "WordS8_toWord32": Int8.int -> int;
       val fromInt16Unsafe = _prim "WordS16_toWord32": Int16.int -> int;
       val fromInt32Unsafe = _prim "WordS32_toWord32": Int32.int -> int;
@@ -597,13 +591,11 @@
       val fromWord16Unsafe = _prim "WordU16_toWord32": Word16.word -> int;
       val fromWord32Unsafe = _prim "WordU32_toWord32": Word32.word -> int;
       val fromWord64Unsafe = _prim "WordU64_toWord32": Word64.word -> int;
-      val fromWordEqUnsafe = fromWord32Unsafe
 
       val fromWordX8Unsafe = _prim "WordS8_toWord32": Word8.word -> int;
       val fromWordX16Unsafe = _prim "WordS16_toWord32": Word16.word -> int;
       val fromWordX32Unsafe = _prim "WordS32_toWord32": Word32.word -> int;
       val fromWordX64Unsafe = _prim "WordS64_toWord32": Word64.word -> int;
-      val fromWordXEqUnsafe = fromWordX32Unsafe
 
       val toInt8Unsafe = _prim "WordS32_toWord8": int -> Int8.int;
       val toInt16Unsafe = _prim "WordS32_toWord16": int -> Int16.int;
@@ -619,13 +611,11 @@
       val toWord16Unsafe = _prim "WordU32_toWord16": int -> Word16.word;
       val toWord32Unsafe = _prim "WordU32_toWord32": int -> Word32.word;
       val toWord64Unsafe = _prim "WordU32_toWord64": int -> Word64.word;
-      val toWordEqUnsafe = toWord32Unsafe
 
       val toWordX8Unsafe = _prim "WordS32_toWord8": int -> Word8.word;
       val toWordX16Unsafe = _prim "WordS32_toWord16": int -> Word16.word;
       val toWordX32Unsafe = _prim "WordS32_toWord32": int -> Word32.word;
       val toWordX64Unsafe = _prim "WordS32_toWord64": int -> Word64.word;
-      val toWordXEqUnsafe = toWordX32Unsafe
    end
 structure Int32 : PRIM_INTEGER =
    struct
@@ -687,8 +677,6 @@
       val >>? = _prim "WordU64_rshift": int * Word32.word -> int;
       val xorb = _prim "Word64_xorb": int * int -> int;
 
-      type wordEq = Word64.word
-
       val fromInt8Unsafe = _prim "WordS8_toWord64": Int8.int -> int;
       val fromInt16Unsafe = _prim "WordS16_toWord64": Int16.int -> int;
       val fromInt32Unsafe = _prim "WordS32_toWord64": Int32.int -> int;
@@ -703,13 +691,11 @@
       val fromWord16Unsafe = _prim "WordU16_toWord64": Word16.word -> int;
       val fromWord32Unsafe = _prim "WordU32_toWord64": Word32.word -> int;
       val fromWord64Unsafe = _prim "WordU64_toWord64": Word64.word -> int;
-      val fromWordEqUnsafe = fromWord64Unsafe
 
       val fromWordX8Unsafe = _prim "WordS8_toWord64": Word8.word -> int;
       val fromWordX16Unsafe = _prim "WordS16_toWord64": Word16.word -> int;
       val fromWordX32Unsafe = _prim "WordS32_toWord64": Word32.word -> int;
       val fromWordX64Unsafe = _prim "WordS64_toWord64": Word64.word -> int;
-      val fromWordXEqUnsafe = fromWordX64Unsafe
 
       val toInt8Unsafe = _prim "WordS64_toWord8": int -> Int8.int;
       val toInt16Unsafe = _prim "WordS64_toWord16": int -> Int16.int;
@@ -725,13 +711,11 @@
       val toWord16Unsafe = _prim "WordU64_toWord16": int -> Word16.word;
       val toWord32Unsafe = _prim "WordU64_toWord32": int -> Word32.word;
       val toWord64Unsafe = _prim "WordU64_toWord64": int -> Word64.word;
-      val toWordEqUnsafe = toWord64Unsafe
 
       val toWordX8Unsafe = _prim "WordS64_toWord8": int -> Word8.word;
       val toWordX16Unsafe = _prim "WordS64_toWord16": int -> Word16.word;
       val toWordX32Unsafe = _prim "WordS64_toWord32": int -> Word32.word;
       val toWordX64Unsafe = _prim "WordS64_toWord64": int -> Word64.word;
-      val toWordXEqUnsafe = toWordX64Unsafe
    end
 structure Int64 : PRIM_INTEGER =
    struct

Modified: mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/primitive/prim-nullstring.sml
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/primitive/prim-nullstring.sml	2006-02-10 00:38:30 UTC (rev 4349)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/primitive/prim-nullstring.sml	2006-02-10 00:42:03 UTC (rev 4350)
@@ -28,7 +28,7 @@
       type t = String8.string
  
       fun fromString s =
-         if #"\000" = Vector.sub (s, SeqIndex.- (Vector.length s, 1))
+         if #"\000" = Vector.subUnsafe (s, SeqIndex.- (Vector.length s, 1))
             then s
          else raise Exn.Fail8 "NullString.fromString"
 

Modified: mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/primitive/prim-seq.sml
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/primitive/prim-seq.sml	2006-02-10 00:38:30 UTC (rev 4349)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/primitive/prim-seq.sml	2006-02-10 00:42:03 UTC (rev 4350)
@@ -15,28 +15,28 @@
 structure Array =
    struct
       open Array
-      val array = _prim "Array_array": SeqIndex.int -> 'a array;
-      val array =
-         fn n => if Controls.safe andalso SeqIndex.< (n, 0)
-                    then raise Exn.Size
-                    else array n
+      val arrayUnsafe = _prim "Array_array": SeqIndex.int -> 'a array;
+      fun array n =
+         if Controls.safe andalso SeqIndex.< (n, 0)
+            then raise Exn.Size
+            else arrayUnsafe n
       val array0Const = _prim "Array_array0Const": unit -> 'a array;
       val length = _prim "Array_length": 'a array -> SeqIndex.int;
-      (* There is no maximum length on arrays, so maxLen = maxInt. *)
+      (* There is no maximum length on arrays, so maxLen' = SeqIndex.maxInt'. *)
       val maxLen': SeqIndex.int = SeqIndex.maxInt'
-      val sub = _prim "Array_sub": 'a array * SeqIndex.int -> 'a;
-      val update = _prim "Array_update": 'a array * SeqIndex.int * 'a -> unit;
+      val subUnsafe = _prim "Array_sub": 'a array * SeqIndex.int -> 'a;
+      val updateUnsafe = _prim "Array_update": 'a array * SeqIndex.int * 'a -> unit;
    end
 
 structure Vector =
    struct
       open Vector 
-      val sub = _prim "Vector_sub": 'a vector * SeqIndex.int -> 'a;
-      val length = _prim "Vector_length": 'a vector -> SeqIndex.int;
       (* Don't mutate the array after you apply fromArray, because vectors 
        * are supposed to be immutable and the optimizer depends on this.  
        *)
       val fromArray = _prim "Array_toVector": 'a array -> 'a vector;
+      val length = _prim "Vector_length": 'a vector -> SeqIndex.int;
+      val subUnsafe = _prim "Vector_sub": 'a vector * SeqIndex.int -> 'a;
    end
 
 end

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-10 00:38:30 UTC (rev 4349)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/primitive/prim-word.sml	2006-02-10 00:42:03 UTC (rev 4350)
@@ -39,47 +39,49 @@
       val min: word * word -> word
       val max: word * word -> word
 
-      type intEq
-
+      (* Lowbits or sign extend. *)
       val fromInt8Unsafe: Primitive.Int8.int -> word
       val fromInt16Unsafe: Primitive.Int16.int -> word
       val fromInt32Unsafe: Primitive.Int32.int -> word
       val fromInt64Unsafe: Primitive.Int64.int -> word
-      val fromIntEqUnsafe: intEq -> word
 
+      (* Lowbits or zero extend. *)
       val fromIntZ8Unsafe: Primitive.Int8.int -> word
       val fromIntZ16Unsafe: Primitive.Int16.int -> word
       val fromIntZ32Unsafe: Primitive.Int32.int -> word
       val fromIntZ64Unsafe: Primitive.Int64.int -> word
-      val fromIntZEqUnsafe: intEq -> word
 
+      (* Lowbits or zero extend. *)
       val fromWord8Unsafe: Primitive.Word8.word -> word
       val fromWord16Unsafe: Primitive.Word16.word -> word
       val fromWord32Unsafe: Primitive.Word32.word -> word
       val fromWord64Unsafe: Primitive.Word64.word -> word
 
+      (* Lowbits or sign extend. *)
       val fromWordX8Unsafe: Primitive.Word8.word -> word
       val fromWordX16Unsafe: Primitive.Word16.word -> word
       val fromWordX32Unsafe: Primitive.Word32.word -> word
       val fromWordX64Unsafe: Primitive.Word64.word -> word
 
+      (* Lowbits or zero extend. *)
       val toInt8Unsafe: word -> Primitive.Int8.int
       val toInt16Unsafe: word -> Primitive.Int16.int
       val toInt32Unsafe: word -> Primitive.Int32.int
       val toInt64Unsafe: word -> Primitive.Int64.int
-      val toIntEqUnsafe: word -> intEq
 
+      (* Lowbits or sign extend. *)
       val toIntX8Unsafe: word -> Primitive.Int8.int
       val toIntX16Unsafe: word -> Primitive.Int16.int
       val toIntX32Unsafe: word -> Primitive.Int32.int
       val toIntX64Unsafe: word -> Primitive.Int64.int
-      val toIntXEqUnsafe: word -> intEq
 
+      (* Lowbits or zero extend. *)
       val toWord8Unsafe: word -> Primitive.Word8.word
       val toWord16Unsafe: word -> Primitive.Word16.word
       val toWord32Unsafe: word -> Primitive.Word32.word
       val toWord64Unsafe: word -> Primitive.Word64.word
 
+      (* Lowbits or sign extend. *)
       val toWordX8Unsafe: word -> Primitive.Word8.word
       val toWordX16Unsafe: word -> Primitive.Word16.word
       val toWordX32Unsafe: word -> Primitive.Word32.word
@@ -170,19 +172,15 @@
 
       val < = _prim "WordU8_lt": word * word -> bool;
 
-      type intEq = Int8.int
-
       val fromInt8Unsafe = _prim "WordS8_toWord8": Int8.int -> word;
       val fromInt16Unsafe = _prim "WordS16_toWord8": Int16.int -> word;
       val fromInt32Unsafe = _prim "WordS32_toWord8": Int32.int -> word;
       val fromInt64Unsafe = _prim "WordS64_toWord8": Int64.int -> word;
-      val fromIntEqUnsafe = fromInt8Unsafe
 
       val fromIntZ8Unsafe = _prim "WordU8_toWord8": Int8.int -> word;
       val fromIntZ16Unsafe = _prim "WordU16_toWord8": Int16.int -> word;
       val fromIntZ32Unsafe = _prim "WordU32_toWord8": Int32.int -> word;
       val fromIntZ64Unsafe = _prim "WordU64_toWord8": Int64.int -> word;
-      val fromIntZEqUnsafe = fromIntZ8Unsafe
 
       val fromWord8Unsafe = _prim "WordU8_toWord8": Word8.word -> word;
       val fromWord16Unsafe = _prim "WordU16_toWord8": Word16.word -> word;
@@ -198,13 +196,11 @@
       val toInt16Unsafe = _prim "WordU8_toWord16": word -> Int16.int;
       val toInt32Unsafe = _prim "WordU8_toWord32": word -> Int32.int;
       val toInt64Unsafe = _prim "WordU8_toWord64": word -> Int64.int;
-      val toIntEqUnsafe = toInt8Unsafe
 
       val toIntX8Unsafe = _prim "WordS8_toWord8": word -> Int8.int;
       val toIntX16Unsafe = _prim "WordS8_toWord16": word -> Int16.int;
       val toIntX32Unsafe = _prim "WordS8_toWord32": word -> Int32.int;
       val toIntX64Unsafe = _prim "WordS8_toWord64": word -> Int64.int;
-      val toIntXEqUnsafe = toIntX8Unsafe
 
       val toWord8Unsafe = _prim "WordU8_toWord8": word -> Word8.word;
       val toWord16Unsafe = _prim "WordU8_toWord16": word -> Word16.word;
@@ -305,19 +301,15 @@
 
       val < = _prim "WordU16_lt": word * word -> bool;
 
-      type intEq = Int16.int
-
       val fromInt8Unsafe = _prim "WordS8_toWord16": Int8.int -> word;
       val fromInt16Unsafe = _prim "WordS16_toWord16": Int16.int -> word;
       val fromInt32Unsafe = _prim "WordS32_toWord16": Int32.int -> word;
       val fromInt64Unsafe = _prim "WordS64_toWord16": Int64.int -> word;
-      val fromIntEqUnsafe = fromInt16Unsafe
 
       val fromIntZ8Unsafe = _prim "WordU8_toWord16": Int8.int -> word;
       val fromIntZ16Unsafe = _prim "WordU16_toWord16": Int16.int -> word;
       val fromIntZ32Unsafe = _prim "WordU32_toWord16": Int32.int -> word;
       val fromIntZ64Unsafe = _prim "WordU64_toWord16": Int64.int -> word;
-      val fromIntZEqUnsafe = fromIntZ16Unsafe
 
       val fromWord8Unsafe = _prim "WordU8_toWord16": Word8.word -> word;
       val fromWord16Unsafe = _prim "WordU16_toWord16": Word16.word -> word;
@@ -333,13 +325,11 @@
       val toInt16Unsafe = _prim "WordU16_toWord16": word -> Int16.int;
       val toInt32Unsafe = _prim "WordU16_toWord32": word -> Int32.int;
       val toInt64Unsafe = _prim "WordU16_toWord64": word -> Int64.int;
-      val toIntEqUnsafe = toInt16Unsafe
 
       val toIntX8Unsafe = _prim "WordS16_toWord8": word -> Int8.int;
       val toIntX16Unsafe = _prim "WordS16_toWord16": word -> Int16.int;
       val toIntX32Unsafe = _prim "WordS16_toWord32": word -> Int32.int;
       val toIntX64Unsafe = _prim "WordS16_toWord64": word -> Int64.int;
-      val toIntXEqUnsafe = toIntX16Unsafe
 
       val toWord8Unsafe = _prim "WordU16_toWord8": word -> Word8.word;
       val toWord16Unsafe = _prim "WordU16_toWord16": word -> Word16.word;
@@ -504,19 +494,15 @@
 
       val < = _prim "WordU32_lt": word * word -> bool;
 
-      type intEq = Int32.int
-
       val fromInt8Unsafe = _prim "WordS8_toWord32": Int8.int -> word;
       val fromInt16Unsafe = _prim "WordS16_toWord32": Int16.int -> word;
       val fromInt32Unsafe = _prim "WordS32_toWord32": Int32.int -> word;
       val fromInt64Unsafe = _prim "WordS64_toWord32": Int64.int -> word;
-      val fromIntEqUnsafe = fromInt32Unsafe
 
       val fromIntZ8Unsafe = _prim "WordU8_toWord32": Int8.int -> word;
       val fromIntZ16Unsafe = _prim "WordU16_toWord32": Int16.int -> word;
       val fromIntZ32Unsafe = _prim "WordU32_toWord32": Int32.int -> word;
       val fromIntZ64Unsafe = _prim "WordU64_toWord32": Int64.int -> word;
-      val fromIntZEqUnsafe = fromIntZ32Unsafe
 
       val fromWord8Unsafe = _prim "WordU8_toWord32": Word8.word -> word;
       val fromWord16Unsafe = _prim "WordU16_toWord32": Word16.word -> word;
@@ -532,13 +518,11 @@
       val toInt16Unsafe = _prim "WordU32_toWord16": word -> Int16.int;
       val toInt32Unsafe = _prim "WordU32_toWord32": word -> Int32.int;
       val toInt64Unsafe = _prim "WordU32_toWord64": word -> Int64.int;
-      val toIntEqUnsafe = toInt32Unsafe
 
       val toIntX8Unsafe = _prim "WordS32_toWord8": word -> Int8.int;
       val toIntX16Unsafe = _prim "WordS32_toWord16": word -> Int16.int;
       val toIntX32Unsafe = _prim "WordS32_toWord32": word -> Int32.int;
       val toIntX64Unsafe = _prim "WordS32_toWord64": word -> Int64.int;
-      val toIntXEqUnsafe = toIntX32Unsafe
 
       val toWord8Unsafe = _prim "WordU32_toWord8": word -> Word8.word;
       val toWord16Unsafe = _prim "WordU32_toWord16": word -> Word16.word;
@@ -583,19 +567,15 @@
 
       val < = _prim "WordU64_lt": word * word -> bool;
 
-      type intEq = Int64.int
-
       val fromInt8Unsafe = _prim "WordS8_toWord64": Int8.int -> word;
       val fromInt16Unsafe = _prim "WordS16_toWord64": Int16.int -> word;
       val fromInt32Unsafe = _prim "WordS32_toWord64": Int32.int -> word;
       val fromInt64Unsafe = _prim "WordS64_toWord64": Int64.int -> word;
-      val fromIntEqUnsafe = fromInt64Unsafe
 
       val fromIntZ8Unsafe = _prim "WordU8_toWord64": Int8.int -> word;
       val fromIntZ16Unsafe = _prim "WordU16_toWord64": Int16.int -> word;
       val fromIntZ32Unsafe = _prim "WordU32_toWord64": Int32.int -> word;
       val fromIntZ64Unsafe = _prim "WordU64_toWord64": Int64.int -> word;
-      val fromIntZEqUnsafe = fromIntZ64Unsafe
 
       val fromWord8Unsafe = _prim "WordU8_toWord64": Word8.word -> word;
       val fromWord16Unsafe = _prim "WordU16_toWord64": Word16.word -> word;
@@ -611,13 +591,11 @@
       val toInt16Unsafe = _prim "WordU64_toWord16": word -> Int16.int;
       val toInt32Unsafe = _prim "WordU64_toWord32": word -> Int32.int;
       val toInt64Unsafe = _prim "WordU64_toWord64": word -> Int64.int;
-      val toIntEqUnsafe = toInt64Unsafe
 
       val toIntX8Unsafe = _prim "WordS64_toWord8": word -> Int8.int;
       val toIntX16Unsafe = _prim "WordS64_toWord16": word -> Int16.int;
       val toIntX32Unsafe = _prim "WordS64_toWord32": word -> Int32.int;
       val toIntX64Unsafe = _prim "WordS64_toWord64": word -> Int64.int;
-      val toIntXEqUnsafe = toIntX64Unsafe
 
       val toWord8Unsafe = _prim "WordU64_toWord8": word -> Word8.word;
       val toWord16Unsafe = _prim "WordU64_toWord16": word -> Word16.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-10 00:38:30 UTC (rev 4349)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/primitive/primitive.mlb	2006-02-10 00:42:03 UTC (rev 4350)
@@ -30,9 +30,10 @@
       ../config/choose.sml
    end end
    local ../config/bind-for-config0.sml in ann "forceUsed" in
-      ../config/c/misc/$(CTYPES)
       ../config/objptr/$(OBJPTR_REP)
+      ../config/header/$(HEADER_WORD)
       ../config/seq/$(SEQ_INDEX)
+      ../config/c/misc/$(CTYPES)
    end end
    prim-intinf.sml
    prim-seq.sml

Modified: mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/test/Makefile
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/test/Makefile	2006-02-10 00:38:30 UTC (rev 4349)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/test/Makefile	2006-02-10 00:42:03 UTC (rev 4350)
@@ -20,19 +20,24 @@
 	../bin/clean
 
 
+OBJPTR_REP_MAPS = objptr-rep32.map
+HEADER_MAPS = header-word32.map
+SEQ_INDEX_MAPS = seqindex-int32.map
 CTYPES_MAPS = c-types.m32.map
 DEFAULT_CHAR_MAPS = default-char8.map
 DEFAULT_INT_MAPS = default-int32.map default-int64.map default-intinf.map 
 DEFAULT_WORD_MAPS = default-word32.map default-word64.map
-OBJPTR_REP_MAPS = objptr-rep32.map
-SEQ_INDEX_MAPS = seq-index32.map
 
-test: test.mlb $(shell $(MLTON) -mlb-path-map "../maps/c-types.m32.map" -mlb-path-map "../maps/default-char8.map" -mlb-path-map "../maps/default-int32.map" -mlb-path-map "../maps/default-word32.map" -mlb-path-map "../maps/objptr-rep32.map" -mlb-path-map "../maps/seq-index32.map" -stop f test.mlb)
+test: test.mlb print.o $(shell $(MLTON) -mlb-path-map "../maps/header-word32.map" -mlb-path-map "../maps/objptr-rep32.map" -mlb-path-map "../maps/seqindex-int32.map" -mlb-path-map "../maps/c-types.m32.map" -mlb-path-map "../maps/default-char8.map" -mlb-path-map "../maps/default-int32.map" -mlb-path-map "../maps/default-word32.map" -stop f test.mlb)
 	$(MLTON) \
+		-mlb-path-map "../maps/header-word32.map" \
+		-mlb-path-map "../maps/objptr-rep32.map" \
+		-mlb-path-map "../maps/seqindex-int32.map" \
 		-mlb-path-map "../maps/c-types.m32.map" \
 		-mlb-path-map "../maps/default-char8.map" \
 		-mlb-path-map "../maps/default-int32.map" \
 		-mlb-path-map "../maps/default-word32.map" \
-		-mlb-path-map "../maps/objptr-rep32.map" \
-		-mlb-path-map "../maps/seq-index32.map" \
-		test.mlb
+		test.mlb print.o
+
+print.o: print.c
+	gcc -m32 -c print.c

Added: mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/test/print.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/test/print.c	2006-02-10 00:38:30 UTC (rev 4349)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/test/print.c	2006-02-10 00:42:03 UTC (rev 4350)
@@ -0,0 +1,35 @@
+#include <stdio.h>
+#include <stdint.h>
+#include <inttypes.h>
+
+void printInt8 (int8_t i) {
+  printf("%"PRId8"\n", i);
+}
+
+void printInt16 (int16_t i) {
+  printf("%"PRId16"\n", i);
+}
+
+void printInt32 (int32_t i) {
+  printf("%"PRId32"\n", i);
+}
+
+void printInt64 (int64_t i) {
+  printf("%"PRId64"\n", i);
+}
+
+void printWord8 (uint8_t i) {
+  printf("%"PRIx8"\n", i);
+}
+
+void printWord16 (uint16_t i) {
+  printf("%"PRIx16"\n", i);
+}
+
+void printWord32 (uint32_t i) {
+  printf("%"PRIx32"\n", i);
+}
+
+void printWord64 (uint64_t i) {
+  printf("%"PRIx64"\n", i);
+}

Modified: mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/test/test.mlb
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/test/test.mlb	2006-02-10 00:38:30 UTC (rev 4349)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/test/test.mlb	2006-02-10 00:42:03 UTC (rev 4350)
@@ -1,3 +1,5 @@
 
 ../build/sources.mlb
-test.sml
+ann "allowFFI true" in
+   test.sml
+end

Modified: mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/test/test.sml
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/test/test.sml	2006-02-10 00:38:30 UTC (rev 4349)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/test/test.sml	2006-02-10 00:42:03 UTC (rev 4350)
@@ -1,21 +1,404 @@
+open Primitive
 
+val printInt8 = _import "printInt8" : Int8.int -> unit;
+val printInt16 = _import "printInt16" : Int16.int -> unit;
+val printInt32 = _import "printInt32" : Int32.int -> unit;
+val printInt64 = _import "printInt64" : Int64.int -> unit;
+
+val printWord8 = _import "printWord8" : Word8.word -> unit;
+val printWord16 = _import "printWord16" : Word16.word -> unit;
+val printWord32 = _import "printWord32" : Word32.word -> unit;
+val printWord64 = _import "printWord64" : Word64.word -> unit;
+
 fun printString s =
-   PrimitiveFFI.Stdio.print s
+   PrimitiveFFI.Stdio.printStdout s
 
 fun printIntInf i =
    let
-      val s = Primitive.IntInf.toString8 i
+      val s = IntInf.toString8 i
    in
       printString s
+      ; printString "\n"
    end
 
 local
-   open Primitive.IntInf
+   open IntInf
 in
    fun fact n =
       if n = 0 then 1 else n * (fact (n - 1))
 end
 
-val () = (printString "fact 40 = "
-          ; printIntInf (fact 40)
-          ; printString "\n")
+val _ = (printString "Int8.maxInt' = \n"
+          ; printInt8 Int8.maxInt')
+val _ = (printString "IntInf.fromInt8 Int8.maxInt' = \n"
+         ; printIntInf (IntInf.fromInt8 Int8.maxInt'))
+val _ = (printString "IntInf.toInt8 (IntInf.fromInt8 Int8.maxInt') = \n"
+         ; printInt8 (IntInf.toInt8 (IntInf.fromInt8 Int8.maxInt')))
+val _ = (printString "Int16.maxInt' = \n"
+          ; printInt16 Int16.maxInt')
+val _ = (printString "IntInf.fromInt16 Int16.maxInt' = \n"
+         ; printIntInf (IntInf.fromInt16 Int16.maxInt'))
+val _ = (printString "IntInf.toInt16 (IntInf.fromInt16 Int16.maxInt') = \n"
+         ; printInt16 (IntInf.toInt16 (IntInf.fromInt16 Int16.maxInt')))
+val _ = (printString "Int32.maxInt' = \n"
+          ; printInt32 Int32.maxInt')
+val _ = (printString "IntInf.fromInt32 Int32.maxInt' = \n"
+         ; printIntInf (IntInf.fromInt32 Int32.maxInt'))
+val _ = (printString "IntInf.toInt32 (IntInf.fromInt32 Int32.maxInt') = \n"
+         ; printInt32 (IntInf.toInt32 (IntInf.fromInt32 Int32.maxInt')))
+val _ = (printString "Int64.maxInt' = \n"
+          ; printInt64 Int64.maxInt')
+val _ = (printString "IntInf.fromInt64 Int64.maxInt' = \n"
+         ; printIntInf (IntInf.fromInt64 Int64.maxInt'))
+val _ = (printString "IntInf.toInt64 (IntInf.fromInt64 Int64.maxInt') = \n"
+         ; printInt64 (IntInf.toInt64 (IntInf.fromInt64 Int64.maxInt')))
+
+val _ = (printString "Int8.minInt' = \n"
+          ; printInt8 Int8.minInt')
+val _ = (printString "IntInf.fromInt8 Int8.minInt' = \n"
+         ; printIntInf (IntInf.fromInt8 Int8.minInt'))
+val _ = (printString "IntInf.toInt8 (IntInf.fromInt8 Int8.minInt') = \n"
+         ; printInt8 (IntInf.toInt8 (IntInf.fromInt8 Int8.minInt')))
+val _ = (printString "Int16.minInt' = \n"
+          ; printInt16 Int16.minInt')
+val _ = (printString "IntInf.fromInt16 Int16.minInt' = \n"
+         ; printIntInf (IntInf.fromInt16 Int16.minInt'))
+val _ = (printString "IntInf.toInt16 (IntInf.fromInt16 Int16.minInt') = \n"
+         ; printInt16 (IntInf.toInt16 (IntInf.fromInt16 Int16.minInt')))
+val _ = (printString "Int32.minInt' = \n"
+          ; printInt32 Int32.minInt')
+val _ = (printString "IntInf.fromInt32 Int32.minInt' = \n"
+         ; printIntInf (IntInf.fromInt32 Int32.minInt'))
+val _ = (printString "IntInf.toInt32 (IntInf.fromInt32 Int32.minInt') = \n"
+         ; printInt32 (IntInf.toInt32 (IntInf.fromInt32 Int32.minInt')))
+val _ = (printString "Int64.minInt' = \n"
+          ; printInt64 Int64.minInt')
+val _ = (printString "IntInf.fromInt64 Int64.minInt' = \n"
+         ; printIntInf (IntInf.fromInt64 Int64.minInt'))
+val _ = (printString "IntInf.toInt64 (IntInf.fromInt64 Int64.minInt') = \n"
+         ; printInt64 (IntInf.toInt64 (IntInf.fromInt64 Int64.minInt')))
+
+val _ = (printString "(Int8.div (Int8.minInt', 2)) = \n"
+          ; printInt8 (Int8.div (Int8.minInt', 2)))
+val _ = (printString "IntInf.fromInt8 (Int8.div (Int8.minInt', 2)) = \n"
+         ; printIntInf (IntInf.fromInt8 (Int8.div (Int8.minInt', 2))))
+val _ = (printString "IntInf.toInt8 (IntInf.fromInt8 (Int8.div (Int8.minInt', 2))) = \n"
+         ; printInt8 (IntInf.toInt8 (IntInf.fromInt8 (Int8.div (Int8.minInt', 2)))))
+val _ = (printString "(Int16.div (Int16.minInt', 2)) = \n"
+          ; printInt16 (Int16.div (Int16.minInt', 2)))
+val _ = (printString "IntInf.fromInt16 (Int16.div (Int16.minInt', 2)) = \n"
+         ; printIntInf (IntInf.fromInt16 (Int16.div (Int16.minInt', 2))))
+val _ = (printString "IntInf.toInt16 (IntInf.fromInt16 (Int16.div (Int16.minInt', 2))) = \n"
+         ; printInt16 (IntInf.toInt16 (IntInf.fromInt16 (Int16.div (Int16.minInt', 2)))))
+val _ = (printString "(Int32.div (Int32.minInt', 2)) = \n"
+          ; printInt32 (Int32.div (Int32.minInt', 2)))
+val _ = (printString "IntInf.fromInt32 (Int32.div (Int32.minInt', 2)) = \n"
+         ; printIntInf (IntInf.fromInt32 (Int32.div (Int32.minInt', 2))))
+val _ = (printString "IntInf.toInt32 (IntInf.fromInt32 (Int32.div (Int32.minInt', 2))) = \n"
+         ; printInt32 (IntInf.toInt32 (IntInf.fromInt32 (Int32.div (Int32.minInt', 2)))))
+val _ = (printString "(Int64.div (Int64.minInt', 2)) = \n"
+          ; printInt64 (Int64.div (Int64.minInt', 2)))
+val _ = (printString "IntInf.fromInt64 (Int64.div (Int64.minInt', 2)) = \n"
+         ; printIntInf (IntInf.fromInt64 (Int64.div (Int64.minInt', 2))))
+val _ = (printString "IntInf.toInt64 (IntInf.fromInt64 (Int64.div (Int64.minInt', 2))) = \n"
+         ; printInt64 (IntInf.toInt64 (IntInf.fromInt64 (Int64.div (Int64.minInt', 2)))))
+
+val _ = (printString "(Int8.div (Int8.minInt', 4)) = \n"
+          ; printInt8 (Int8.div (Int8.minInt', 4)))
+val _ = (printString "IntInf.fromInt8 (Int8.div (Int8.minInt', 4)) = \n"
+         ; printIntInf (IntInf.fromInt8 (Int8.div (Int8.minInt', 4))))
+val _ = (printString "IntInf.toInt8 (IntInf.fromInt8 (Int8.div (Int8.minInt', 4))) = \n"
+         ; printInt8 (IntInf.toInt8 (IntInf.fromInt8 (Int8.div (Int8.minInt', 4)))))
+val _ = (printString "(Int16.div (Int16.minInt', 4)) = \n"
+          ; printInt16 (Int16.div (Int16.minInt', 4)))
+val _ = (printString "IntInf.fromInt16 (Int16.div (Int16.minInt', 4)) = \n"
+         ; printIntInf (IntInf.fromInt16 (Int16.div (Int16.minInt', 4))))
+val _ = (printString "IntInf.toInt16 (IntInf.fromInt16 (Int16.div (Int16.minInt', 4))) = \n"
+         ; printInt16 (IntInf.toInt16 (IntInf.fromInt16 (Int16.div (Int16.minInt', 4)))))
+val _ = (printString "(Int32.div (Int32.minInt', 4)) = \n"
+          ; printInt32 (Int32.div (Int32.minInt', 4)))
+val _ = (printString "IntInf.fromInt32 (Int32.div (Int32.minInt', 4)) = \n"
+         ; printIntInf (IntInf.fromInt32 (Int32.div (Int32.minInt', 4))))
+val _ = (printString "IntInf.toInt32 (IntInf.fromInt32 (Int32.div (Int32.minInt', 4))) = \n"
+         ; printInt32 (IntInf.toInt32 (IntInf.fromInt32 (Int32.div (Int32.minInt', 4)))))
+val _ = (printString "(Int64.div (Int64.minInt', 4)) = \n"
+          ; printInt64 (Int64.div (Int64.minInt', 4)))
+val _ = (printString "IntInf.fromInt64 (Int64.div (Int64.minInt', 4)) = \n"
+         ; printIntInf (IntInf.fromInt64 (Int64.div (Int64.minInt', 4))))
+val _ = (printString "IntInf.toInt64 (IntInf.fromInt64 (Int64.div (Int64.minInt', 4))) = \n"
+         ; printInt64 (IntInf.toInt64 (IntInf.fromInt64 (Int64.div (Int64.minInt', 4)))))
+
+val _ = (printString "(Int8.- (Int8.maxInt', 2)) = \n"
+          ; printInt8 (Int8.- (Int8.maxInt', 2)))
+val _ = (printString "IntInf.fromInt8 (Int8.- (Int8.maxInt', 2)) = \n"
+         ; printIntInf (IntInf.fromInt8 (Int8.- (Int8.maxInt', 2))))
+val _ = (printString "IntInf.toInt8 (IntInf.fromInt8 (Int8.- (Int8.maxInt', 2))) = \n"
+         ; printInt8 (IntInf.toInt8 (IntInf.fromInt8 (Int8.- (Int8.maxInt', 2)))))
+val _ = (printString "(Int16.- (Int16.maxInt', 2)) = \n"
+          ; printInt16 (Int16.- (Int16.maxInt', 2)))
+val _ = (printString "IntInf.fromInt16 (Int16.- (Int16.maxInt', 2)) = \n"
+         ; printIntInf (IntInf.fromInt16 (Int16.- (Int16.maxInt', 2))))
+val _ = (printString "IntInf.toInt16 (IntInf.fromInt16 (Int16.- (Int16.maxInt', 2))) = \n"
+         ; printInt16 (IntInf.toInt16 (IntInf.fromInt16 (Int16.- (Int16.maxInt', 2)))))
+val _ = (printString "(Int32.- (Int32.maxInt', 2)) = \n"
+          ; printInt32 (Int32.- (Int32.maxInt', 2)))
+val _ = (printString "IntInf.fromInt32 (Int32.- (Int32.maxInt', 2)) = \n"
+         ; printIntInf (IntInf.fromInt32 (Int32.- (Int32.maxInt', 2))))
+val _ = (printString "IntInf.toInt32 (IntInf.fromInt32 (Int32.- (Int32.maxInt', 2))) = \n"
+         ; printInt32 (IntInf.toInt32 (IntInf.fromInt32 (Int32.- (Int32.maxInt', 2)))))
+val _ = (printString "(Int64.- (Int64.maxInt', 2)) = \n"
+          ; printInt64 (Int64.- (Int64.maxInt', 2)))
+val _ = (printString "IntInf.fromInt64 (Int64.- (Int64.maxInt', 2)) = \n"
+         ; printIntInf (IntInf.fromInt64 (Int64.- (Int64.maxInt', 2))))
+val _ = (printString "IntInf.toInt64 (IntInf.fromInt64 (Int64.- (Int64.maxInt', 2))) = \n"
+         ; printInt64 (IntInf.toInt64 (IntInf.fromInt64 (Int64.- (Int64.maxInt', 2)))))
+
+val _ = (printString "(Int8.- (Int8.maxInt', 4)) = \n"
+          ; printInt8 (Int8.- (Int8.maxInt', 4)))
+val _ = (printString "IntInf.fromInt8 (Int8.- (Int8.maxInt', 4)) = \n"
+         ; printIntInf (IntInf.fromInt8 (Int8.- (Int8.maxInt', 4))))
+val _ = (printString "IntInf.toInt8 (IntInf.fromInt8 (Int8.- (Int8.maxInt', 4))) = \n"
+         ; printInt8 (IntInf.toInt8 (IntInf.fromInt8 (Int8.- (Int8.maxInt', 4)))))
+val _ = (printString "(Int16.- (Int16.maxInt', 4)) = \n"
+          ; printInt16 (Int16.- (Int16.maxInt', 4)))
+val _ = (printString "IntInf.fromInt16 (Int16.- (Int16.maxInt', 4)) = \n"
+         ; printIntInf (IntInf.fromInt16 (Int16.- (Int16.maxInt', 4))))
+val _ = (printString "IntInf.toInt16 (IntInf.fromInt16 (Int16.- (Int16.maxInt', 4))) = \n"
+         ; printInt16 (IntInf.toInt16 (IntInf.fromInt16 (Int16.- (Int16.maxInt', 4)))))
+val _ = (printString "(Int32.- (Int32.maxInt', 4)) = \n"
+          ; printInt32 (Int32.- (Int32.maxInt', 4)))
+val _ = (printString "IntInf.fromInt32 (Int32.- (Int32.maxInt', 4)) = \n"
+         ; printIntInf (IntInf.fromInt32 (Int32.- (Int32.maxInt', 4))))
+val _ = (printString "IntInf.toInt32 (IntInf.fromInt32 (Int32.- (Int32.maxInt', 4))) = \n"
+         ; printInt32 (IntInf.toInt32 (IntInf.fromInt32 (Int32.- (Int32.maxInt', 4)))))
+val _ = (printString "(Int64.- (Int64.maxInt', 4)) = \n"
+          ; printInt64 (Int64.- (Int64.maxInt', 4)))
+val _ = (printString "IntInf.fromInt64 (Int64.- (Int64.maxInt', 4)) = \n"
+         ; printIntInf (IntInf.fromInt64 (Int64.- (Int64.maxInt', 4))))
+val _ = (printString "IntInf.toInt64 (IntInf.fromInt64 (Int64.- (Int64.maxInt', 4))) = \n"
+         ; printInt64 (IntInf.toInt64 (IntInf.fromInt64 (Int64.- (Int64.maxInt', 4)))))
+
+val _ = (printString "(Int8.+ (Int8.minInt', 2)) = \n"
+          ; printInt8 (Int8.+ (Int8.minInt', 2)))
+val _ = (printString "IntInf.fromInt8 (Int8.+ (Int8.minInt', 2)) = \n"
+         ; printIntInf (IntInf.fromInt8 (Int8.+ (Int8.minInt', 2))))
+val _ = (printString "IntInf.toInt8 (IntInf.fromInt8 (Int8.+ (Int8.minInt', 2))) = \n"
+         ; printInt8 (IntInf.toInt8 (IntInf.fromInt8 (Int8.+ (Int8.minInt', 2)))))
+val _ = (printString "(Int16.+ (Int16.minInt', 2)) = \n"
+          ; printInt16 (Int16.+ (Int16.minInt', 2)))
+val _ = (printString "IntInf.fromInt16 (Int16.+ (Int16.minInt', 2)) = \n"
+         ; printIntInf (IntInf.fromInt16 (Int16.+ (Int16.minInt', 2))))
+val _ = (printString "IntInf.toInt16 (IntInf.fromInt16 (Int16.+ (Int16.minInt', 2))) = \n"
+         ; printInt16 (IntInf.toInt16 (IntInf.fromInt16 (Int16.+ (Int16.minInt', 2)))))
+val _ = (printString "(Int32.+ (Int32.minInt', 2)) = \n"
+          ; printInt32 (Int32.+ (Int32.minInt', 2)))
+val _ = (printString "IntInf.fromInt32 (Int32.+ (Int32.minInt', 2)) = \n"
+         ; printIntInf (IntInf.fromInt32 (Int32.+ (Int32.minInt', 2))))
+val _ = (printString "IntInf.toInt32 (IntInf.fromInt32 (Int32.+ (Int32.minInt', 2))) = \n"
+         ; printInt32 (IntInf.toInt32 (IntInf.fromInt32 (Int32.+ (Int32.minInt', 2)))))
+val _ = (printString "(Int64.+ (Int64.minInt', 2)) = \n"
+          ; printInt64 (Int64.+ (Int64.minInt', 2)))
+val _ = (printString "IntInf.fromInt64 (Int64.+ (Int64.minInt', 2)) = \n"
+         ; printIntInf (IntInf.fromInt64 (Int64.+ (Int64.minInt', 2))))
+val _ = (printString "IntInf.toInt64 (IntInf.fromInt64 (Int64.+ (Int64.minInt', 2))) = \n"
+         ; printInt64 (IntInf.toInt64 (IntInf.fromInt64 (Int64.+ (Int64.minInt', 2)))))
+
+val _ = (printString "(Int8.+ (Int8.minInt', 4)) = \n"
+          ; printInt8 (Int8.+ (Int8.minInt', 4)))
+val _ = (printString "IntInf.fromInt8 (Int8.+ (Int8.minInt', 4)) = \n"
+         ; printIntInf (IntInf.fromInt8 (Int8.+ (Int8.minInt', 4))))
+val _ = (printString "IntInf.toInt8 (IntInf.fromInt8 (Int8.+ (Int8.minInt', 4))) = \n"
+         ; printInt8 (IntInf.toInt8 (IntInf.fromInt8 (Int8.+ (Int8.minInt', 4)))))
+val _ = (printString "(Int16.+ (Int16.minInt', 4)) = \n"
+          ; printInt16 (Int16.+ (Int16.minInt', 4)))
+val _ = (printString "IntInf.fromInt16 (Int16.+ (Int16.minInt', 4)) = \n"
+         ; printIntInf (IntInf.fromInt16 (Int16.+ (Int16.minInt', 4))))
+val _ = (printString "IntInf.toInt16 (IntInf.fromInt16 (Int16.+ (Int16.minInt', 4))) = \n"
+         ; printInt16 (IntInf.toInt16 (IntInf.fromInt16 (Int16.+ (Int16.minInt', 4)))))
+val _ = (printString "(Int32.+ (Int32.minInt', 4)) = \n"
+          ; printInt32 (Int32.+ (Int32.minInt', 4)))
+val _ = (printString "IntInf.fromInt32 (Int32.+ (Int32.minInt', 4)) = \n"
+         ; printIntInf (IntInf.fromInt32 (Int32.+ (Int32.minInt', 4))))
+val _ = (printString "IntInf.toInt32 (IntInf.fromInt32 (Int32.+ (Int32.minInt', 4))) = \n"
+         ; printInt32 (IntInf.toInt32 (IntInf.fromInt32 (Int32.+ (Int32.minInt', 4)))))
+val _ = (printString "(Int64.+ (Int64.minInt', 4)) = \n"
+          ; printInt64 (Int64.+ (Int64.minInt', 4)))
+val _ = (printString "IntInf.fromInt64 (Int64.+ (Int64.minInt', 4)) = \n"
+         ; printIntInf (IntInf.fromInt64 (Int64.+ (Int64.minInt', 4))))
+val _ = (printString "IntInf.toInt64 (IntInf.fromInt64 (Int64.+ (Int64.minInt', 4))) = \n"
+         ; printInt64 (IntInf.toInt64 (IntInf.fromInt64 (Int64.+ (Int64.minInt', 4)))))
+
+val _ = (printString "Int8.zero = \n"
+          ; printInt8 Int8.zero)
+val _ = (printString "IntInf.fromInt8 Int8.zero = \n"
+         ; printIntInf (IntInf.fromInt8 Int8.zero))
+val _ = (printString "IntInf.toInt8 (IntInf.fromInt8 Int8.zero) = \n"
+         ; printInt8 (IntInf.toInt8 (IntInf.fromInt8 Int8.zero)))
+val _ = (printString "Int16.zero = \n"
+          ; printInt16 Int16.zero)
+val _ = (printString "IntInf.fromInt16 Int16.zero = \n"
+         ; printIntInf (IntInf.fromInt16 Int16.zero))
+val _ = (printString "IntInf.toInt16 (IntInf.fromInt16 Int16.zero) = \n"
+         ; printInt16 (IntInf.toInt16 (IntInf.fromInt16 Int16.zero)))
+val _ = (printString "Int32.zero = \n"
+          ; printInt32 Int32.zero)
+val _ = (printString "IntInf.fromInt32 Int32.zero = \n"
+         ; printIntInf (IntInf.fromInt32 Int32.zero))
+val _ = (printString "IntInf.toInt32 (IntInf.fromInt32 Int32.zero) = \n"
+         ; printInt32 (IntInf.toInt32 (IntInf.fromInt32 Int32.zero)))
+val _ = (printString "Int64.zero = \n"
+          ; printInt64 Int64.zero)
+val _ = (printString "IntInf.fromInt64 Int64.zero = \n"
+         ; printIntInf (IntInf.fromInt64 Int64.zero))
+val _ = (printString "IntInf.toInt64 (IntInf.fromInt64 Int64.zero) = \n"
+         ; printInt64 (IntInf.toInt64 (IntInf.fromInt64 Int64.zero)))
+
+val _ = (printString "Int8.one = \n"
+          ; printInt8 Int8.one)
+val _ = (printString "IntInf.fromInt8 Int8.one = \n"
+         ; printIntInf (IntInf.fromInt8 Int8.one))
+val _ = (printString "IntInf.toInt8 (IntInf.fromInt8 Int8.one) = \n"
+         ; printInt8 (IntInf.toInt8 (IntInf.fromInt8 Int8.one)))
+val _ = (printString "Int16.one = \n"
+          ; printInt16 Int16.one)
+val _ = (printString "IntInf.fromInt16 Int16.one = \n"
+         ; printIntInf (IntInf.fromInt16 Int16.one))
+val _ = (printString "IntInf.toInt16 (IntInf.fromInt16 Int16.one) = \n"
+         ; printInt16 (IntInf.toInt16 (IntInf.fromInt16 Int16.one)))
+val _ = (printString "Int32.one = \n"
+          ; printInt32 Int32.one)
+val _ = (printString "IntInf.fromInt32 Int32.one = \n"
+         ; printIntInf (IntInf.fromInt32 Int32.one))
+val _ = (printString "IntInf.toInt32 (IntInf.fromInt32 Int32.one) = \n"
+         ; printInt32 (IntInf.toInt32 (IntInf.fromInt32 Int32.one)))
+val _ = (printString "Int64.one = \n"
+          ; printInt64 Int64.one)
+val _ = (printString "IntInf.fromInt64 Int64.one = \n"
+         ; printIntInf (IntInf.fromInt64 Int64.one))
+val _ = (printString "IntInf.toInt64 (IntInf.fromInt64 Int64.one) = \n"
+         ; printInt64 (IntInf.toInt64 (IntInf.fromInt64 Int64.one)))
+
+val _ = (printString "(Int8.~ Int8.one) = \n"
+          ; printInt8 (Int8.~ Int8.one))
+val _ = (printString "IntInf.fromInt8 (Int8.~ Int8.one) = \n"
+         ; printIntInf (IntInf.fromInt8 (Int8.~ Int8.one)))
+val _ = (printString "IntInf.toInt8 (IntInf.fromInt8 (Int8.~ Int8.one)) = \n"
+         ; printInt8 (IntInf.toInt8 (IntInf.fromInt8 (Int8.~ Int8.one))))
+val _ = (printString "(Int16.~ Int16.one) = \n"
+          ; printInt16 (Int16.~ Int16.one))
+val _ = (printString "IntInf.fromInt16 (Int16.~ Int16.one) = \n"
+         ; printIntInf (IntInf.fromInt16 (Int16.~ Int16.one)))
+val _ = (printString "IntInf.toInt16 (IntInf.fromInt16 (Int16.~ Int16.one)) = \n"
+         ; printInt16 (IntInf.toInt16 (IntInf.fromInt16 (Int16.~ Int16.one))))
+val _ = (printString "(Int32.~ Int32.one) = \n"
+          ; printInt32 (Int32.~ Int32.one))
+val _ = (printString "IntInf.fromInt32 (Int32.~ Int32.one) = \n"
+         ; printIntInf (IntInf.fromInt32 (Int32.~ Int32.one)))
+val _ = (printString "IntInf.toInt32 (IntInf.fromInt32 (Int32.~ Int32.one)) = \n"
+         ; printInt32 (IntInf.toInt32 (IntInf.fromInt32 (Int32.~ Int32.one))))
+val _ = (printString "(Int64.~ Int64.one) = \n"
+          ; printInt64 (Int64.~ Int64.one))
+val _ = (printString "IntInf.fromInt64 (Int64.~ Int64.one) = \n"
+         ; printIntInf (IntInf.fromInt64 (Int64.~ Int64.one)))
+val _ = (printString "IntInf.toInt64 (IntInf.fromInt64 (Int64.~ Int64.one)) = \n"
+         ; printInt64 (IntInf.toInt64 (IntInf.fromInt64 (Int64.~ Int64.one))))
+
+val _ = (printString "IntInf.toWord8 0 = \n"
+         ; printWord8 (IntInf.toWord8 0))
+val _ = (printString "IntInf.toWord16 0 = \n"
+         ; printWord16 (IntInf.toWord16 0))
+val _ = (printString "IntInf.toWord32 0 = \n"
+         ; printWord32 (IntInf.toWord32 0))
+val _ = (printString "IntInf.toWord64 0 = \n"
+         ; printWord64 (IntInf.toWord64 0))
+
+val _ = (printString "IntInf.toWord8 1 = \n"
+         ; printWord8 (IntInf.toWord8 1))
+val _ = (printString "IntInf.toWord16 1 = \n"
+         ; printWord16 (IntInf.toWord16 1))
+val _ = (printString "IntInf.toWord32 1 = \n"
+         ; printWord32 (IntInf.toWord32 1))
+val _ = (printString "IntInf.toWord64 1 = \n"
+         ; printWord64 (IntInf.toWord64 1))
+
+val _ = (printString "IntInf.toWord8 ~1 = \n"
+         ; printWord8 (IntInf.toWord8 ~1))
+val _ = (printString "IntInf.toWord16 ~1 = \n"
+         ; printWord16 (IntInf.toWord16 ~1))
+val _ = (printString "IntInf.toWord32 ~1 = \n"
+         ; printWord32 (IntInf.toWord32 ~1))
+val _ = (printString "IntInf.toWord64 ~1 = \n"
+         ; printWord64 (IntInf.toWord64 ~1))
+
+val _ = (printString "IntInf.toWord8 (IntInf.fromInt8 Int8.minInt') = \n"
+         ; printWord8 (IntInf.toWord8 (IntInf.fromInt8 Int8.minInt')))
+val _ = (printString "IntInf.toWord16 (IntInf.fromInt8 Int8.minInt') = \n"
+         ; printWord16 (IntInf.toWord16 (IntInf.fromInt8 Int8.minInt')))
+val _ = (printString "IntInf.toWord32 (IntInf.fromInt8 Int8.minInt') = \n"
+         ; printWord32 (IntInf.toWord32 (IntInf.fromInt8 Int8.minInt')))
+val _ = (printString "IntInf.toWord64 (IntInf.fromInt8 Int8.minInt') = \n"
+         ; printWord64 (IntInf.toWord64 (IntInf.fromInt8 Int8.minInt')))
+
+val _ = (printString "IntInf.toWord8 (IntInf.fromInt16 Int16.minInt') = \n"
+         ; printWord8 (IntInf.toWord8 (IntInf.fromInt16 Int16.minInt')))
+val _ = (printString "IntInf.toWord16 (IntInf.fromInt16 Int16.minInt') = \n"
+         ; printWord16 (IntInf.toWord16 (IntInf.fromInt16 Int16.minInt')))
+val _ = (printString "IntInf.toWord32 (IntInf.fromInt16 Int16.minInt') = \n"
+         ; printWord32 (IntInf.toWord32 (IntInf.fromInt16 Int16.minInt')))
+val _ = (printString "IntInf.toWord64 (IntInf.fromInt16 Int16.minInt') = \n"
+         ; printWord64 (IntInf.toWord64 (IntInf.fromInt16 Int16.minInt')))
+
+val _ = (printString "IntInf.toWord8 (IntInf.fromInt32 Int32.minInt') = \n"
+         ; printWord8 (IntInf.toWord8 (IntInf.fromInt32 Int32.minInt')))
+val _ = (printString "IntInf.toWord16 (IntInf.fromInt32 Int32.minInt') = \n"
+         ; printWord16 (IntInf.toWord16 (IntInf.fromInt32 Int32.minInt')))
+val _ = (printString "IntInf.toWord32 (IntInf.fromInt32 Int32.minInt') = \n"
+         ; printWord32 (IntInf.toWord32 (IntInf.fromInt32 Int32.minInt')))
+val _ = (printString "IntInf.toWord64 (IntInf.fromInt32 Int32.minInt') = \n"
+         ; printWord64 (IntInf.toWord64 (IntInf.fromInt32 Int32.minInt')))
+
+val _ = (printString "IntInf.toWord8 (IntInf.fromInt64 Int64.minInt') = \n"
+         ; printWord8 (IntInf.toWord8 (IntInf.fromInt64 Int64.minInt')))
+val _ = (printString "IntInf.toWord16 (IntInf.fromInt64 Int64.minInt') = \n"
+         ; printWord16 (IntInf.toWord16 (IntInf.fromInt64 Int64.minInt')))
+val _ = (printString "IntInf.toWord32 (IntInf.fromInt64 Int64.minInt') = \n"
+         ; printWord32 (IntInf.toWord32 (IntInf.fromInt64 Int64.minInt')))
+val _ = (printString "IntInf.toWord64 (IntInf.fromInt64 Int64.minInt') = \n"
+         ; printWord64 (IntInf.toWord64 (IntInf.fromInt64 Int64.minInt')))
+
+val _ = (printString "IntInf.toWord8 (IntInf.fromInt8 Int8.maxInt') = \n"
+         ; printWord8 (IntInf.toWord8 (IntInf.fromInt8 Int8.maxInt')))
+val _ = (printString "IntInf.toWord16 (IntInf.fromInt8 Int8.maxInt') = \n"
+         ; printWord16 (IntInf.toWord16 (IntInf.fromInt8 Int8.maxInt')))
+val _ = (printString "IntInf.toWord32 (IntInf.fromInt8 Int8.maxInt') = \n"
+         ; printWord32 (IntInf.toWord32 (IntInf.fromInt8 Int8.maxInt')))
+val _ = (printString "IntInf.toWord64 (IntInf.fromInt8 Int8.maxInt') = \n"
+         ; printWord64 (IntInf.toWord64 (IntInf.fromInt8 Int8.maxInt')))
+
+val _ = (printString "IntInf.toWord8 (IntInf.fromInt16 Int16.maxInt') = \n"
+         ; printWord8 (IntInf.toWord8 (IntInf.fromInt16 Int16.maxInt')))
+val _ = (printString "IntInf.toWord16 (IntInf.fromInt16 Int16.maxInt') = \n"
+         ; printWord16 (IntInf.toWord16 (IntInf.fromInt16 Int16.maxInt')))
+val _ = (printString "IntInf.toWord32 (IntInf.fromInt16 Int16.maxInt') = \n"
+         ; printWord32 (IntInf.toWord32 (IntInf.fromInt16 Int16.maxInt')))
+val _ = (printString "IntInf.toWord64 (IntInf.fromInt16 Int16.maxInt') = \n"
+         ; printWord64 (IntInf.toWord64 (IntInf.fromInt16 Int16.maxInt')))
+
+val _ = (printString "IntInf.toWord8 (IntInf.fromInt32 Int32.maxInt') = \n"
+         ; printWord8 (IntInf.toWord8 (IntInf.fromInt32 Int32.maxInt')))
+val _ = (printString "IntInf.toWord16 (IntInf.fromInt32 Int32.maxInt') = \n"
+         ; printWord16 (IntInf.toWord16 (IntInf.fromInt32 Int32.maxInt')))
+val _ = (printString "IntInf.toWord32 (IntInf.fromInt32 Int32.maxInt') = \n"
+         ; printWord32 (IntInf.toWord32 (IntInf.fromInt32 Int32.maxInt')))
+val _ = (printString "IntInf.toWord64 (IntInf.fromInt32 Int32.maxInt') = \n"
+         ; printWord64 (IntInf.toWord64 (IntInf.fromInt32 Int32.maxInt')))
+
+val _ = (printString "IntInf.toWord8 (IntInf.fromInt64 Int64.maxInt') = \n"
+         ; printWord8 (IntInf.toWord8 (IntInf.fromInt64 Int64.maxInt')))
+val _ = (printString "IntInf.toWord16 (IntInf.fromInt64 Int64.maxInt') = \n"
+         ; printWord16 (IntInf.toWord16 (IntInf.fromInt64 Int64.maxInt')))
+val _ = (printString "IntInf.toWord32 (IntInf.fromInt64 Int64.maxInt') = \n"
+         ; printWord32 (IntInf.toWord32 (IntInf.fromInt64 Int64.maxInt')))
+val _ = (printString "IntInf.toWord64 (IntInf.fromInt64 Int64.maxInt') = \n"
+         ; printWord64 (IntInf.toWord64 (IntInf.fromInt64 Int64.maxInt')))
+

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/basis/Stdio.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/basis/Stdio.c	2006-02-10 00:38:30 UTC (rev 4349)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/basis/Stdio.c	2006-02-10 00:42:03 UTC (rev 4350)
@@ -1,9 +1,21 @@
 #include "platform.h"
 
-void Stdio_print (String8_t s) {
+void Stdio_printStderr (String8_t s) {
   uintmax_t size = GC_getArrayLength ((pointer)s);
   if (0 == size)
     return;
   while (1 != fwrite ((const void*)s, (size_t)size, 1, stderr))
     /* nothing */;
 }
+
+void Stdio_printStdout (String8_t s) {
+  uintmax_t size = GC_getArrayLength ((pointer)s);
+  if (0 == size)
+    return;
+  while (1 != fwrite ((const void*)s, (size_t)size, 1, stdout))
+    /* nothing */;
+}
+
+void Stdio_print (String8_t s) {
+  Stdio_printStderr (s);
+}

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/gen/basis-ffi.def
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/gen/basis-ffi.def	2006-02-10 00:38:30 UTC (rev 4349)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gen/basis-ffi.def	2006-02-10 00:42:03 UTC (rev 4350)
@@ -802,6 +802,8 @@
 Socket.shutdown = _import : C_Sock.t * C_Int.t -> C_Int.t C_Errno.t
 Socket.sockAddrStorageLen = _const : C_Size.t
 Stdio.print = _import : String8.t -> unit
+Stdio.printStderr = _import : String8.t -> unit
+Stdio.printStdout = _import : String8.t -> unit
 Time.getTimeOfDay = _import : unit -> C_Int.t
 Time.sec = _import : unit -> C_Time.t
 Time.usec = _import : unit -> C_SUSeconds.t