forked from caterinaurban/function
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbanal_semantics.ml
54 lines (40 loc) · 1.49 KB
/
banal_semantics.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
(*
Semantic definitions and utilities
Copyright (C) 2011 Antoine Miné
*)
open Banal_datatypes
open Banal_abstract_syntax
open Banal_typed_syntax
module Int = Banal_int
module Float = Banal_float
module Itv_int = Banal_itv_int
module Itv_float = Banal_itv_float
(* value domain of each type *)
let signed_set bsize =
Finite (Int.neg (Int.shift_left Int.one (bsize-1))),
Finite (Int.pred (Int.shift_left Int.one (bsize-1)))
let unsigned_set bsize =
Finite Int.zero, Finite (Int.pred (Int.shift_left Int.one bsize))
let int_type_set (t:int_type) (s:int_sign) : Itv_int.t =
match t,s with
| A_CHAR, A_SIGNED -> signed_set 8
| A_CHAR, A_UNSIGNED -> unsigned_set 8
| A_SHORT, A_SIGNED -> signed_set 16
| A_SHORT, A_UNSIGNED -> unsigned_set 16
| A_INT, A_SIGNED -> signed_set 32
| A_INT, A_UNSIGNED -> unsigned_set 32
| A_LONG, A_SIGNED -> signed_set 64
| A_LONG, A_UNSIGNED -> unsigned_set 64
| A_INTEGER, A_SIGNED -> MINF, INF
| A_INTEGER, A_UNSIGNED -> Finite Int.zero, INF
let float_type_set (t:float_type) : Itv_float.t =
match t with
| A_FLOAT -> -.Float.Single.max_normal, Float.Single.max_normal
| A_DOUBLE -> -.Float.Double.max_normal, Float.Double.max_normal
| A_REAL -> neg_infinity, infinity
let bool_type_set = Maybe
let type_set_expr (t:typ) : expr =
match t with
| A_int (i,s) -> T_int_const (int_type_set i s)
| A_float f -> T_float_const (float_type_set f)
| A_BOOL -> T_bool_const Maybe