From 8b484b69d7d5243ef02369115b6e50fecbb6a370 Mon Sep 17 00:00:00 2001 From: Yuichi Nishiwaki Date: Mon, 11 Nov 2013 10:14:42 +0900 Subject: [PATCH] rename fields in struct pic_cont --- include/picrin/cont.h | 8 ++++---- src/cont.c | 16 ++++++++-------- src/gc.c | 8 ++++---- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/include/picrin/cont.h b/include/picrin/cont.h index 6fb5dd68..66ba6b91 100644 --- a/include/picrin/cont.h +++ b/include/picrin/cont.h @@ -8,11 +8,11 @@ struct pic_cont { size_t stk_len; pic_value *stk_pos, *stk_ptr; - pic_value *sp; - pic_value *stbase, *stend; + pic_value *sp, *st_ptr; + size_t st_len; - pic_callinfo *ci; - pic_callinfo *cibase, *ciend; + pic_callinfo *ci, *ci_ptr; + size_t ci_len; struct pic_object **arena; int arena_idx; diff --git a/src/cont.c b/src/cont.c index 04a5b25b..ddffdca9 100644 --- a/src/cont.c +++ b/src/cont.c @@ -35,15 +35,15 @@ save_cont(pic_state *pic) cont->stk_ptr = pic_alloc(pic, sizeof(pic_value) * cont->stk_len); memcpy(cont->stk_ptr, cont->stk_pos, sizeof(pic_value) * cont->stk_len); - cont->stbase = (pic_value *)pic_alloc(pic, sizeof(pic_value) * (pic->stend - pic->stbase)); - cont->stend = cont->stbase + (pic->stend - pic->stbase); cont->sp = pic->sp; - memcpy(cont->stbase, pic->stbase, sizeof(pic_value) * (pic->stend - pic->stbase)); + cont->st_len = pic->stend - pic->stbase; + cont->st_ptr = (pic_value *)pic_alloc(pic, sizeof(pic_value) * cont->st_len); + memcpy(cont->st_ptr, pic->stbase, sizeof(pic_value) * cont->st_len); - cont->cibase = (pic_callinfo *)pic_alloc(pic, sizeof(pic_callinfo) * (pic->ciend - pic->cibase)); - cont->ciend = cont->cibase + (pic->ciend - pic->cibase); cont->ci = pic->ci; - memcpy(cont->cibase, pic->cibase, sizeof(pic_callinfo) * (pic->ciend - pic->cibase)); + cont->ci_len = pic->ciend - pic->cibase; + cont->ci_ptr = (pic_callinfo *)pic_alloc(pic, sizeof(pic_callinfo) * cont->ci_len); + memcpy(cont->ci_ptr, pic->cibase, sizeof(pic_callinfo) * cont->ci_len); cont->arena = (struct pic_object **)pic_alloc(pic, sizeof(struct pic_object *) * PIC_ARENA_SIZE); cont->arena_idx = pic->arena_idx; @@ -77,10 +77,10 @@ restore_cont(pic_state *pic, struct pic_cont *cont) } pic->sp = cont->sp; - memcpy(pic->stbase, cont->stbase, sizeof(pic_value) * (cont->stend - cont->stbase)); + memcpy(pic->stbase, cont->st_ptr, sizeof(pic_value) * cont->st_len); pic->ci = cont->ci; - memcpy(pic->cibase, cont->cibase, sizeof(pic_callinfo) * (cont->ciend - cont->cibase)); + memcpy(pic->cibase, cont->ci_ptr, sizeof(pic_callinfo) * cont->ci_len); memcpy(pic->arena, cont->arena, sizeof(struct pic_object *) * PIC_ARENA_SIZE); pic->arena_idx = cont->arena_idx; diff --git a/src/gc.c b/src/gc.c index 56da0721..6a507f32 100644 --- a/src/gc.c +++ b/src/gc.c @@ -199,12 +199,12 @@ gc_mark_object(pic_state *pic, struct pic_object *obj) int i; /* stack */ - for (stack = cont->stbase; stack != cont->sp; ++stack) { + for (stack = cont->st_ptr; stack != cont->sp; ++stack) { gc_mark(pic, *stack); } /* callinfo */ - for (ci = cont->ci; ci != cont->cibase; --ci) { + for (ci = cont->ci; ci != cont->ci_ptr; --ci) { if (ci->env) { gc_mark_object(pic, (struct pic_object *)ci->env); } @@ -334,8 +334,8 @@ gc_finalize_object(pic_state *pic, struct pic_object *obj) case PIC_TT_CONT: { struct pic_cont *cont = (struct pic_cont *)obj; pic_free(pic, cont->stk_ptr); - pic_free(pic, cont->stbase); - pic_free(pic, cont->cibase); + pic_free(pic, cont->st_ptr); + pic_free(pic, cont->ci_ptr); pic_free(pic, cont->arena); break; }