-
Notifications
You must be signed in to change notification settings - Fork 108
/
Copy pathTargetNumbers-sig.ML
79 lines (67 loc) · 1.46 KB
/
TargetNumbers-sig.ML
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
(*
* Copyright 2020, Data61, CSIRO (ABN 41 687 119 230)
*
* SPDX-License-Identifier: BSD-2-Clause
*)
structure BaseCTypes =
struct
datatype base_inttype = Char | Short | Int | Long | LongLong (* | ITY_Word of int *)
end
signature IMPLEMENTATION_NUMBERS =
sig
type int = IntInf.int
val UCHAR_MAX : int
val USHORT_MAX : int
val UINT_MAX : int
val ULONG_MAX : int
val ULLONG_MAX : int
val SCHAR_MAX : int
val CHAR_MAX : int
val SHORT_MAX : int
val INT_MAX : int
val LONG_MAX : int
val LLONG_MAX : int
val SCHAR_MIN : int
val CHAR_MIN : int
val SHORT_MIN : int
val INT_MIN : int
val LONG_MIN : int
val LLONG_MIN : int
val char_signedp : bool
val CHAR_BIT : int
val boolWidth : int
val charWidth : int
val shortWidth : int
val intWidth : int
val longWidth : int
val llongWidth : int
val ptrWidth : int
val ptr_t : BaseCTypes.base_inttype
exception BadChar
val charliteral_conversion : int -> int
end
signature CHAR_LIT_UTIL =
sig
exception BadChar
type int = IntInf.int
val schar_conv : {umax:int,smin:int,smax:int} -> int -> int
val uchar_conv : {umax:int} -> int -> int
end
structure CharLitUtil : CHAR_LIT_UTIL =
struct
open IntInf
exception BadChar
fun schar_conv {umax,smin,smax} i = let
val _ = 0 <= i andalso i <= umax orelse
raise BadChar
in
if i > smax then smin + i
else i
end
fun uchar_conv {umax} i = let
val _ = 0 <= i andalso i <= umax orelse
raise BadChar
in
i
end
end