Commit | Line | Data |
---|---|---|
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 | ||
10 | functor 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 | ||
23 | structure LargeWord = FixWord(struct open Pervasive.LargeWord end) | |
24 | structure Word = FixWord(struct open Pervasive.Word end) | |
25 | structure Word8 = FixWord(struct open Pervasive.Word8 end) | |
26 | structure Word31 = FixWord(struct open Pervasive.Word31 end) | |
27 | structure Word32 = FixWord(struct open Pervasive.Word32 end) | |
28 | structure Word64 = FixWord(struct open Pervasive.Word64 end) | |
29 | structure SysWord = FixWord(struct open Pervasive.SysWord end) | |
30 | ||
31 | (* Dummy implementation that will not be used at run-time. *) | |
32 | structure 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" | |
40 | end | |
41 | (* Dummy implementation that will not be used at run-time. *) | |
42 | structure 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" | |
50 | end |