add defvar

This commit is contained in:
Yuichi Nishiwaki 2014-01-12 16:09:27 +09:00
parent 10e5546a53
commit d6abb5c0ba
1 changed files with 10 additions and 0 deletions

View File

@ -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, ...)
{