diff options
author | Son Ho | 2022-11-15 16:32:35 +0100 |
---|---|---|
committer | Son HO | 2022-11-16 15:45:32 +0100 |
commit | 8bf0452f91c44ff390556db77bf42697c0443b67 (patch) | |
tree | 4c4d8b318b39acf03b9dd59e953af87e242d6960 /tests/coq/hashmap_on_disk | |
parent | fa6dcd3ebbdc7a508157ff2a12f91e70d2012a86 (diff) |
Generate record field projectors for Coq
Diffstat (limited to 'tests/coq/hashmap_on_disk')
-rw-r--r-- | tests/coq/hashmap_on_disk/HashmapMain_Funs.v | 228 | ||||
-rw-r--r-- | tests/coq/hashmap_on_disk/_CoqProject | 6 |
2 files changed, 120 insertions, 114 deletions
diff --git a/tests/coq/hashmap_on_disk/HashmapMain_Funs.v b/tests/coq/hashmap_on_disk/HashmapMain_Funs.v index b4351dc3..94a390df 100644 --- a/tests/coq/hashmap_on_disk/HashmapMain_Funs.v +++ b/tests/coq/hashmap_on_disk/HashmapMain_Funs.v @@ -89,18 +89,19 @@ Definition hashmap_hash_map_clear_fwd_back match n with | O => Fail_ OutOfFuel | S n0 => - match self with - | mkHashmap_hash_map_t i p i0 v => - v0 <- hashmap_hash_map_clear_slots_fwd_back T n0 v (0%usize); - Return (mkHashmap_hash_map_t (0%usize) p i0 v0) - end + v <- + hashmap_hash_map_clear_slots_fwd_back T n0 self.(Hashmap_hash_map_slots) + (0%usize); + Return (mkHashmap_hash_map_t (0%usize) + self.(Hashmap_hash_map_max_load_factor) self.(Hashmap_hash_map_max_load) + v) end . (** [hashmap_main::hashmap::HashMap::{0}::len] *) Definition hashmap_hash_map_len_fwd (T : Type) (self : Hashmap_hash_map_t T) : result usize := - match self with | mkHashmap_hash_map_t i p i0 v => Return i end + Return self.(Hashmap_hash_map_num_entries) . (** [hashmap_main::hashmap::HashMap::{0}::insert_in_list] *) @@ -153,23 +154,29 @@ Definition hashmap_hash_map_insert_no_resize_fwd_back | O => Fail_ OutOfFuel | S n0 => hash <- hashmap_hash_key_fwd key; - match self with - | mkHashmap_hash_map_t i p i0 v => - let i1 := vec_len (Hashmap_list_t T) v in - hash_mod <- usize_rem hash i1; - l <- vec_index_mut_fwd (Hashmap_list_t T) v hash_mod; - inserted <- hashmap_hash_map_insert_in_list_fwd T n0 key value l; - if inserted - then ( - i2 <- usize_add i 1%usize; - l0 <- hashmap_hash_map_insert_in_list_back T n0 key value l; - v0 <- vec_index_mut_back (Hashmap_list_t T) v hash_mod l0; - Return (mkHashmap_hash_map_t i2 p i0 v0)) - else ( - l0 <- hashmap_hash_map_insert_in_list_back T n0 key value l; - v0 <- vec_index_mut_back (Hashmap_list_t T) v hash_mod l0; - Return (mkHashmap_hash_map_t i p i0 v0)) - end + let i := vec_len (Hashmap_list_t T) self.(Hashmap_hash_map_slots) in + hash_mod <- usize_rem hash i; + l <- + vec_index_mut_fwd (Hashmap_list_t T) self.(Hashmap_hash_map_slots) + hash_mod; + inserted <- hashmap_hash_map_insert_in_list_fwd T n0 key value l; + if inserted + then ( + i0 <- usize_add self.(Hashmap_hash_map_num_entries) 1%usize; + l0 <- hashmap_hash_map_insert_in_list_back T n0 key value l; + v <- + vec_index_mut_back (Hashmap_list_t T) self.(Hashmap_hash_map_slots) + hash_mod l0; + Return (mkHashmap_hash_map_t i0 self.(Hashmap_hash_map_max_load_factor) + self.(Hashmap_hash_map_max_load) v)) + else ( + l0 <- hashmap_hash_map_insert_in_list_back T n0 key value l; + v <- + vec_index_mut_back (Hashmap_list_t T) self.(Hashmap_hash_map_slots) + hash_mod l0; + Return (mkHashmap_hash_map_t self.(Hashmap_hash_map_num_entries) + self.(Hashmap_hash_map_max_load_factor) + self.(Hashmap_hash_map_max_load) v)) end . @@ -232,24 +239,23 @@ Definition hashmap_hash_map_try_resize_fwd_back | O => Fail_ OutOfFuel | S n0 => max_usize <- scalar_cast U32 Usize core_num_u32_max_c; - match self with - | mkHashmap_hash_map_t i p i0 v => - let capacity := vec_len (Hashmap_list_t T) v in - n1 <- usize_div max_usize 2%usize; - let (i1, i2) := p in - i3 <- usize_div n1 i1; - if capacity s<= i3 - then ( - i4 <- usize_mul capacity 2%usize; - ntable <- hashmap_hash_map_new_with_capacity_fwd T n0 i4 i1 i2; - p0 <- hashmap_hash_map_move_elements_fwd_back T n0 ntable v (0%usize); - let (ntable0, _) := p0 in - match ntable0 with - | mkHashmap_hash_map_t i5 p1 i6 v0 => - Return (mkHashmap_hash_map_t i (i1, i2) i6 v0) - end) - else Return (mkHashmap_hash_map_t i (i1, i2) i0 v) - end + let capacity := vec_len (Hashmap_list_t T) self.(Hashmap_hash_map_slots) in + n1 <- usize_div max_usize 2%usize; + let (i, i0) := self.(Hashmap_hash_map_max_load_factor) in + i1 <- usize_div n1 i; + if capacity s<= i1 + then ( + i2 <- usize_mul capacity 2%usize; + ntable <- hashmap_hash_map_new_with_capacity_fwd T n0 i2 i i0; + p <- + hashmap_hash_map_move_elements_fwd_back T n0 ntable + self.(Hashmap_hash_map_slots) (0%usize); + let (ntable0, _) := p in + Return (mkHashmap_hash_map_t self.(Hashmap_hash_map_num_entries) (i, i0) + ntable0.(Hashmap_hash_map_max_load) ntable0.(Hashmap_hash_map_slots))) + else + Return (mkHashmap_hash_map_t self.(Hashmap_hash_map_num_entries) (i, i0) + self.(Hashmap_hash_map_max_load) self.(Hashmap_hash_map_slots)) end . @@ -264,16 +270,10 @@ Definition hashmap_hash_map_insert_fwd_back | S n0 => self0 <- hashmap_hash_map_insert_no_resize_fwd_back T n0 self key value; i <- hashmap_hash_map_len_fwd T self0; - match self0 with - | mkHashmap_hash_map_t i0 p i1 v => - if i s> i1 - then ( - self1 <- - hashmap_hash_map_try_resize_fwd_back T n0 (mkHashmap_hash_map_t i0 p - i1 v); - Return self1) - else Return (mkHashmap_hash_map_t i0 p i1 v) - end + if i s> self0.(Hashmap_hash_map_max_load) + then ( + self1 <- hashmap_hash_map_try_resize_fwd_back T n0 self0; Return self1) + else Return self0 end . @@ -303,14 +303,12 @@ Definition hashmap_hash_map_contains_key_fwd | O => Fail_ OutOfFuel | S n0 => hash <- hashmap_hash_key_fwd key; - match self with - | mkHashmap_hash_map_t i p i0 v => - let i1 := vec_len (Hashmap_list_t T) v in - hash_mod <- usize_rem hash i1; - l <- vec_index_fwd (Hashmap_list_t T) v hash_mod; - b <- hashmap_hash_map_contains_key_in_list_fwd T n0 key l; - Return b - end + let i := vec_len (Hashmap_list_t T) self.(Hashmap_hash_map_slots) in + hash_mod <- usize_rem hash i; + l <- + vec_index_fwd (Hashmap_list_t T) self.(Hashmap_hash_map_slots) hash_mod; + b <- hashmap_hash_map_contains_key_in_list_fwd T n0 key l; + Return b end . @@ -339,14 +337,12 @@ Definition hashmap_hash_map_get_fwd | O => Fail_ OutOfFuel | S n0 => hash <- hashmap_hash_key_fwd key; - match self with - | mkHashmap_hash_map_t i p i0 v => - let i1 := vec_len (Hashmap_list_t T) v in - hash_mod <- usize_rem hash i1; - l <- vec_index_fwd (Hashmap_list_t T) v hash_mod; - t <- hashmap_hash_map_get_in_list_fwd T n0 key l; - Return t - end + let i := vec_len (Hashmap_list_t T) self.(Hashmap_hash_map_slots) in + hash_mod <- usize_rem hash i; + l <- + vec_index_fwd (Hashmap_list_t T) self.(Hashmap_hash_map_slots) hash_mod; + t <- hashmap_hash_map_get_in_list_fwd T n0 key l; + Return t end . @@ -395,14 +391,13 @@ Definition hashmap_hash_map_get_mut_fwd | O => Fail_ OutOfFuel | S n0 => hash <- hashmap_hash_key_fwd key; - match self with - | mkHashmap_hash_map_t i p i0 v => - let i1 := vec_len (Hashmap_list_t T) v in - hash_mod <- usize_rem hash i1; - l <- vec_index_mut_fwd (Hashmap_list_t T) v hash_mod; - t <- hashmap_hash_map_get_mut_in_list_fwd T n0 key l; - Return t - end + let i := vec_len (Hashmap_list_t T) self.(Hashmap_hash_map_slots) in + hash_mod <- usize_rem hash i; + l <- + vec_index_mut_fwd (Hashmap_list_t T) self.(Hashmap_hash_map_slots) + hash_mod; + t <- hashmap_hash_map_get_mut_in_list_fwd T n0 key l; + Return t end . @@ -415,15 +410,18 @@ Definition hashmap_hash_map_get_mut_back | O => Fail_ OutOfFuel | S n0 => hash <- hashmap_hash_key_fwd key; - match self with - | mkHashmap_hash_map_t i p i0 v => - let i1 := vec_len (Hashmap_list_t T) v in - hash_mod <- usize_rem hash i1; - l <- vec_index_mut_fwd (Hashmap_list_t T) v hash_mod; - l0 <- hashmap_hash_map_get_mut_in_list_back T n0 key l ret; - v0 <- vec_index_mut_back (Hashmap_list_t T) v hash_mod l0; - Return (mkHashmap_hash_map_t i p i0 v0) - end + let i := vec_len (Hashmap_list_t T) self.(Hashmap_hash_map_slots) in + hash_mod <- usize_rem hash i; + l <- + vec_index_mut_fwd (Hashmap_list_t T) self.(Hashmap_hash_map_slots) + hash_mod; + l0 <- hashmap_hash_map_get_mut_in_list_back T n0 key l ret; + v <- + vec_index_mut_back (Hashmap_list_t T) self.(Hashmap_hash_map_slots) + hash_mod l0; + Return (mkHashmap_hash_map_t self.(Hashmap_hash_map_num_entries) + self.(Hashmap_hash_map_max_load_factor) self.(Hashmap_hash_map_max_load) + v) end . @@ -489,16 +487,18 @@ Definition hashmap_hash_map_remove_fwd | O => Fail_ OutOfFuel | S n0 => hash <- hashmap_hash_key_fwd key; - match self with - | mkHashmap_hash_map_t i p i0 v => - let i1 := vec_len (Hashmap_list_t T) v in - hash_mod <- usize_rem hash i1; - l <- vec_index_mut_fwd (Hashmap_list_t T) v hash_mod; - x <- hashmap_hash_map_remove_from_list_fwd T n0 key l; - match x with - | None => Return None - | Some x0 => i2 <- usize_sub i 1%usize; let _ := i2 in Return (Some x0) - end + let i := vec_len (Hashmap_list_t T) self.(Hashmap_hash_map_slots) in + hash_mod <- usize_rem hash i; + l <- + vec_index_mut_fwd (Hashmap_list_t T) self.(Hashmap_hash_map_slots) + hash_mod; + x <- hashmap_hash_map_remove_from_list_fwd T n0 key l; + match x with + | None => Return None + | Some x0 => + i0 <- usize_sub self.(Hashmap_hash_map_num_entries) 1%usize; + let _ := i0 in + Return (Some x0) end end . @@ -512,23 +512,29 @@ Definition hashmap_hash_map_remove_back | O => Fail_ OutOfFuel | S n0 => hash <- hashmap_hash_key_fwd key; - match self with - | mkHashmap_hash_map_t i p i0 v => - let i1 := vec_len (Hashmap_list_t T) v in - hash_mod <- usize_rem hash i1; - l <- vec_index_mut_fwd (Hashmap_list_t T) v hash_mod; - x <- hashmap_hash_map_remove_from_list_fwd T n0 key l; - match x with - | None => - l0 <- hashmap_hash_map_remove_from_list_back T n0 key l; - v0 <- vec_index_mut_back (Hashmap_list_t T) v hash_mod l0; - Return (mkHashmap_hash_map_t i p i0 v0) - | Some x0 => - i2 <- usize_sub i 1%usize; - l0 <- hashmap_hash_map_remove_from_list_back T n0 key l; - v0 <- vec_index_mut_back (Hashmap_list_t T) v hash_mod l0; - Return (mkHashmap_hash_map_t i2 p i0 v0) - end + let i := vec_len (Hashmap_list_t T) self.(Hashmap_hash_map_slots) in + hash_mod <- usize_rem hash i; + l <- + vec_index_mut_fwd (Hashmap_list_t T) self.(Hashmap_hash_map_slots) + hash_mod; + x <- hashmap_hash_map_remove_from_list_fwd T n0 key l; + match x with + | None => + l0 <- hashmap_hash_map_remove_from_list_back T n0 key l; + v <- + vec_index_mut_back (Hashmap_list_t T) self.(Hashmap_hash_map_slots) + hash_mod l0; + Return (mkHashmap_hash_map_t self.(Hashmap_hash_map_num_entries) + self.(Hashmap_hash_map_max_load_factor) + self.(Hashmap_hash_map_max_load) v) + | Some x0 => + i0 <- usize_sub self.(Hashmap_hash_map_num_entries) 1%usize; + l0 <- hashmap_hash_map_remove_from_list_back T n0 key l; + v <- + vec_index_mut_back (Hashmap_list_t T) self.(Hashmap_hash_map_slots) + hash_mod l0; + Return (mkHashmap_hash_map_t i0 self.(Hashmap_hash_map_max_load_factor) + self.(Hashmap_hash_map_max_load) v) end end . diff --git a/tests/coq/hashmap_on_disk/_CoqProject b/tests/coq/hashmap_on_disk/_CoqProject index 10e247ae..95b82c41 100644 --- a/tests/coq/hashmap_on_disk/_CoqProject +++ b/tests/coq/hashmap_on_disk/_CoqProject @@ -4,6 +4,6 @@ Primitives.v -HashmapMain__Funs.v -HashmapMain__Opaque.v -HashmapMain__Types.v
\ No newline at end of file +HashmapMain_Funs.v +HashmapMain_Opaque.v +HashmapMain_Types.v
\ No newline at end of file |