Import Upstream version 20180207
[hcoop/debian/mlton.git] / lib / mlton / basic / int-inf.sml
CommitLineData
7f918cf1
CE
1(* Copyright (C) 2009 Matthew Fluet.
2 * Copyright (C) 1999-2008 Henry Cejtin, Matthew Fluet, Suresh
3 * Jagannathan, and Stephen Weeks.
4 *
5 * MLton is released under a BSD-style license.
6 * See the file MLton-LICENSE for details.
7 *)
8
9structure IntInf: INTEGER = Integer (open Pervasive.IntInf
10 fun toIntInf x = x)
11
12structure IntInf: INT_INF =
13 struct
14 open IntInf
15
16 val hash = let
17 val prime =
18 (Word.toIntInf o Word.~ o Word.fromInt)
19 (case Word.wordSize of
20 6 => 3
21 | 7 => 1
22 | 8 => 5
23 | 14 => 3
24 | 15 => 19
25 | 16 => 15
26 | 30 => 35
27 | 31 => 1
28 | 32 => 5
29 | 62 => 57
30 | 63 => 25
31 | 64 => 59
32 | 126 => 137
33 | 127 => 1
34 | 128 => 159
35 | _ => Error.bug "Unknown Word.wordSize")
36 in
37 fn i => Word.fromIntInf (i mod prime)
38 end
39
40 local
41 open Pervasive.IntInf
42 in
43 val andb = andb
44 val log2 = log2
45 val notb = notb
46 val orb = orb
47 val xorb = xorb
48 val op ~>> = ~>>
49 val op << = <<
50 end
51
52 structure M = MaxPow2ThatDivides (open IntInf
53 val andb = andb
54 val orb = orb
55 val << = <<
56 val >> = ~>>)
57 open M
58 end
59
60structure LargeInt = IntInf