Skip to content

Commit

Permalink
basic implementation of a new primitive type for sequences implemente…
Browse files Browse the repository at this point in the history
…d by OCaml arrays
  • Loading branch information
nikswamy committed Nov 1, 2022
1 parent c722846 commit 23e6af9
Show file tree
Hide file tree
Showing 18 changed files with 782 additions and 45 deletions.
4 changes: 4 additions & 0 deletions src/basic/boot/FStar.Compiler.Util.fsti
Original file line number Diff line number Diff line change
Expand Up @@ -436,3 +436,7 @@ val write : ref 'a -> 'a -> unit
(* Marshaling to and from strings *)
val marshal: 'a -> string
val unmarshal: string -> 'a

val print_array (f: 'a -> string) (s:FStar.ConstantTimeSequence.seq 'a) : string
val array_length (s:FStar.ConstantTimeSequence.seq 'a) : FStar.BigInt.t
val array_index (s:FStar.ConstantTimeSequence.seq 'a) (i:FStar.BigInt.t) : 'a
12 changes: 12 additions & 0 deletions src/basic/ml/FStar_Compiler_Util.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1253,3 +1253,15 @@ let within_bounds repr signedness width =
let lower, upper = bounds signedness width in
let value = Z.of_string (ensure_decimal repr) in
Z.leq lower value && Z.leq value upper

let print_array (f: 'a -> string)
(s: 'a array)
: string
= let ls = Array.fold_left (fun out a -> f a :: out) [] s in
format1 "[| %s |]" (String.concat "; " (List.rev ls))

let array_of_list (l:'a list) = FStar_ConstantTimeSequence.of_list l

let array_length (l:'a FStar_ConstantTimeSequence.seq) = FStar_ConstantTimeSequence.length l

let array_index (l:'a FStar_ConstantTimeSequence.seq) (i:Z.t) = FStar_ConstantTimeSequence.index l i
8 changes: 8 additions & 0 deletions src/ocaml-output/FStar_Parser_Const.ml

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

49 changes: 49 additions & 0 deletions src/ocaml-output/FStar_Syntax_Embeddings.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/ocaml-output/FStar_Syntax_Syntax.ml

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

154 changes: 137 additions & 17 deletions src/ocaml-output/FStar_ToSyntax_Interleave.ml

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

Loading

0 comments on commit 23e6af9

Please sign in to comment.