[MLton-commit] r5900

Vesa Karvonen vesak at mlton.org
Mon Aug 20 04:24:55 PDT 2007


Bug fixed toWord8[X] conversions.

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

U   mltonlib/trunk/com/ssh/extended-basis/unstable/detail/numeric/mk-word-ext.fun

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

Modified: mltonlib/trunk/com/ssh/extended-basis/unstable/detail/numeric/mk-word-ext.fun
===================================================================
--- mltonlib/trunk/com/ssh/extended-basis/unstable/detail/numeric/mk-word-ext.fun	2007-08-20 11:11:29 UTC (rev 5899)
+++ mltonlib/trunk/com/ssh/extended-basis/unstable/detail/numeric/mk-word-ext.fun	2007-08-20 11:24:55 UTC (rev 5900)
@@ -44,14 +44,14 @@
                                    BasisInt.toString wordSize^") not known"))
       val bounds = (fromInt 0, fromInt~1)
       val numBytes = BasisInt.quot (BasisInt.+ (wordSize, 7), 8)
+      val fromWord8 = fromInt o BasisWord8.toInt
+      val fromWord8X = fromInt o BasisWord8.toIntX
       local
          fun mk fold bs =
              if numBytes <> BasisWord8Vector.length bs then
                 raise Subscript
              else
-                fold (fn (b, w) =>
-                         W.orb (W.<< (w, 0w8),
-                                W.fromLarge (BasisWord8.toLarge b)))
+                fold (fn (b, w) => W.orb (W.<< (w, 0w8), fromWord8 b))
                      (W.fromInt 0)
                      bs
       in
@@ -68,25 +68,21 @@
           then BasisFixedInt.fromInt o toIntX
           else BasisFixedInt.fromLarge o toLargeIntX
       val fromWord = fromLarge o BasisWord.toLarge
-      val fromWord8 = fromInt o BasisWord8.toInt
-      val fromWord8X = fromInt o BasisWord8.toIntX
       val fromWordX = fromLarge o BasisWord.toLargeX
+      val toWord8 = BasisWord8.fromLarge o toLarge
+      val toWord8X = BasisWord8.fromLarge o toLargeX
       local
          fun mk idx w =
              BasisWord8Vector.tabulate
                 (numBytes,
                  fn i =>
-                    BasisWord8.fromLarge
-                       (W.toLarge
-                           (W.>> (w, BasisWord.*
-                                        (0w8, BasisWord.fromInt (idx i))))))
+                    (toWord8 o W.>>)
+                       (w, BasisWord.<< (BasisWord.fromInt (idx i), 0w3)))
       in
          val toBigBytes = mk (fn i => BasisInt.- (BasisInt.- (numBytes, 1), i))
          val toLittleBytes = mk (fn i => i)
       end
       val toWord = BasisWord.fromLarge o toLarge
-      val toWord8 = BasisWord8.fromInt o toIntX
-      val toWord8X = toWord8
       val toWordX = BasisWord.fromLarge o toLargeX
       val fromFixedInt =
           if intPrec (fn n => n = valOf BasisFixedInt.precision)




More information about the MLton-commit mailing list