diff --git a/include/picrin.h b/include/picrin.h index e34e7659..01c42da5 100644 --- a/include/picrin.h +++ b/include/picrin.h @@ -170,7 +170,7 @@ pic_value pic_read_cstr(pic_state *, const char *); void pic_load(pic_state *, const char *); void pic_load_cstr(pic_state *, const char *); -pic_value pic_funcall(pic_state *pic, const char *, pic_list); +pic_value pic_funcall(pic_state *pic, struct pic_lib *, const char *, pic_list); pic_value pic_ref(pic_state *, struct pic_lib *, const char *); void pic_set(pic_state *, struct pic_lib *, const char *, pic_value); diff --git a/port.c b/port.c index 11ef26ab..b9679e54 100644 --- a/port.c +++ b/port.c @@ -25,21 +25,21 @@ pic_eof_object() struct pic_port * pic_stdin(pic_state *pic) { - struct pic_proc *proc; + pic_value obj; - proc = pic_proc_ptr(pic_ref(pic, pic->PICRIN_BASE, "current-input-port")); + obj = pic_funcall(pic, pic->PICRIN_BASE, "current-input-port", pic_nil_value()); - return pic_port_ptr(pic_apply(pic, proc, pic_nil_value())); + return pic_port_ptr(obj); } struct pic_port * pic_stdout(pic_state *pic) { - struct pic_proc *proc; + pic_value obj; - proc = pic_proc_ptr(pic_ref(pic, pic->PICRIN_BASE, "current-output-port")); + obj = pic_funcall(pic, pic->PICRIN_BASE, "current-output-port", pic_nil_value()); - return pic_port_ptr(pic_apply(pic, proc, pic_nil_value())); + return pic_port_ptr(obj); } struct pic_port * diff --git a/vm.c b/vm.c index 72ea96d0..b84bc96e 100644 --- a/vm.c +++ b/vm.c @@ -457,11 +457,11 @@ pic_set(pic_state *pic, struct pic_lib *lib, const char *name, pic_value val) } pic_value -pic_funcall(pic_state *pic, const char *name, pic_list args) +pic_funcall(pic_state *pic, struct pic_lib *lib, const char *name, pic_list args) { pic_value proc; - proc = pic_ref(pic, pic->lib, name); + proc = pic_ref(pic, lib, name); pic_assert_type(pic, proc, proc);