diff --git a/src/vm.c b/src/vm.c index 9e8a26c3..995bc545 100644 --- a/src/vm.c +++ b/src/vm.c @@ -9,6 +9,7 @@ #include "picrin/proc.h" #include "picrin/irep.h" #include "picrin/blob.h" +#include "picrin/var.h" #define GET_OPERAND(pic,n) ((pic)->ci->fp[(n)]) @@ -309,6 +310,15 @@ pic_defun(pic_state *pic, const char *name, pic_func_t cfunc) pic_define(pic, pic->lib, name, pic_obj_value(proc)); } +void +pic_defvar(pic_state *pic, const char *name, pic_value init) +{ + struct pic_var *var; + + var = pic_var_new(pic, init, NULL); + pic_define(pic, pic->lib, name, pic_obj_value(pic_wrap_var(pic, var))); +} + pic_value pic_apply_argv(pic_state *pic, struct pic_proc *proc, size_t argc, ...) {