add pic_funcall

This commit is contained in:
Yuichi Nishiwaki 2014-07-12 22:07:06 +09:00
parent 13fec26c59
commit fe375a7224
2 changed files with 14 additions and 0 deletions

View File

@ -135,6 +135,8 @@ void pic_define(pic_state *, const char *, pic_value); /* automatic export */
pic_value pic_ref(pic_state *, const char *);
void pic_set(pic_state *, const char *, pic_value);
pic_value pic_funcall(pic_state *pic, const char *name, pic_list args);
struct pic_proc *pic_get_proc(pic_state *);
int pic_get_args(pic_state *, const char *, ...);
void pic_defun(pic_state *, const char *, pic_func_t);

View File

@ -444,6 +444,18 @@ pic_set(pic_state *pic, const char *name, pic_value value)
pic->globals[gid] = value;
}
pic_value
pic_funcall(pic_state *pic, const char *name, pic_list args)
{
pic_value proc;
proc = pic_ref(pic, name);
pic_assert_type(pic, proc, proc);
return pic_apply(pic, pic_proc_ptr(proc), args);
}
void
pic_defun(pic_state *pic, const char *name, pic_func_t cfunc)
{