Import Upstream version 20180207
[hcoop/debian/mlton.git] / lib / stubs / basis-stubs-for-smlnj / word.sml
CommitLineData
7f918cf1
CE
1(* Copyright (C) 2009 Matthew Fluet.
2 * Copyright (C) 1999-2006, 2008 Henry Cejtin, Matthew Fluet, Suresh
3 * Jagannathan, and Stephen Weeks.
4 * Copyright (C) 1997-2000 NEC Research Institute.
5 *
6 * MLton is released under a BSD-style license.
7 * See the file MLton-LICENSE for details.
8 *)
9
10functor FixWord(PWord: sig include WORD end) : WORD =
11 struct
12 open PWord
13
14 local
15 (* SML/NJ uses lower instead of upper case. *)
16 val toUpper = String.translate (Char.toString o Char.toUpper)
17 in
18 fun fmt r w = toUpper (PWord.fmt r w)
19 fun toString w = toUpper (PWord.toString w)
20 end
21 end
22
23structure LargeWord = FixWord(struct open Pervasive.LargeWord end)
24structure Word = FixWord(struct open Pervasive.Word end)
25structure Word8 = FixWord(struct open Pervasive.Word8 end)
26structure Word31 = FixWord(struct open Pervasive.Word31 end)
27structure Word32 = FixWord(struct open Pervasive.Word32 end)
28structure Word64 = FixWord(struct open Pervasive.Word64 end)
29structure SysWord = FixWord(struct open Pervasive.SysWord end)
30
31(* Dummy implementation that will not be used at run-time. *)
32structure PackWord64Big : PACK_WORD = struct
33 val bytesPerElem = 0
34 val isBigEndian = true
35 fun subVec _ = raise Fail "PackWord64Big.subVec"
36 fun subVecX _ = raise Fail "PackWord64Big.subVecX"
37 fun subArr _ = raise Fail "PackWord64Big.subArr"
38 fun subArrX _ = raise Fail "PackWord64Big.subArrX"
39 fun update _ = raise Fail "PackWord64Big.update"
40end
41(* Dummy implementation that will not be used at run-time. *)
42structure PackWord64Little : PACK_WORD = struct
43 val bytesPerElem = 0
44 val isBigEndian = false
45 fun subVec _ = raise Fail "PackWord64Little.subVec"
46 fun subVecX _ = raise Fail "PackWord64Little.subVecX"
47 fun subArr _ = raise Fail "PackWord64Little.subArr"
48 fun subArrX _ = raise Fail "PackWord64Little.subArrX"
49 fun update _ = raise Fail "PackWord64Little.update"
50end