[MLton-commit] r4975
Stephen Weeks
sweeks at mlton.org
Thu Dec 14 10:46:16 PST 2006
Added Word.{numBits,toInt,toIntX}.
Added SysWord structure.
----------------------------------------------------------------------
U mltonlib/trunk/com/sweeks/basic/unstable/EXPORT
U mltonlib/trunk/com/sweeks/basic/unstable/export.sig
U mltonlib/trunk/com/sweeks/basic/unstable/export.sml
U mltonlib/trunk/com/sweeks/basic/unstable/word.fun
U mltonlib/trunk/com/sweeks/basic/unstable/word.sig
----------------------------------------------------------------------
Modified: mltonlib/trunk/com/sweeks/basic/unstable/EXPORT
===================================================================
--- mltonlib/trunk/com/sweeks/basic/unstable/EXPORT 2006-12-14 18:39:58 UTC (rev 4974)
+++ mltonlib/trunk/com/sweeks/basic/unstable/EXPORT 2006-12-14 18:46:07 UTC (rev 4975)
@@ -219,6 +219,8 @@
structure SysError: SYS_ERROR
where type Exn.t = SysError.Exn.t
where type t = SysError.t
+structure SysWord: WORD
+ where type t = Word64.t
structure Time: TIME
where type t = Time.t
structure Unit:
@@ -1126,6 +1128,7 @@
val div: (?.t * ?.t) -> ?.t
val mod: (?.t * ?.t) -> ?.t
val notb: ?.t -> ?.t
+ val numBits: Int.t
val ofLarge: Word64.t -> ?.t
val ofString: string -> ?.t Option.t
val ofStringRadix: (string * Radix.t) -> ?.t Option.t
@@ -1133,6 +1136,8 @@
val scanner: Radix.t -> ?.t Scanner.t
val subArr: (Word8.t ArraySlice.base * Int.t * ?.Endian.t) -> ?.t
val subVec: (Word8.t VectorSlice.base * Int.t * ?.Endian.t) -> ?.t
+ val toInt: ?.t -> Int.t
+ val toIntX: ?.t -> Int.t
val toLarge: ?.t -> Word64.t
val toLargeX: ?.t -> Word64.t
val toString: ?.t -> string
@@ -2294,11 +2299,14 @@
val div: (?.t * ?.t) -> ?.t
val mod: (?.t * ?.t) -> ?.t
val notb: ?.t -> ?.t
+ val numBits: Int.t
val ofLarge: Word64.t -> ?.t
val ofString: string -> ?.t Option.t
val ofStringRadix: (string * Radix.t) -> ?.t Option.t
val orb: (?.t * ?.t) -> ?.t
val scanner: Radix.t -> ?.t Scanner.t
+ val toInt: ?.t -> Int.t
+ val toIntX: ?.t -> Int.t
val toLarge: ?.t -> Word64.t
val toLargeX: ?.t -> Word64.t
val toString: ?.t -> string
@@ -2324,12 +2332,15 @@
val div: (?.t * ?.t) -> ?.t
val mod: (?.t * ?.t) -> ?.t
val notb: ?.t -> ?.t
+ val numBits: Int.t
val ofLarge: Word64.t -> ?.t
val ofString: string -> ?.t Option.t
val ofStringRadix: (string * Radix.t) -> ?.t Option.t
val orb: (?.t * ?.t) -> ?.t
val scanner: Radix.t -> ?.t Scanner.t
val toChar: ?.t -> Char.t
+ val toInt: ?.t -> Int.t
+ val toIntX: ?.t -> Int.t
val toLarge: ?.t -> Word64.t
val toLargeX: ?.t -> Word64.t
val toString: ?.t -> string
Modified: mltonlib/trunk/com/sweeks/basic/unstable/export.sig
===================================================================
--- mltonlib/trunk/com/sweeks/basic/unstable/export.sig 2006-12-14 18:39:58 UTC (rev 4974)
+++ mltonlib/trunk/com/sweeks/basic/unstable/export.sig 2006-12-14 18:46:07 UTC (rev 4975)
@@ -46,6 +46,7 @@
structure String: STRING
structure Substring: SUBSTRING
structure SysError: SYS_ERROR
+ structure SysWord: WORD
structure Time: TIME
structure Unit: UNIT
structure Vector: VECTOR
Modified: mltonlib/trunk/com/sweeks/basic/unstable/export.sml
===================================================================
--- mltonlib/trunk/com/sweeks/basic/unstable/export.sml 2006-12-14 18:39:58 UTC (rev 4974)
+++ mltonlib/trunk/com/sweeks/basic/unstable/export.sml 2006-12-14 18:46:07 UTC (rev 4975)
@@ -39,6 +39,7 @@
where type ('a, 'b) String.unfold = ('a, 'b) String.unfold
where type ('a, 'b) String.unfoldR = ('a, 'b) String.unfoldR
where type Substring.t = Substring.t
+ where type SysWord.t = SysWord.t
where type Time.t = Time.t
where type Unit.t = Unit.t
where type 'a Vector.t = 'a Vector.t
@@ -95,6 +96,7 @@
structure String = String
structure Substring = Substring
structure SysError = SysError
+ structure SysWord = SysWord
structure Time = Time
structure Unit = Unit
structure Vector = Vector
Modified: mltonlib/trunk/com/sweeks/basic/unstable/word.fun
===================================================================
--- mltonlib/trunk/com/sweeks/basic/unstable/word.fun 2006-12-14 18:39:58 UTC (rev 4974)
+++ mltonlib/trunk/com/sweeks/basic/unstable/word.fun 2006-12-14 18:46:07 UTC (rev 4975)
@@ -9,6 +9,8 @@
type t = word
+ val numBits = wordSize
+
val == = op =
val compare = Order.ofBasis o compare
Modified: mltonlib/trunk/com/sweeks/basic/unstable/word.sig
===================================================================
--- mltonlib/trunk/com/sweeks/basic/unstable/word.sig 2006-12-14 18:39:58 UTC (rev 4974)
+++ mltonlib/trunk/com/sweeks/basic/unstable/word.sig 2006-12-14 18:46:07 UTC (rev 4975)
@@ -60,6 +60,10 @@
* i mod 0 raises Div.
* i = j * (i div j) + i mod j.
*)
+ val numBits: Int.t
+ (**
+ * The number of bits in a value of this word type.
+ *)
val notb: t -> t
(**
* notb w returns the "bitwise not" of w.
@@ -79,7 +83,16 @@
* orb (w1, w2) returns the "bitwise or" of w1 and w2.
*)
val scanner: Radix.t -> t Scanner.t
+ val toInt: t -> Int.t
(**
+ * toInt w converts w to an integer, where w is in [0, 2^numBits - 1]
+ *)
+ val toIntX: t -> Int.t
+ (**
+ * toIntX w converts w to an integer, where w is in
+ * [-2^(numBits-1), 2^(numBits-1) - 1]
+ *)
+ (**
* scanner r returns a scanner for words where characters are interepreted
* according to radix r.
*)
More information about the MLton-commit
mailing list