Skip to content

Commit 5411736

Browse files
committed
Type check expressions during construction
1 parent 801e1b7 commit 5411736

29 files changed

+793
-662
lines changed

doc/examples.mld

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ let read_int () = Scanf.scanf " %d" (fun x -> x)
7272

7373
let int x = Expr.value (Int x)
7474

75-
let symbol x = Expr.symbol Symbol.(x @: Ty_int)
75+
let symbol x = Expr.symbol Symbol.(x @: Ty Ty_int)
7676

7777
let ( = ) i1 i2 = Expr.relop Ty_bool Eq i1 i2
7878

doc/examples/product_mix.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ let read_int () = Scanf.scanf " %d" (fun x -> x)
55

66
let int x = Expr.value (Int x)
77

8-
let symbol x = Expr.symbol Symbol.(x @: Ty_int)
8+
let symbol x = Expr.symbol Symbol.(x @: Ty Ty_int)
99

1010
let ( = ) i1 i2 = Expr.relop Ty_bool Eq i1 i2
1111

doc/index.mld

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@ Example: Bitvector arithmetic
9393
{@ocaml[
9494
# open Smtml;;
9595
# let cond =
96-
let x = Expr.symbol (Symbol.make (Ty_bitv 8) "x") in
97-
let y = Expr.symbol (Symbol.make (Ty_bitv 8) "y") in
96+
let x = Expr.symbol (Symbol.make (Ty (Ty_bitv 8)) "x") in
97+
let y = Expr.symbol (Symbol.make (Ty (Ty_bitv 8)) "y") in
9898
let sum = Expr.binop (Ty_bitv 8) Add x y in
9999
let num = Expr.value (Bitv (Bitvector.of_int8 42)) in
100100
Expr.relop Ty_bool Eq sum num;;
@@ -123,7 +123,7 @@ val model : Model.t = (model
123123
(x i8 9)
124124
(y i8 33))
125125
# let x_val =
126-
let x = Symbol.make (Ty_bitv 8) "x" in
126+
let x = Symbol.make (Ty (Ty_bitv 8)) "x" in
127127
Model.evaluate model x;;
128128
val x_val : Value.t option = Some (Smtml.Value.Bitv <abstr>)
129129
]}

src/smtml/altergo_mappings.default.ml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -221,10 +221,10 @@ module M = struct
221221
module Model = struct
222222
let aety_to_ty (ty : AEL.Ty.t) : Ty.t =
223223
match ty with
224-
| Tbool -> Ty_bool
225-
| Tint -> Ty_int
226-
| Treal -> Ty_real
227-
| Tbitv n -> Ty_bitv n
224+
| Tbool -> Ty Ty_bool
225+
| Tint -> Ty Ty_int
226+
| Treal -> Ty Ty_real
227+
| Tbitv n -> Ty (Ty_bitv n)
228228
| _ -> assert false
229229

230230
let aeid_to_sym ((hs, tyl, ty) : AEL.Id.typed) =

src/smtml/dolmenexpr_to_expr.ml

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -150,9 +150,11 @@ module DolmenIntf = struct
150150

151151
let to_ety (ty : DTy.t) : Ty.t =
152152
match ty with
153-
| { ty_descr = TyApp ({ builtin = DBuiltin.Int; _ }, _); _ } -> Ty_int
154-
| { ty_descr = TyApp ({ builtin = DBuiltin.Real; _ }, _); _ } -> Ty_real
155-
| { ty_descr = TyApp ({ builtin = DBuiltin.Prop; _ }, _); _ } -> Ty_bool
153+
| { ty_descr = TyApp ({ builtin = DBuiltin.Int; _ }, _); _ } -> Ty Ty_int
154+
| { ty_descr = TyApp ({ builtin = DBuiltin.Real; _ }, _); _ } ->
155+
Ty Ty_real
156+
| { ty_descr = TyApp ({ builtin = DBuiltin.Prop; _ }, _); _ } ->
157+
Ty Ty_bool
156158
| { ty_descr =
157159
TyApp
158160
( { builtin = DBuiltin.Base
@@ -162,13 +164,13 @@ module DolmenIntf = struct
162164
, _ )
163165
; _
164166
} ->
165-
Ty_str
167+
Ty Ty_str
166168
| { ty_descr = TyApp ({ builtin = DBuiltin.Bitv n; _ }, _); _ } ->
167-
Ty_bitv n
169+
Ty (Ty_bitv n)
168170
| { ty_descr = TyApp ({ builtin = DBuiltin.Float (8, 24); _ }, _); _ } ->
169-
Ty_fp 32
171+
Ty (Ty_fp 32)
170172
| { ty_descr = TyApp ({ builtin = DBuiltin.Float (11, 53); _ }, _); _ } ->
171-
Ty_fp 64
173+
Ty (Ty_fp 64)
172174
| _ -> Fmt.failwith {|Unsupported dolmen type "%a"|} DTy.print ty
173175
end
174176

src/smtml/dune

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
symbol
5252
ty
5353
utils
54+
utils_parse
5455
value
5556
z3_mappings)
5657
(private_modules lexer parser)

0 commit comments

Comments
 (0)