38 PANIC(
"Should never happen");
81 return srn_errors_make_error(ctx, metadata,
ABSURD,
"expected a map");
87 return srn_errors_make_error(ctx, metadata,
ABSURD,
"map key is not hashable");
90 hmap_key_t k = {.data = key, .len =
sizeof(*key)};
srn_value_t * srn_value_make(srn_context_t *ctx, srn_value_tag_t tag, srn_metadata_t *metadata, void *payload)
Creates a new serene value.
#define AS_MAP(value_ref)
#define IS_A(value_ref, field)
Error handling for the runtime.
hmap_t hmap_empty(const srn_context_t *ctx)
Create, initialize and return a new hashmap pinned to ctx.
void * hmap_lookup_ctl(const hmap_control_t *ctl, const hmap_t *hmap, const hmap_key_t *k, void *default_value)
Just like the hmap_lookup function but, it receives a hmap_control_t to customize the comparison and ...
hmap_t hmap_insert_ctl(const hmap_control_t *ctl, const hmap_t *hmap, hmap_key_t *k, void *v)
Just like the hmap_insert function but, it receives a hmap_control_t to customize the comparison and ...
hmap_key_t * hmap_copy_key(const hmap_t *hmap, const hmap_key_t *k)
The default copy_key hook.
This is an implementation of Compressed Hash-Array Mapped Prefix-tree, which is a bit-partitioned,...
HMAP_HASH_TYPE hmap_hash_t
srn_value_t * srn_map_assoc(srn_context_t *ctx, srn_metadata_t *metadata, srn_value_t *map, srn_value_t *key, srn_value_t *value)
srn_value_t * srn_map_empty(srn_context_t *ctx, srn_metadata_t *metadata)
static const hmap_control_t value_map
static bool srn_vmap_cmp(const hmap_t *hmap, const hmap_key_t *a, const hmap_key_t *b)
static hmap_hash_t srn_vmap_hash(const hmap_t *hmap, const hmap_key_t *k)
srn_hash_t srn_value_hash(const srn_context_t *ctx, const srn_value_t *v)
Compute the xxHash32 of a value using the engine seed.
srn_value_t * srn_value_eq(const srn_context_t *ctx, const srn_value_t *a, const srn_value_t *b)
Check to values for equality. Return a boolean.
bool srn_value_hashable(const srn_value_t *v)
Whether v can be a hash key.
If we ever want to modify some of these behaviours for a new instance of hashmap, we should use this ...
Note: For key equality we use the memcpy function.
void * data
len 0 -> data == nullptr
const srn_context_t * map_ctx
The context that owns every allocation the map retains.
A persistent, immutable map.
#define PANIC_IF_NULL(ptr)