1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341
|
(* Copyright (C) 1999-2006 Henry Cejtin, Matthew Fluet, Suresh
* Jagannathan, and Stephen Weeks.
* Copyright (C) 1997-2000 NEC Research Institute.
*
* MLton is released under a BSD-style license.
* See the file MLton-LICENSE for details.
*)
signature INT_FROM_TO_ARG =
sig
type int
(* 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
val fromIntInfUnsafe: Primitive.IntInf.int -> int
(* 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
val fromIntInf: Primitive.IntInf.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 fromWord8X: Primitive.Word8.word -> int
val fromWord16X: Primitive.Word16.word -> int
val fromWord32X: Primitive.Word32.word -> int
val fromWord64X: Primitive.Word64.word -> 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
val toIntInfUnsafe: int -> Primitive.IntInf.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 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 toWord8X: int -> Primitive.Word8.word
val toWord16X: int -> Primitive.Word16.word
val toWord32X: int -> Primitive.Word32.word
val toWord64X: int -> Primitive.Word64.word
end
signature INT_FROM_TO_RES =
sig
type int
val fromIntUnsafe: Int.int -> int
val fromInt: Int.int -> int
val fromLargeInt: LargeInt.int -> int
val fromLarge: LargeInt.int -> int
val fromWord: Word.word -> int
val fromWordX: Word.word -> int
val fromLargeWord: LargeWord.word -> int
val fromLargeWordX: LargeWord.word -> int
val fromSysWord: SysWord.word -> int
val fromSysWordX: SysWord.word -> int
val toIntUnsafe: int -> Int.int
val toInt: int -> Int.int
val toLargeInt: int -> LargeInt.int
val toLarge: int -> LargeInt.int
val toWord: int -> Word.word
val toWordX: int -> Word.word
val toLargeWord: int -> LargeWord.word
val toLargeWordX: int -> LargeWord.word
val toSysWord: int -> SysWord.word
val toSysWordX: int -> SysWord.word
end
functor IntFromTo(I: INT_FROM_TO_ARG): INT_FROM_TO_RES where type int = I.int =
struct
open I
local
structure S =
Int_ChooseInt
(type 'a t = 'a -> int
val fInt8 = I.fromInt8Unsafe
val fInt16 = I.fromInt16Unsafe
val fInt32 = I.fromInt32Unsafe
val fInt64 = I.fromInt64Unsafe
val fIntInf = I.fromIntInfUnsafe)
in
val fromIntUnsafe = S.f
end
local
structure S =
Int_ChooseInt
(type 'a t = 'a -> int
val fInt8 = I.fromInt8
val fInt16 = I.fromInt16
val fInt32 = I.fromInt32
val fInt64 = I.fromInt64
val fIntInf = I.fromIntInf)
in
val fromInt = S.f
end
local
structure S =
LargeInt_ChooseInt
(type 'a t = 'a -> int
val fInt8 = I.fromInt8
val fInt16 = I.fromInt16
val fInt32 = I.fromInt32
val fInt64 = I.fromInt64
val fIntInf = I.fromIntInf)
in
val fromLargeInt = S.f
val fromLarge = fromLargeInt
end
local
structure S =
Word_ChooseWordN
(type 'a t = 'a -> int
val fWord8 = I.fromWord8
val fWord16 = I.fromWord16
val fWord32 = I.fromWord32
val fWord64 = I.fromWord64)
in
val fromWord = S.f
end
local
structure S =
Word_ChooseWordN
(type 'a t = 'a -> int
val fWord8 = I.fromWord8X
val fWord16 = I.fromWord16X
val fWord32 = I.fromWord32X
val fWord64 = I.fromWord64X)
in
val fromWordX = S.f
end
local
structure S =
LargeWord_ChooseWordN
(type 'a t = 'a -> int
val fWord8 = I.fromWord8
val fWord16 = I.fromWord16
val fWord32 = I.fromWord32
val fWord64 = I.fromWord64)
in
val fromLargeWord = S.f
end
local
structure S =
LargeWord_ChooseWordN
(type 'a t = 'a -> int
val fWord8 = I.fromWord8X
val fWord16 = I.fromWord16X
val fWord32 = I.fromWord32X
val fWord64 = I.fromWord64X)
in
val fromLargeWordX = S.f
end
local
structure S =
SysWord_ChooseWordN
(type 'a t = 'a -> int
val fWord8 = I.fromWord8
val fWord16 = I.fromWord16
val fWord32 = I.fromWord32
val fWord64 = I.fromWord64)
in
val fromSysWord = S.f
end
local
structure S =
SysWord_ChooseWordN
(type 'a t = 'a -> int
val fWord8 = I.fromWord8X
val fWord16 = I.fromWord16X
val fWord32 = I.fromWord32X
val fWord64 = I.fromWord64X)
in
val fromSysWordX = S.f
end
local
structure S =
Int_ChooseInt
(type 'a t = int -> 'a
val fInt8 = I.toInt8Unsafe
val fInt16 = I.toInt16Unsafe
val fInt32 = I.toInt32Unsafe
val fInt64 = I.toInt64Unsafe
val fIntInf = I.toIntInfUnsafe)
in
val toIntUnsafe = S.f
end
local
structure S =
Int_ChooseInt
(type 'a t = int -> 'a
val fInt8 = I.toInt8
val fInt16 = I.toInt16
val fInt32 = I.toInt32
val fInt64 = I.toInt64
val fIntInf = I.toIntInf)
in
val toInt = S.f
end
local
structure S =
LargeInt_ChooseInt
(type 'a t = int -> 'a
val fInt8 = I.toInt8
val fInt16 = I.toInt16
val fInt32 = I.toInt32
val fInt64 = I.toInt64
val fIntInf = I.toIntInf)
in
val toLargeInt = S.f
val toLarge = toLargeInt
end
local
structure S =
Word_ChooseWordN
(type 'a t = int -> 'a
val fWord8 = I.toWord8
val fWord16 = I.toWord16
val fWord32 = I.toWord32
val fWord64 = I.toWord64)
in
val toWord = S.f
end
local
structure S =
Word_ChooseWordN
(type 'a t = int -> 'a
val fWord8 = I.toWord8X
val fWord16 = I.toWord16X
val fWord32 = I.toWord32X
val fWord64 = I.toWord64X)
in
val toWordX = S.f
end
local
structure S =
LargeWord_ChooseWordN
(type 'a t = int -> 'a
val fWord8 = I.toWord8
val fWord16 = I.toWord16
val fWord32 = I.toWord32
val fWord64 = I.toWord64)
in
val toLargeWord = S.f
end
local
structure S =
LargeWord_ChooseWordN
(type 'a t = int -> 'a
val fWord8 = I.toWord8X
val fWord16 = I.toWord16X
val fWord32 = I.toWord32X
val fWord64 = I.toWord64X)
in
val toLargeWordX = S.f
end
local
structure S =
SysWord_ChooseWordN
(type 'a t = int -> 'a
val fWord8 = I.toWord8
val fWord16 = I.toWord16
val fWord32 = I.toWord32
val fWord64 = I.toWord64)
in
val toSysWord = S.f
end
local
structure S =
SysWord_ChooseWordN
(type 'a t = int -> 'a
val fWord8 = I.toWord8X
val fWord16 = I.toWord16X
val fWord32 = I.toWord32X
val fWord64 = I.toWord64X)
in
val toSysWordX = S.f
end
end
structure Primitive = struct
open Primitive
structure Int8 = struct
open Int8
local
structure S = IntFromTo (Primitive.Int8)
in
open S
end
end
structure Int16 = struct
open Int16
local
structure S = IntFromTo (Primitive.Int16)
in
open S
end
end
structure Int32 = struct
open Int32
local
structure S = IntFromTo (Primitive.Int32)
in
open S
end
end
structure Int64 = struct
open Int64
local
structure S = IntFromTo (Primitive.Int64)
in
open S
end
end
structure IntInf = struct
open IntInf
local
structure S = IntFromTo (Primitive.IntInf)
in
open S
end
end
end
|