add defvar
This commit is contained in:
parent
10e5546a53
commit
d6abb5c0ba
10
src/vm.c
10
src/vm.c
|
@ -9,6 +9,7 @@
|
||||||
#include "picrin/proc.h"
|
#include "picrin/proc.h"
|
||||||
#include "picrin/irep.h"
|
#include "picrin/irep.h"
|
||||||
#include "picrin/blob.h"
|
#include "picrin/blob.h"
|
||||||
|
#include "picrin/var.h"
|
||||||
|
|
||||||
#define GET_OPERAND(pic,n) ((pic)->ci->fp[(n)])
|
#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));
|
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_value
|
||||||
pic_apply_argv(pic_state *pic, struct pic_proc *proc, size_t argc, ...)
|
pic_apply_argv(pic_state *pic, struct pic_proc *proc, size_t argc, ...)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue