From d6abb5c0ba569ba385cdd862e1a3ea3bc044fef1 Mon Sep 17 00:00:00 2001 From: Yuichi Nishiwaki Date: Sun, 12 Jan 2014 16:09:27 +0900 Subject: [PATCH] add defvar --- src/vm.c | 10 ++++++++++ 1 file changed, 10 insertions(+) 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, ...) {