From da27d2ff759be4e0d6849b330a9da3bdd14207e2 Mon Sep 17 00:00:00 2001 From: Yuichi Nishiwaki Date: Sun, 7 May 2017 02:41:21 +0900 Subject: [PATCH] cleanup --- lib/ext/read.c | 4 ++-- lib/object.h | 1 - lib/pair.c | 6 +++--- lib/proc.c | 11 ----------- lib/state.c | 2 +- 5 files changed, 6 insertions(+), 18 deletions(-) diff --git a/lib/ext/read.c b/lib/ext/read.c index 507394f6..747e3349 100644 --- a/lib/ext/read.c +++ b/lib/ext/read.c @@ -547,8 +547,8 @@ read_label_set(pic_state *pic, pic_value port, int i, struct reader_control *p) kh_val(h, it) = val = pic_cons(pic, pic_undef_value(pic), pic_undef_value(pic)); tmp = read_core(pic, port, c, p); - pair_ptr(pic, val)->car = pic_car(pic, tmp); - pair_ptr(pic, val)->cdr = pic_cdr(pic, tmp); + pic_set_car(pic, val, pic_car(pic, tmp)); + pic_set_cdr(pic, val, pic_cdr(pic, tmp)); return val; } diff --git a/lib/object.h b/lib/object.h index a800c3dc..e3228a49 100644 --- a/lib/object.h +++ b/lib/object.h @@ -219,7 +219,6 @@ struct object *pic_obj_alloc_unsafe(pic_state *, int type); struct frame *pic_make_frame_unsafe(pic_state *, int n); pic_value pic_make_proc_irep_unsafe(pic_state *, struct irep *, struct frame *); -pic_value pic_make_proc_func(pic_state *, pic_func_t); pic_value pic_make_record(pic_state *, pic_value type, pic_value datum); pic_value pic_record_type(pic_state *pic, pic_value record); pic_value pic_record_datum(pic_state *pic, pic_value record); diff --git a/lib/pair.c b/lib/pair.c index acaa2f09..b038c9d5 100644 --- a/lib/pair.c +++ b/lib/pair.c @@ -92,7 +92,7 @@ pic_list_p(pic_state *pic, pic_value obj) /* advance rapid fast-forward; runs 2x faster than local */ for (i = 0; i < 2; ++i) { if (pic_pair_p(pic, rapid)) { - rapid = pair_ptr(pic, rapid)->cdr; + rapid = pic_cdr(pic, rapid); } else { return pic_nil_p(pic, rapid); @@ -100,7 +100,7 @@ pic_list_p(pic_state *pic, pic_value obj) } /* advance local */ - local = pair_ptr(pic, local)->cdr; + local = pic_cdr(pic, local); if (pic_eq_p(pic, local, rapid)) { return false; @@ -154,7 +154,7 @@ pic_list_ref(pic_state *pic, pic_value list, int i) void pic_list_set(pic_state *pic, pic_value list, int i, pic_value obj) { - pair_ptr(pic, pic_list_tail(pic, list, i))->car = obj; + pic_set_car(pic, pic_list_tail(pic, list, i), obj); } pic_value diff --git a/lib/proc.c b/lib/proc.c index b08694cf..3cce822c 100644 --- a/lib/proc.c +++ b/lib/proc.c @@ -207,17 +207,6 @@ pic_vlambda(pic_state *pic, pic_func_t f, int n, va_list ap) return obj_value(pic, proc); } -pic_value -pic_make_proc_func(pic_state *pic, pic_func_t func) -{ - struct proc *proc; - - proc = (struct proc *)pic_obj_alloc(pic, PIC_TYPE_PROC_FUNC); - proc->u.func = func; - proc->env = NULL; - return obj_value(pic, proc); -} - pic_value pic_make_proc_irep_unsafe(pic_state *pic, struct irep *irep, struct frame *fp) { diff --git a/lib/state.c b/lib/state.c index bfdcf009..0095146e 100644 --- a/lib/state.c +++ b/lib/state.c @@ -360,7 +360,7 @@ pic_define(pic_state *pic, const char *name, pic_value val) void pic_defun(pic_state *pic, const char *name, pic_func_t f) { - pic_define(pic, name, pic_make_proc_func(pic, f)); + pic_define(pic, name, pic_lambda(pic, f, 0)); } void