Skip to content

Commit

Permalink
Merge pull request #3507 from FStarLang/_taramana_sizet_uint64
Browse files Browse the repository at this point in the history
Add a cast from size_t to uint64_t
  • Loading branch information
tahina-pro authored Sep 30, 2024
2 parents c20b10a + 64560b4 commit 061fcdf
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 1 deletion.
15 changes: 14 additions & 1 deletion ocaml/fstar-lib/generated/FStar_Extraction_Krml.ml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions ocaml/fstar-lib/generated/FStar_SizeT.ml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions src/extraction/FStar.Extraction.Krml.fst
Original file line number Diff line number Diff line change
Expand Up @@ -1164,6 +1164,10 @@ and translate_expr' env e: expr =
when string_of_mlpath p = "FStar.SizeT.sizet_to_uint32" ->
ECast (translate_expr env arg, TInt UInt32)

| MLE_App ({ expr = MLE_Name p }, [ arg ])
when string_of_mlpath p = "FStar.SizeT.sizet_to_uint64" ->
ECast (translate_expr env arg, TInt UInt64)

| MLE_App (head, args) ->
EApp (translate_expr env head, List.map (translate_expr env) args)

Expand Down
1 change: 1 addition & 0 deletions ulib/FStar.SizeT.fst
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ let uint16_to_sizet x = uint_to_t (U16.v x)
let uint32_to_sizet x = uint_to_t (U32.v x)
let uint64_to_sizet x = uint_to_t (U64.v x)
let sizet_to_uint32 x = FStar.Int.Cast.uint64_to_uint32 (Sz?.x x)
let sizet_to_uint64 x = (Sz?.x x)

let fits_lte x y = ()

Expand Down
4 changes: 4 additions & 0 deletions ulib/FStar.SizeT.fsti
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ val sizet_to_uint32 (x:t) : Pure U32.t
(requires True)
(ensures fun y -> U32.v y == v x % pow2 32)

val sizet_to_uint64 (x:t) : Pure U64.t
(requires True)
(ensures fun y -> U64.v y == v x % pow2 64)

val fits_lte (x y: nat) : Lemma
(requires (x <= y /\ fits y))
(ensures (fits x))
Expand Down

0 comments on commit 061fcdf

Please sign in to comment.