diff options
| -rw-r--r-- | lib/ocaml_rts/sail_lib.ml | 8 | ||||
| -rw-r--r-- | src/ocaml_backend.ml | 5 | ||||
| -rw-r--r-- | src/rewriter.ml | 2 |
3 files changed, 13 insertions, 2 deletions
diff --git a/lib/ocaml_rts/sail_lib.ml b/lib/ocaml_rts/sail_lib.ml index 292f187e..3cf4505d 100644 --- a/lib/ocaml_rts/sail_lib.ml +++ b/lib/ocaml_rts/sail_lib.ml @@ -416,7 +416,7 @@ let sub_real (x, y) = Num.sub_num x y let lt (x, y) = lt_big_int x y let gt (x, y) = gt_big_int x y let lteq (x, y) = le_big_int x y -let gteq (x, y) = gt_big_int x y +let gteq (x, y) = ge_big_int x y let pow2 x = power_big_int_positive_int x 2 @@ -462,3 +462,9 @@ let rec string_of_list sep string_of = function | [] -> "" | [x] -> string_of x | x::ls -> (string_of x) ^ sep ^ (string_of_list sep string_of ls) + +let zero_extend (vec, n) = + let m = int_of_big_int n in + if m <= List.length vec + then take m vec + else replicate_bits ([B0], big_int_of_int (m - List.length vec)) @ vec diff --git a/src/ocaml_backend.ml b/src/ocaml_backend.ml index 9b8ac56a..bf5ce83c 100644 --- a/src/ocaml_backend.ml +++ b/src/ocaml_backend.ml @@ -163,6 +163,11 @@ let rec ocaml_exp ctx (E_aux (exp_aux, _) as exp) = | E_app (f, [x]) -> zencode ctx f ^^ space ^^ ocaml_atomic_exp ctx x | E_app (f, xs) when Env.is_union_constructor f (env_of exp) -> zencode_upper ctx f ^^ space ^^ parens (separate_map (comma ^^ space) (ocaml_atomic_exp ctx) xs) + (* Make sure we get the correct short circuiting semantics for and and or *) + | E_app (f, [x; y]) when string_of_id f = "and_bool" -> + separate space [ocaml_atomic_exp ctx x; string "&&"; ocaml_atomic_exp ctx y] + | E_app (f, [x; y]) when string_of_id f = "or_bool" -> + separate space [ocaml_atomic_exp ctx x; string "||"; ocaml_atomic_exp ctx y] | E_app (f, xs) -> zencode ctx f ^^ space ^^ parens (separate_map (comma ^^ space) (ocaml_atomic_exp ctx) xs) | E_vector_subrange (exp1, exp2, exp3) -> string "subrange" ^^ space ^^ parens (separate_map (comma ^^ space) (ocaml_atomic_exp ctx) [exp1; exp2; exp3]) diff --git a/src/rewriter.ml b/src/rewriter.ml index 62e4f7ef..f387e157 100644 --- a/src/rewriter.ml +++ b/src/rewriter.ml @@ -2686,7 +2686,7 @@ let rewrite_simple_types (Defs defs) = e_lit = simple_lit; e_vector = (fun exps -> E_list exps); e_cast = (fun (typ, exp) -> E_cast (simple_typ typ, exp)); - e_assert = (fun (E_aux (_, annot), str) -> E_assert (E_aux (E_lit (mk_lit L_true), annot), str)); + (* e_assert = (fun (E_aux (_, annot), str) -> E_assert (E_aux (E_lit (mk_lit L_true), annot), str)); *) lEXP_cast = (fun (typ, lexp) -> LEXP_cast (simple_typ typ, lexp)); pat_alg = simple_pat } in |
