remove pic_funcallk and add pic_call
This commit is contained in:
parent
417a44b786
commit
69b660e9a3
|
@ -151,11 +151,7 @@ void pic_defvar(pic_state *, const char *, pic_value, struct pic_proc *);
|
|||
void pic_define(pic_state *, struct pic_lib *, const char *, pic_value);
|
||||
pic_value pic_ref(pic_state *, struct pic_lib *, const char *);
|
||||
void pic_set(pic_state *, struct pic_lib *, const char *, pic_value);
|
||||
pic_value pic_funcall(pic_state *pic, struct pic_lib *, const char *, pic_value);
|
||||
pic_value pic_funcall0(pic_state *pic, struct pic_lib *, const char *);
|
||||
pic_value pic_funcall1(pic_state *pic, struct pic_lib *, const char *, pic_value);
|
||||
pic_value pic_funcall2(pic_state *pic, struct pic_lib *, const char *, pic_value, pic_value);
|
||||
pic_value pic_funcall3(pic_state *pic, struct pic_lib *, const char *, pic_value, pic_value, pic_value);
|
||||
pic_value pic_funcall(pic_state *pic, struct pic_lib *, const char *, int, ...);
|
||||
|
||||
struct pic_lib *pic_make_library(pic_state *, pic_value);
|
||||
struct pic_lib *pic_find_library(pic_state *, pic_value);
|
||||
|
@ -165,6 +161,8 @@ void pic_export(pic_state *, pic_sym *);
|
|||
PIC_NORETURN void pic_panic(pic_state *, const char *);
|
||||
PIC_NORETURN void pic_errorf(pic_state *, const char *, ...);
|
||||
|
||||
pic_value pic_call(pic_state *, struct pic_proc *, int, ...);
|
||||
pic_value pic_vcall(pic_state *, struct pic_proc *, int, va_list);
|
||||
pic_value pic_apply(pic_state *, struct pic_proc *, int, pic_value *);
|
||||
pic_value pic_apply0(pic_state *, struct pic_proc *);
|
||||
pic_value pic_apply1(pic_state *, struct pic_proc *, pic_value);
|
||||
|
|
|
@ -172,7 +172,7 @@ pic_define_standard_port(pic_state *pic, const char *name, xFILE *file, int dir)
|
|||
{ \
|
||||
pic_value obj; \
|
||||
\
|
||||
obj = pic_funcall0(pic, pic->PICRIN_BASE, var); \
|
||||
obj = pic_funcall(pic, pic->PICRIN_BASE, var, 0); \
|
||||
\
|
||||
return pic_port_ptr(obj); \
|
||||
}
|
||||
|
|
|
@ -783,6 +783,30 @@ pic_apply(pic_state *pic, struct pic_proc *proc, int argc, pic_value *argv)
|
|||
} VM_LOOP_END;
|
||||
}
|
||||
|
||||
pic_value
|
||||
pic_call(pic_state *pic, struct pic_proc *proc, int n, ...)
|
||||
{
|
||||
pic_value r;
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, n);
|
||||
r = pic_vcall(pic, proc, n, ap);
|
||||
va_end(ap);
|
||||
return r;
|
||||
}
|
||||
|
||||
pic_value
|
||||
pic_vcall(pic_state *pic, struct pic_proc *proc, int n, va_list ap)
|
||||
{
|
||||
pic_value *args = pic_alloca(pic, sizeof(pic_value) * n);
|
||||
int i;
|
||||
|
||||
for (i = 0; i < n; ++i) {
|
||||
args[i] = va_arg(ap, pic_value);
|
||||
}
|
||||
return pic_apply(pic, proc, n, args);
|
||||
}
|
||||
|
||||
pic_value
|
||||
pic_apply_list(pic_state *pic, struct pic_proc *proc, pic_value list)
|
||||
{
|
||||
|
@ -959,46 +983,21 @@ pic_set(pic_state *pic, struct pic_lib *lib, const char *name, pic_value val)
|
|||
vm_gset(pic, uid, val);
|
||||
}
|
||||
|
||||
static struct pic_proc *
|
||||
pic_ref_proc(pic_state *pic, struct pic_lib *lib, const char *name)
|
||||
pic_value
|
||||
pic_funcall(pic_state *pic, struct pic_lib *lib, const char *name, int n, ...)
|
||||
{
|
||||
pic_value proc;
|
||||
pic_value proc, r;
|
||||
va_list ap;
|
||||
|
||||
proc = pic_ref(pic, lib, name);
|
||||
|
||||
pic_assert_type(pic, proc, proc);
|
||||
|
||||
return pic_proc_ptr(proc);
|
||||
}
|
||||
va_start(ap, n);
|
||||
r = pic_vcall(pic, pic_proc_ptr(proc), n, ap);
|
||||
va_end(ap);
|
||||
|
||||
pic_value
|
||||
pic_funcall(pic_state *pic, struct pic_lib *lib, const char *name, pic_value args)
|
||||
{
|
||||
return pic_apply_list(pic, pic_ref_proc(pic, lib, name), args);
|
||||
}
|
||||
|
||||
pic_value
|
||||
pic_funcall0(pic_state *pic, struct pic_lib *lib, const char *name)
|
||||
{
|
||||
return pic_apply0(pic, pic_ref_proc(pic, lib, name));
|
||||
}
|
||||
|
||||
pic_value
|
||||
pic_funcall1(pic_state *pic, struct pic_lib *lib, const char *name, pic_value arg0)
|
||||
{
|
||||
return pic_apply1(pic, pic_ref_proc(pic, lib, name), arg0);
|
||||
}
|
||||
|
||||
pic_value
|
||||
pic_funcall2(pic_state *pic, struct pic_lib *lib, const char *name, pic_value arg0, pic_value arg1)
|
||||
{
|
||||
return pic_apply2(pic, pic_ref_proc(pic, lib, name), arg0, arg1);
|
||||
}
|
||||
|
||||
pic_value
|
||||
pic_funcall3(pic_state *pic, struct pic_lib *lib, const char *name, pic_value arg0, pic_value arg1, pic_value arg2)
|
||||
{
|
||||
return pic_apply3(pic, pic_ref_proc(pic, lib, name), arg0, arg1, arg2);
|
||||
return r;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
Loading…
Reference in New Issue