From ca77353c20e425c687ba207023d56828de6495b6 Mon Sep 17 00:00:00 2001 From: Son Ho Date: Tue, 7 Mar 2023 23:50:36 +0100 Subject: Start updating simplify_aggregates --- tests/fstar/hashmap/Hashmap.Funs.fst | 80 ++++++++++++++++++++++++++++-------- 1 file changed, 63 insertions(+), 17 deletions(-) (limited to 'tests/fstar/hashmap') diff --git a/tests/fstar/hashmap/Hashmap.Funs.fst b/tests/fstar/hashmap/Hashmap.Funs.fst index 62799976..120f8323 100644 --- a/tests/fstar/hashmap/Hashmap.Funs.fst +++ b/tests/fstar/hashmap/Hashmap.Funs.fst @@ -39,7 +39,13 @@ let hash_map_new_with_capacity_fwd let* slots = hash_map_allocate_slots_fwd t v capacity in let* i = usize_mul capacity max_load_dividend in let* i0 = usize_div i max_load_divisor in - Return (Mkhash_map_t 0 (max_load_dividend, max_load_divisor) i0 slots) + Return + { + hash_map_num_entries = 0; + hash_map_max_load_factor = (max_load_dividend, max_load_divisor); + hash_map_max_load = i0; + hash_map_slots = slots + } (** [hashmap::HashMap::{0}::new] *) let hash_map_new_fwd (t : Type0) : result (hash_map_t t) = @@ -63,8 +69,13 @@ let rec hash_map_clear_loop_fwd_back let hash_map_clear_fwd_back (t : Type0) (self : hash_map_t t) : result (hash_map_t t) = let* v = hash_map_clear_loop_fwd_back t self.hash_map_slots 0 in - Return (Mkhash_map_t 0 self.hash_map_max_load_factor self.hash_map_max_load - v) + Return + { + hash_map_num_entries = 0; + hash_map_max_load_factor = self.hash_map_max_load_factor; + hash_map_max_load = self.hash_map_max_load; + hash_map_slots = v + } (** [hashmap::HashMap::{0}::len] *) let hash_map_len_fwd (t : Type0) (self : hash_map_t t) : result usize = @@ -125,13 +136,23 @@ let hash_map_insert_no_resize_fwd_back let* i0 = usize_add self.hash_map_num_entries 1 in let* l0 = hash_map_insert_in_list_back t key value l in let* v = vec_index_mut_back (list_t t) self.hash_map_slots hash_mod l0 in - Return (Mkhash_map_t i0 self.hash_map_max_load_factor - self.hash_map_max_load v) + Return + { + hash_map_num_entries = i0; + hash_map_max_load_factor = self.hash_map_max_load_factor; + hash_map_max_load = self.hash_map_max_load; + hash_map_slots = v + } else let* l0 = hash_map_insert_in_list_back t key value l in let* v = vec_index_mut_back (list_t t) self.hash_map_slots hash_mod l0 in - Return (Mkhash_map_t self.hash_map_num_entries - self.hash_map_max_load_factor self.hash_map_max_load v) + Return + { + hash_map_num_entries = self.hash_map_num_entries; + hash_map_max_load_factor = self.hash_map_max_load_factor; + hash_map_max_load = self.hash_map_max_load; + hash_map_slots = v + } (** [core::num::u32::{9}::MAX] *) let core_num_u32_max_body : result u32 = Return 4294967295 @@ -194,11 +215,21 @@ let hash_map_try_resize_fwd_back let* ntable = hash_map_new_with_capacity_fwd t i2 i i0 in let* (ntable0, _) = hash_map_move_elements_fwd_back t ntable self.hash_map_slots 0 in - Return (Mkhash_map_t self.hash_map_num_entries (i, i0) - ntable0.hash_map_max_load ntable0.hash_map_slots) + Return + { + hash_map_num_entries = self.hash_map_num_entries; + hash_map_max_load_factor = (i, i0); + hash_map_max_load = ntable0.hash_map_max_load; + hash_map_slots = ntable0.hash_map_slots + } else - Return (Mkhash_map_t self.hash_map_num_entries (i, i0) - self.hash_map_max_load self.hash_map_slots) + Return + { + hash_map_num_entries = self.hash_map_num_entries; + hash_map_max_load_factor = (i, i0); + hash_map_max_load = self.hash_map_max_load; + hash_map_slots = self.hash_map_slots + } (** [hashmap::HashMap::{0}::insert] *) let hash_map_insert_fwd_back @@ -325,8 +356,13 @@ let hash_map_get_mut_back let* l = vec_index_mut_fwd (list_t t) self.hash_map_slots hash_mod in let* l0 = hash_map_get_mut_in_list_back t l key ret in let* v = vec_index_mut_back (list_t t) self.hash_map_slots hash_mod l0 in - Return (Mkhash_map_t self.hash_map_num_entries self.hash_map_max_load_factor - self.hash_map_max_load v) + Return + { + hash_map_num_entries = self.hash_map_num_entries; + hash_map_max_load_factor = self.hash_map_max_load_factor; + hash_map_max_load = self.hash_map_max_load; + hash_map_slots = v + } (** [hashmap::HashMap::{0}::remove_from_list] *) let rec hash_map_remove_from_list_loop_fwd @@ -404,14 +440,24 @@ let hash_map_remove_back | None -> let* l0 = hash_map_remove_from_list_back t key l in let* v = vec_index_mut_back (list_t t) self.hash_map_slots hash_mod l0 in - Return (Mkhash_map_t self.hash_map_num_entries - self.hash_map_max_load_factor self.hash_map_max_load v) + Return + { + hash_map_num_entries = self.hash_map_num_entries; + hash_map_max_load_factor = self.hash_map_max_load_factor; + hash_map_max_load = self.hash_map_max_load; + hash_map_slots = v + } | Some x0 -> let* i0 = usize_sub self.hash_map_num_entries 1 in let* l0 = hash_map_remove_from_list_back t key l in let* v = vec_index_mut_back (list_t t) self.hash_map_slots hash_mod l0 in - Return (Mkhash_map_t i0 self.hash_map_max_load_factor - self.hash_map_max_load v) + Return + { + hash_map_num_entries = i0; + hash_map_max_load_factor = self.hash_map_max_load_factor; + hash_map_max_load = self.hash_map_max_load; + hash_map_slots = v + } end (** [hashmap::test1] *) -- cgit v1.2.3