core: Add hash_clear!.
* src/hash.c (hash_clear_x): New builtin. * include/mes/builtins.h: Declare it. * src/builtins.c (mes_builtins): Register it.
This commit is contained in:
parent
d481048c10
commit
126aa3f5eb
|
@ -73,6 +73,7 @@ struct scm *hash_table_printer (struct scm *table);
|
|||
struct scm *make_hash_table (struct scm *x);
|
||||
struct scm *hash_table_p (struct scm *x);
|
||||
struct scm *hash_map_to_list (struct scm *proc, struct scm *table);
|
||||
struct scm *hash_clear_x (struct scm *table);
|
||||
/* src/lib.c */
|
||||
struct scm *type_ (struct scm *x);
|
||||
struct scm *car_ (struct scm *x);
|
||||
|
|
|
@ -183,6 +183,7 @@ mes_builtins (struct scm *a) /*:((internal)) */
|
|||
a = init_builtin (builtin_type, "hash-table?", 1, &hash_table_p, a);
|
||||
a = init_builtin (builtin_type, "make-hash-table", -1, &make_hash_table, a);
|
||||
a = init_builtin (builtin_type, "hash-map->list", 2, &hash_map_to_list, a);
|
||||
a = init_builtin (builtin_type, "hash-clear!", 1, &hash_clear_x, a);
|
||||
/* src/lib.c */
|
||||
a = init_builtin (builtin_type, "core:type", 1, &type_, a);
|
||||
a = init_builtin (builtin_type, "core:car", 1, &car_, a);
|
||||
|
|
10
src/hash.c
10
src/hash.c
|
@ -251,3 +251,13 @@ hash_map_to_list (struct scm *proc, struct scm *table)
|
|||
}
|
||||
return lst;
|
||||
}
|
||||
|
||||
struct scm *
|
||||
hash_clear_x (struct scm *table)
|
||||
{
|
||||
struct scm *s = struct_ref_ (table, 3);
|
||||
long size = s->value;
|
||||
struct scm *buckets = make_vector_ (size, cell_unspecified);
|
||||
struct_set_x_ (table, 4, buckets);
|
||||
return cell_unspecified;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue