diff options
Diffstat (limited to 'uscript/uscript.c')
| -rw-r--r-- | uscript/uscript.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/uscript/uscript.c b/uscript/uscript.c index 008bcbe..6afdb25 100644 --- a/uscript/uscript.c +++ b/uscript/uscript.c @@ -4,9 +4,10 @@ #include "dyn_arr.h" #include "lex.h" +#include "map.h" +#include "parser.h" #include "val.h" #include "vm.h" -#include "parser.h" void core_print(int argc) { @@ -116,6 +117,17 @@ void arr_iter(int argc) vm_push(wrap_cfunc(cfunc)); } +void map_has(int argc) +{ + (void)argc; + if (vm_get(0).type != VAL_MAP) + us_err("map:has expected a map"); + + struct us_map *map = get_map(vm_get(0)); + bool has = map_get_value(map, vm_get(1), NULL); + vm_push(create_bool(has)); +} + void us_init(void) { init_vm(); @@ -126,6 +138,8 @@ void us_init(void) us_set_cfunc("arr:iter", arr_iter, 1); us_set_cfunc("arr:add", arr_add, 2); + + us_set_cfunc("map:has", map_has, 2); } void us_deinit(void) @@ -159,3 +173,4 @@ void us_set_cfunc(const char *c_name, us_cfunc_sig c, int argc) int global = declare_global(name); set_global(global, wrap_cfunc(create_cfunc(name, c, argc))); } + |
