diff options
author | Son HO | 2023-12-14 16:49:34 +0100 |
---|---|---|
committer | GitHub | 2023-12-14 16:49:34 +0100 |
commit | c3e0b90e422cbd902ee6d2b47073940c0017b7fb (patch) | |
tree | 92da14273eb068bcf418a2bdf9fbb6d27ba86102 /tests/fstar/hashmap | |
parent | c6247e0c103cc1dc95c2a63ae01602c4a1208dc4 (diff) | |
parent | b32fd66b71ad8fe28449d87a2e0334fdd36e286a (diff) |
Merge pull request #53 from AeneasVerif/son/casts
Add support for casts between integers and booleans
Diffstat (limited to '')
-rw-r--r-- | tests/fstar/hashmap/Primitives.fst | 4 | ||||
-rw-r--r-- | tests/fstar/hashmap_on_disk/Primitives.fst | 4 |
2 files changed, 8 insertions, 0 deletions
diff --git a/tests/fstar/hashmap/Primitives.fst b/tests/fstar/hashmap/Primitives.fst index dd340c00..a3ffbde4 100644 --- a/tests/fstar/hashmap/Primitives.fst +++ b/tests/fstar/hashmap/Primitives.fst @@ -273,6 +273,10 @@ let scalar_shr (#ty0 #ty1 : scalar_ty) let scalar_cast (src_ty : scalar_ty) (tgt_ty : scalar_ty) (x : scalar src_ty) : result (scalar tgt_ty) = mk_scalar tgt_ty x +// This can't fail, but for now we make all casts faillible (easier for the translation) +let scalar_cast_bool (tgt_ty : scalar_ty) (x : bool) : result (scalar tgt_ty) = + mk_scalar tgt_ty (if x then 1 else 0) + /// The scalar types type isize : eqtype = scalar Isize type i8 : eqtype = scalar I8 diff --git a/tests/fstar/hashmap_on_disk/Primitives.fst b/tests/fstar/hashmap_on_disk/Primitives.fst index dd340c00..a3ffbde4 100644 --- a/tests/fstar/hashmap_on_disk/Primitives.fst +++ b/tests/fstar/hashmap_on_disk/Primitives.fst @@ -273,6 +273,10 @@ let scalar_shr (#ty0 #ty1 : scalar_ty) let scalar_cast (src_ty : scalar_ty) (tgt_ty : scalar_ty) (x : scalar src_ty) : result (scalar tgt_ty) = mk_scalar tgt_ty x +// This can't fail, but for now we make all casts faillible (easier for the translation) +let scalar_cast_bool (tgt_ty : scalar_ty) (x : bool) : result (scalar tgt_ty) = + mk_scalar tgt_ty (if x then 1 else 0) + /// The scalar types type isize : eqtype = scalar Isize type i8 : eqtype = scalar I8 |