diff --git a/contrib/10.callcc/callcc.c b/contrib/10.callcc/callcc.c index b1c57627..8664354c 100644 --- a/contrib/10.callcc/callcc.c +++ b/contrib/10.callcc/callcc.c @@ -2,12 +2,12 @@ #include "picrin/private/object.h" #include "picrin/private/state.h" -struct pic_fullcont { +struct fullcont { jmp_buf jmp; struct pic_cont *prev_jmp; - struct pic_checkpoint *cp; + struct checkpoint *cp; char *stk_pos, *stk_ptr; ptrdiff_t stk_len; @@ -16,19 +16,19 @@ struct pic_fullcont { size_t sp_offset; ptrdiff_t st_len; - struct pic_callinfo *ci_ptr; + struct callinfo *ci_ptr; size_t ci_offset; ptrdiff_t ci_len; - struct pic_proc **xp_ptr; + struct proc **xp_ptr; size_t xp_offset; ptrdiff_t xp_len; - struct pic_code *ip; + struct code *ip; pic_value ptable; - struct pic_object **arena; + struct object **arena; size_t arena_size, arena_idx; int retc; @@ -38,7 +38,7 @@ struct pic_fullcont { static void cont_dtor(pic_state *pic, void *data) { - struct pic_fullcont *cont = data; + struct fullcont *cont = data; pic_free(pic, cont->stk_ptr); pic_free(pic, cont->st_ptr); @@ -51,11 +51,11 @@ cont_dtor(pic_state *pic, void *data) static void cont_mark(pic_state *pic, void *data, void (*mark)(pic_state *, pic_value)) { - struct pic_fullcont *cont = data; - struct pic_checkpoint *cp; + struct fullcont *cont = data; + struct checkpoint *cp; pic_value *stack; - struct pic_callinfo *ci; - struct pic_proc **xp; + struct callinfo *ci; + struct proc **xp; size_t i; /* checkpoint */ @@ -96,8 +96,8 @@ cont_mark(pic_state *pic, void *data, void (*mark)(pic_state *, pic_value)) static const pic_data_type cont_type = { "continuation", cont_dtor, cont_mark }; -static void save_cont(pic_state *, struct pic_fullcont **); -static void restore_cont(pic_state *, struct pic_fullcont *); +static void save_cont(pic_state *, struct fullcont **); +static void restore_cont(pic_state *, struct fullcont *); static ptrdiff_t native_stack_length(pic_state *pic, char **pos) @@ -114,15 +114,15 @@ native_stack_length(pic_state *pic, char **pos) } static void -save_cont(pic_state *pic, struct pic_fullcont **c) +save_cont(pic_state *pic, struct fullcont **c) { void pic_vm_tear_off(pic_state *); - struct pic_fullcont *cont; + struct fullcont *cont; char *pos; pic_vm_tear_off(pic); /* tear off */ - cont = *c = pic_malloc(pic, sizeof(struct pic_fullcont)); + cont = *c = pic_malloc(pic, sizeof(struct fullcont)); cont->prev_jmp = pic->cc; @@ -141,13 +141,13 @@ save_cont(pic_state *pic, struct pic_fullcont **c) cont->ci_offset = pic->ci - pic->cibase; cont->ci_len = pic->ciend - pic->cibase; - cont->ci_ptr = pic_malloc(pic, sizeof(struct pic_callinfo) * cont->ci_len); - memcpy(cont->ci_ptr, pic->cibase, sizeof(struct pic_callinfo) * cont->ci_len); + cont->ci_ptr = pic_malloc(pic, sizeof(struct callinfo) * cont->ci_len); + memcpy(cont->ci_ptr, pic->cibase, sizeof(struct callinfo) * cont->ci_len); cont->xp_offset = pic->xp - pic->xpbase; cont->xp_len = pic->xpend - pic->xpbase; - cont->xp_ptr = pic_malloc(pic, sizeof(struct pic_proc *) * cont->xp_len); - memcpy(cont->xp_ptr, pic->xpbase, sizeof(struct pic_proc *) * cont->xp_len); + cont->xp_ptr = pic_malloc(pic, sizeof(struct proc *) * cont->xp_len); + memcpy(cont->xp_ptr, pic->xpbase, sizeof(struct proc *) * cont->xp_len); cont->ip = pic->ip; @@ -155,15 +155,15 @@ save_cont(pic_state *pic, struct pic_fullcont **c) cont->arena_idx = pic->arena_idx; cont->arena_size = pic->arena_size; - cont->arena = pic_malloc(pic, sizeof(struct pic_object *) * pic->arena_size); - memcpy(cont->arena, pic->arena, sizeof(struct pic_object *) * pic->arena_size); + cont->arena = pic_malloc(pic, sizeof(struct object *) * pic->arena_size); + memcpy(cont->arena, pic->arena, sizeof(struct object *) * pic->arena_size); cont->retc = 0; cont->retv = NULL; } static void -native_stack_extend(pic_state *pic, struct pic_fullcont *cont) +native_stack_extend(pic_state *pic, struct fullcont *cont) { volatile pic_value v[1024]; @@ -172,10 +172,10 @@ native_stack_extend(pic_state *pic, struct pic_fullcont *cont) } PIC_NORETURN static void -restore_cont(pic_state *pic, struct pic_fullcont *cont) +restore_cont(pic_state *pic, struct fullcont *cont) { char v; - struct pic_fullcont *tmp = cont; + struct fullcont *tmp = cont; if (&v < pic->native_stack_start) { if (&v > cont->stk_pos) native_stack_extend(pic, cont); @@ -193,12 +193,12 @@ restore_cont(pic_state *pic, struct pic_fullcont *cont) pic->stend = pic->stbase + cont->st_len; assert(pic->ciend - pic->cibase >= cont->ci_len); - memcpy(pic->cibase, cont->ci_ptr, sizeof(struct pic_callinfo) * cont->ci_len); + memcpy(pic->cibase, cont->ci_ptr, sizeof(struct callinfo) * cont->ci_len); pic->ci = pic->cibase + cont->ci_offset; pic->ciend = pic->cibase + cont->ci_len; assert(pic->xpend - pic->xpbase >= cont->xp_len); - memcpy(pic->xpbase, cont->xp_ptr, sizeof(struct pic_proc *) * cont->xp_len); + memcpy(pic->xpbase, cont->xp_ptr, sizeof(struct proc *) * cont->xp_len); pic->xp = pic->xpbase + cont->xp_offset; pic->xpend = pic->xpbase + cont->xp_len; @@ -207,7 +207,7 @@ restore_cont(pic_state *pic, struct pic_fullcont *cont) pic->ptable = cont->ptable; assert(pic->arena_size >= cont->arena_size); - memcpy(pic->arena, cont->arena, sizeof(struct pic_object *) * cont->arena_size); + memcpy(pic->arena, cont->arena, sizeof(struct object *) * cont->arena_size); pic->arena_size = cont->arena_size; pic->arena_idx = cont->arena_idx; @@ -221,7 +221,7 @@ cont_call(pic_state *pic) { int argc, i; pic_value *argv, *retv; - struct pic_fullcont *cont; + struct fullcont *cont; pic_get_args(pic, "*", &argc, &argv); @@ -243,7 +243,7 @@ cont_call(pic_state *pic) static pic_value pic_callcc(pic_state *pic, pic_value proc) { - struct pic_fullcont *cont; + struct fullcont *cont; save_cont(pic, &cont); if (setjmp(cont->jmp)) { diff --git a/extlib/benz/blob.c b/extlib/benz/blob.c index 292ea083..3747d66e 100644 --- a/extlib/benz/blob.c +++ b/extlib/benz/blob.c @@ -9,9 +9,9 @@ pic_value pic_blob_value(pic_state *pic, const unsigned char *buf, int len) { - struct pic_blob *bv; + struct blob *bv; - bv = (struct pic_blob *)pic_obj_alloc(pic, sizeof(struct pic_blob), PIC_TYPE_BLOB); + bv = (struct blob *)pic_obj_alloc(pic, sizeof(struct blob), PIC_TYPE_BLOB); bv->data = pic_malloc(pic, len); bv->len = len; if (buf) { diff --git a/extlib/benz/bool.c b/extlib/benz/bool.c index 09ea02a2..9de94abc 100644 --- a/extlib/benz/bool.c +++ b/extlib/benz/bool.c @@ -94,7 +94,7 @@ internal_equal_p(pic_state *pic, pic_value x, pic_value y, int depth, khash_t(m) switch (pic_type(pic, x)) { case PIC_TYPE_ID: { - identifier *id1, *id2; + struct identifier *id1, *id2; pic_value s1, s2; id1 = pic_id_ptr(pic, x); diff --git a/extlib/benz/cont.c b/extlib/benz/cont.c index 4e6545f9..0149e00f 100644 --- a/extlib/benz/cont.c +++ b/extlib/benz/cont.c @@ -11,13 +11,13 @@ struct pic_cont { int id; - struct pic_checkpoint *cp; + struct checkpoint *cp; ptrdiff_t sp_offset; ptrdiff_t ci_offset; ptrdiff_t xp_offset; size_t arena_idx; pic_value ptable; - struct pic_code *ip; + struct code *ip; int retc; pic_value *retv; @@ -71,7 +71,7 @@ pic_exit_point(pic_state *pic) } void -pic_wind(pic_state *pic, struct pic_checkpoint *here, struct pic_checkpoint *there) +pic_wind(pic_state *pic, struct checkpoint *here, struct checkpoint *there) { if (here == there) return; @@ -89,13 +89,13 @@ pic_wind(pic_state *pic, struct pic_checkpoint *here, struct pic_checkpoint *the static pic_value pic_dynamic_wind(pic_state *pic, pic_value in, pic_value thunk, pic_value out) { - struct pic_checkpoint *here; + struct checkpoint *here; pic_value val; pic_call(pic, in, 0); /* enter */ here = pic->cp; - pic->cp = (struct pic_checkpoint *)pic_obj_alloc(pic, sizeof(struct pic_checkpoint), PIC_TYPE_CP); + pic->cp = (struct checkpoint *)pic_obj_alloc(pic, sizeof(struct checkpoint), PIC_TYPE_CP); pic->cp->prev = here; pic->cp->depth = here->depth + 1; pic->cp->in = pic_proc_ptr(pic, in); @@ -218,7 +218,7 @@ pic_valuesk(pic_state *pic, int argc, pic_value *argv) int pic_receive(pic_state *pic, int n, pic_value *argv) { - struct pic_callinfo *ci; + struct callinfo *ci; int i, retc; /* take info from discarded frame */ diff --git a/extlib/benz/data.c b/extlib/benz/data.c index 4ba3cb71..300bb162 100644 --- a/extlib/benz/data.c +++ b/extlib/benz/data.c @@ -19,9 +19,9 @@ pic_data(pic_state *PIC_UNUSED(pic), pic_value data) pic_value pic_data_value(pic_state *pic, void *userdata, const pic_data_type *type) { - struct pic_data *data; + struct data *data; - data = (struct pic_data *)pic_obj_alloc(pic, sizeof(struct pic_data), PIC_TYPE_DATA); + data = (struct data *)pic_obj_alloc(pic, sizeof(struct data), PIC_TYPE_DATA); data->type = type; data->data = userdata; diff --git a/extlib/benz/debug.c b/extlib/benz/debug.c index 80fd6d95..189f95dc 100644 --- a/extlib/benz/debug.c +++ b/extlib/benz/debug.c @@ -11,7 +11,7 @@ pic_value pic_get_backtrace(pic_state *pic) { size_t ai = pic_enter(pic); - struct pic_callinfo *ci; + struct callinfo *ci; pic_value trace; trace = pic_lit_value(pic, ""); @@ -46,7 +46,7 @@ pic_print_backtrace(pic_state *pic, xFILE *file) xfprintf(pic, file, "raise: "); pic_fwrite(pic, err, file); } else { - struct pic_error *e; + struct error *e; pic_value elem, it; e = pic_error_ptr(pic, err); diff --git a/extlib/benz/dict.c b/extlib/benz/dict.c index a4b209c4..47a92fd6 100644 --- a/extlib/benz/dict.c +++ b/extlib/benz/dict.c @@ -11,9 +11,9 @@ KHASH_DEFINE(dict, symbol *, pic_value, kh_ptr_hash_func, kh_ptr_hash_equal) pic_value pic_make_dict(pic_state *pic) { - struct pic_dict *dict; + struct dict *dict; - dict = (struct pic_dict *)pic_obj_alloc(pic, sizeof(struct pic_dict), PIC_TYPE_DICT); + dict = (struct dict *)pic_obj_alloc(pic, sizeof(struct dict), PIC_TYPE_DICT); kh_init(dict, &dict->hash); return pic_obj_value(dict); } diff --git a/extlib/benz/error.c b/extlib/benz/error.c index 24acabfb..56a0c39b 100644 --- a/extlib/benz/error.c +++ b/extlib/benz/error.c @@ -83,7 +83,7 @@ pic_push_handler(pic_state *pic, pic_value handler) if (pic->xp >= pic->xpend) { xp_len = (size_t)(pic->xpend - pic->xpbase) * 2; xp_offset = pic->xp - pic->xpbase; - pic->xpbase = pic_realloc(pic, pic->xpbase, sizeof(struct pic_proc *) * xp_len); + pic->xpbase = pic_realloc(pic, pic->xpbase, sizeof(struct proc *) * xp_len); pic->xp = pic->xpbase + xp_offset; pic->xpend = pic->xpbase + xp_len; } @@ -110,12 +110,12 @@ pic_err(pic_state *pic) pic_value pic_make_error(pic_state *pic, const char *type, const char *msg, pic_value irrs) { - struct pic_error *e; + struct error *e; pic_value stack, ty = pic_intern_cstr(pic, type); stack = pic_get_backtrace(pic); - e = (struct pic_error *)pic_obj_alloc(pic, sizeof(struct pic_error), PIC_TYPE_ERROR); + e = (struct error *)pic_obj_alloc(pic, sizeof(struct error), PIC_TYPE_ERROR); e->type = pic_sym_ptr(pic, ty); e->msg = pic_str_ptr(pic, pic_cstr_value(pic, msg)); e->irrs = irrs; diff --git a/extlib/benz/eval.c b/extlib/benz/eval.c index 279d29aa..1717ae36 100644 --- a/extlib/benz/eval.c +++ b/extlib/benz/eval.c @@ -354,17 +354,17 @@ typedef struct codegen_context { pic_value rest; pic_value args, locals, captures; /* actual bit code sequence */ - struct pic_code *code; + struct code *code; size_t clen, ccapa; /* child ireps */ - struct pic_irep **irep; + struct irep **irep; size_t ilen, icapa; /* constant object pool */ int *ints; size_t klen, kcapa; double *nums; size_t flen, fcapa; - struct pic_object **pool; + struct object **pool; size_t plen, pcapa; struct codegen_context *up; @@ -382,15 +382,15 @@ codegen_context_init(pic_state *pic, codegen_context *cxt, codegen_context *up, cxt->locals = locals; cxt->captures = captures; - cxt->code = pic_calloc(pic, PIC_ISEQ_SIZE, sizeof(struct pic_code)); + cxt->code = pic_calloc(pic, PIC_ISEQ_SIZE, sizeof(struct code)); cxt->clen = 0; cxt->ccapa = PIC_ISEQ_SIZE; - cxt->irep = pic_calloc(pic, PIC_IREP_SIZE, sizeof(struct pic_irep *)); + cxt->irep = pic_calloc(pic, PIC_IREP_SIZE, sizeof(struct irep *)); cxt->ilen = 0; cxt->icapa = PIC_IREP_SIZE; - cxt->pool = pic_calloc(pic, PIC_POOL_SIZE, sizeof(struct pic_object *)); + cxt->pool = pic_calloc(pic, PIC_POOL_SIZE, sizeof(struct object *)); cxt->plen = 0; cxt->pcapa = PIC_POOL_SIZE; @@ -405,23 +405,23 @@ codegen_context_init(pic_state *pic, codegen_context *cxt, codegen_context *up, create_activation(pic, cxt); } -static struct pic_irep * +static struct irep * codegen_context_destroy(pic_state *pic, codegen_context *cxt) { - struct pic_irep *irep; + struct irep *irep; /* create irep */ - irep = pic_malloc(pic, sizeof(struct pic_irep)); + irep = pic_malloc(pic, sizeof(struct irep)); irep->refc = 1; irep->varg = pic_sym_p(pic, cxt->rest); irep->argc = pic_vec_len(pic, cxt->args) + 1; irep->localc = pic_vec_len(pic, cxt->locals); irep->capturec = pic_vec_len(pic, cxt->captures); - irep->code = pic_realloc(pic, cxt->code, sizeof(struct pic_code) * cxt->clen); - irep->irep = pic_realloc(pic, cxt->irep, sizeof(struct pic_irep *) * cxt->ilen); + irep->code = pic_realloc(pic, cxt->code, sizeof(struct code) * cxt->clen); + irep->irep = pic_realloc(pic, cxt->irep, sizeof(struct irep *) * cxt->ilen); irep->ints = pic_realloc(pic, cxt->ints, sizeof(int) * cxt->klen); irep->nums = pic_realloc(pic, cxt->nums, sizeof(double) * cxt->flen); - irep->pool = pic_realloc(pic, cxt->pool, sizeof(struct pic_object *) * cxt->plen); + irep->pool = pic_realloc(pic, cxt->pool, sizeof(struct object *) * cxt->plen); irep->ncode = cxt->clen; irep->nirep = cxt->ilen; irep->nints = cxt->klen; @@ -443,9 +443,9 @@ codegen_context_destroy(pic_state *pic, codegen_context *cxt) } \ } while (0) -#define check_code_size(pic, cxt) check_size(pic, cxt, c, code, struct pic_code) -#define check_irep_size(pic, cxt) check_size(pic, cxt, i, irep, struct pic_irep *) -#define check_pool_size(pic, cxt) check_size(pic, cxt, p, pool, struct pic_object *) +#define check_code_size(pic, cxt) check_size(pic, cxt, c, code, struct code) +#define check_irep_size(pic, cxt) check_size(pic, cxt, i, irep, struct irep *) +#define check_pool_size(pic, cxt) check_size(pic, cxt, p, pool, struct object *) #define check_ints_size(pic, cxt) check_size(pic, cxt, k, ints, int) #define check_nums_size(pic, cxt) check_size(pic, cxt, f, nums, double) @@ -513,7 +513,7 @@ index_global(pic_state *pic, codegen_context *cxt, pic_value name) check_pool_size(pic, cxt); pidx = (int)cxt->plen++; - cxt->pool[pidx] = (struct pic_object *)pic_sym_ptr(pic, name); + cxt->pool[pidx] = (struct object *)pic_sym_ptr(pic, name); return pidx; } @@ -804,7 +804,7 @@ codegen(pic_state *pic, codegen_context *cxt, pic_value obj, bool tailpos) } } -static struct pic_irep * +static struct irep * pic_codegen(pic_state *pic, pic_value obj) { pic_value empty = pic_make_vec(pic, 0, NULL); @@ -822,7 +822,7 @@ pic_codegen(pic_state *pic, pic_value obj) pic_value pic_compile(pic_state *pic, pic_value obj) { - struct pic_irep *irep; + struct irep *irep; pic_value proc; size_t ai = pic_enter(pic); diff --git a/extlib/benz/gc.c b/extlib/benz/gc.c index b5030ae0..00a34de5 100644 --- a/extlib/benz/gc.c +++ b/extlib/benz/gc.c @@ -23,39 +23,39 @@ struct heap_page { struct heap_page *next; }; -struct pic_object { +struct object { union { - struct pic_basic basic; - struct pic_identifier id; - struct pic_string str; - struct pic_blob blob; - struct pic_pair pair; - struct pic_vector vec; - struct pic_dict dict; - struct pic_weak weak; - struct pic_data data; - struct pic_record rec; - struct pic_env env; - struct pic_proc proc; - struct pic_context cxt; - struct pic_port port; - struct pic_error err; - struct pic_checkpoint cp; + struct basic basic; + struct identifier id; + struct string str; + struct blob blob; + struct pair pair; + struct vector vec; + struct dict dict; + struct weak weak; + struct data data; + struct record rec; + struct env env; + struct proc proc; + struct context cxt; + struct port port; + struct error err; + struct checkpoint cp; } u; }; -struct pic_heap { +struct heap { union header base, *freep; struct heap_page *pages; - struct pic_weak *weaks; /* weak map chain */ + struct weak *weaks; /* weak map chain */ }; -struct pic_heap * +struct heap * pic_heap_open(pic_state *pic) { - struct pic_heap *heap; + struct heap *heap; - heap = pic_malloc(pic, sizeof(struct pic_heap)); + heap = pic_malloc(pic, sizeof(struct heap)); heap->base.s.ptr = &heap->base; heap->base.s.size = 0; /* not 1, since it must never be used for allocation */ @@ -69,7 +69,7 @@ pic_heap_open(pic_state *pic) } void -pic_heap_close(pic_state *pic, struct pic_heap *heap) +pic_heap_close(pic_state *pic, struct heap *heap) { struct heap_page *page; @@ -137,11 +137,11 @@ pic_free(pic_state *pic, void *ptr) } static void -gc_protect(pic_state *pic, struct pic_object *obj) +gc_protect(pic_state *pic, struct object *obj) { if (pic->arena_idx >= pic->arena_size) { pic->arena_size = pic->arena_size * 2 + 1; - pic->arena = pic_realloc(pic, pic->arena, sizeof(struct pic_object *) * pic->arena_size); + pic->arena = pic_realloc(pic, pic->arena, sizeof(struct object *) * pic->arena_size); } pic->arena[pic->arena_idx++] = obj; } @@ -259,7 +259,7 @@ heap_morecore(pic_state *pic) /* MARK */ -static void gc_mark_object(pic_state *, struct pic_object *); +static void gc_mark_object(pic_state *, struct object *); static void gc_mark(pic_state *pic, pic_value v) @@ -271,7 +271,7 @@ gc_mark(pic_state *pic, pic_value v) } static void -gc_mark_object(pic_state *pic, struct pic_object *obj) +gc_mark_object(pic_state *pic, struct object *obj) { loop: @@ -280,7 +280,7 @@ gc_mark_object(pic_state *pic, struct pic_object *obj) obj->u.basic.gc_mark = BLACK; -#define LOOP(o) obj = (struct pic_object *)(o); goto loop +#define LOOP(o) obj = (struct object *)(o); goto loop switch (obj->u.basic.tt) { case PIC_TYPE_PAIR: { @@ -318,8 +318,8 @@ gc_mark_object(pic_state *pic, struct pic_object *obj) break; } case PIC_TYPE_ERROR: { - gc_mark_object(pic, (struct pic_object *)obj->u.err.type); - gc_mark_object(pic, (struct pic_object *)obj->u.err.msg); + gc_mark_object(pic, (struct object *)obj->u.err.type); + gc_mark_object(pic, (struct object *)obj->u.err.msg); gc_mark(pic, obj->u.err.irrs); LOOP(obj->u.err.stack); break; @@ -338,7 +338,7 @@ gc_mark_object(pic_state *pic, struct pic_object *obj) break; } case PIC_TYPE_ID: { - gc_mark_object(pic, (struct pic_object *)obj->u.id.u.id); + gc_mark_object(pic, (struct object *)obj->u.id.u.id); LOOP(obj->u.id.env); break; } @@ -348,8 +348,8 @@ gc_mark_object(pic_state *pic, struct pic_object *obj) for (it = kh_begin(h); it != kh_end(h); ++it) { if (kh_exist(h, it)) { - gc_mark_object(pic, (struct pic_object *)kh_key(h, it)); - gc_mark_object(pic, (struct pic_object *)kh_val(h, it)); + gc_mark_object(pic, (struct object *)kh_key(h, it)); + gc_mark_object(pic, (struct object *)kh_val(h, it)); } } if (obj->u.env.up) { @@ -385,7 +385,7 @@ gc_mark_object(pic_state *pic, struct pic_object *obj) break; } case PIC_TYPE_WEAK: { - struct pic_weak *weak = (struct pic_weak *)obj; + struct weak *weak = (struct weak *)obj; weak->prev = pic->heap->weaks; pic->heap->weaks = weak; @@ -393,13 +393,13 @@ gc_mark_object(pic_state *pic, struct pic_object *obj) } case PIC_TYPE_CP: { if (obj->u.cp.prev) { - gc_mark_object(pic, (struct pic_object *)obj->u.cp.prev); + gc_mark_object(pic, (struct object *)obj->u.cp.prev); } if (obj->u.cp.in) { - gc_mark_object(pic, (struct pic_object *)obj->u.cp.in); + gc_mark_object(pic, (struct object *)obj->u.cp.in); } if (obj->u.cp.out) { - LOOP((struct pic_object *)obj->u.cp.out); + LOOP((struct object *)obj->u.cp.out); } break; } @@ -412,9 +412,9 @@ static void gc_mark_phase(pic_state *pic) { pic_value *stack; - struct pic_callinfo *ci; - struct pic_proc **xhandler; - struct pic_list_head *list; + struct callinfo *ci; + struct proc **xhandler; + struct list_head *list; int it; size_t j; @@ -422,7 +422,7 @@ gc_mark_phase(pic_state *pic) /* checkpoint */ if (pic->cp) { - gc_mark_object(pic, (struct pic_object *)pic->cp); + gc_mark_object(pic, (struct object *)pic->cp); } /* stack */ @@ -433,23 +433,23 @@ gc_mark_phase(pic_state *pic) /* callinfo */ for (ci = pic->ci; ci != pic->cibase; --ci) { if (ci->cxt) { - gc_mark_object(pic, (struct pic_object *)ci->cxt); + gc_mark_object(pic, (struct object *)ci->cxt); } } /* exception handlers */ for (xhandler = pic->xpbase; xhandler != pic->xp; ++xhandler) { - gc_mark_object(pic, (struct pic_object *)*xhandler); + gc_mark_object(pic, (struct object *)*xhandler); } /* arena */ for (j = 0; j < pic->arena_idx; ++j) { - gc_mark_object(pic, (struct pic_object *)pic->arena[j]); + gc_mark_object(pic, (struct object *)pic->arena[j]); } /* ireps */ for (list = pic->ireps.next; list != &pic->ireps; list = list->next) { - struct pic_irep *irep = (struct pic_irep *)list; + struct irep *irep = (struct irep *)list; for (j = 0; j < irep->npool; ++j) { gc_mark_object(pic, irep->pool[j]); } @@ -475,18 +475,18 @@ gc_mark_phase(pic_state *pic) if (! kh_exist(&pic->ltable, it)) { continue; } - gc_mark_object(pic, (struct pic_object *)kh_val(&pic->ltable, it).name); - gc_mark_object(pic, (struct pic_object *)kh_val(&pic->ltable, it).env); - gc_mark_object(pic, (struct pic_object *)kh_val(&pic->ltable, it).exports); + gc_mark_object(pic, (struct object *)kh_val(&pic->ltable, it).name); + gc_mark_object(pic, (struct object *)kh_val(&pic->ltable, it).env); + gc_mark_object(pic, (struct object *)kh_val(&pic->ltable, it).exports); } /* weak maps */ do { - struct pic_object *key; + struct object *key; pic_value val; int it; khash_t(weak) *h; - struct pic_weak *weak; + struct weak *weak; j = 0; weak = pic->heap->weaks; @@ -513,7 +513,7 @@ gc_mark_phase(pic_state *pic) /* SWEEP */ static void -gc_finalize_object(pic_state *pic, struct pic_object *obj) +gc_finalize_object(pic_state *pic, struct object *obj) { switch (obj->u.basic.tt) { case PIC_TYPE_VECTOR: { @@ -575,7 +575,7 @@ static size_t gc_sweep_page(pic_state *pic, struct heap_page *page) { union header *bp, *p, *head = NULL, *tail = NULL; - struct pic_object *obj; + struct object *obj; size_t alive = 0; for (bp = page->basep; ; bp = bp->s.ptr) { @@ -584,7 +584,7 @@ gc_sweep_page(pic_state *pic, struct heap_page *page) if (p < page->basep || page->endp <= p) { goto escape; } - obj = (struct pic_object *)(p + 1); + obj = (struct object *)(p + 1); if (obj->u.basic.gc_mark == BLACK) { obj->u.basic.gc_mark = WHITE; alive += p->s.size; @@ -606,7 +606,7 @@ gc_sweep_page(pic_state *pic, struct heap_page *page) while (head != NULL) { p = head; head = head->s.ptr; - gc_finalize_object(pic, (struct pic_object *)(p + 1)); + gc_finalize_object(pic, (struct object *)(p + 1)); heap_free(pic, p + 1); } @@ -621,7 +621,7 @@ gc_sweep_phase(pic_state *pic) khash_t(weak) *h; khash_t(oblist) *s = &pic->oblist; symbol *sym; - struct pic_object *obj; + struct object *obj; size_t total = 0, inuse = 0; /* weak maps */ @@ -680,22 +680,22 @@ pic_alloca(pic_state *pic, size_t n) return pic_data(pic, pic_data_value(pic, pic_malloc(pic, n), &t)); } -struct pic_object * +struct object * pic_obj_alloc_unsafe(pic_state *pic, size_t size, int type) { - struct pic_object *obj; + struct object *obj; #if GC_STRESS pic_gc(pic); #endif - obj = (struct pic_object *)heap_alloc(pic, size); + obj = (struct object *)heap_alloc(pic, size); if (obj == NULL) { pic_gc(pic); - obj = (struct pic_object *)heap_alloc(pic, size); + obj = (struct object *)heap_alloc(pic, size); if (obj == NULL) { heap_morecore(pic); - obj = (struct pic_object *)heap_alloc(pic, size); + obj = (struct object *)heap_alloc(pic, size); if (obj == NULL) pic_panic(pic, "GC memory exhausted"); } @@ -706,10 +706,10 @@ pic_obj_alloc_unsafe(pic_state *pic, size_t size, int type) return obj; } -struct pic_object * +struct object * pic_obj_alloc(pic_state *pic, size_t size, int type) { - struct pic_object *obj; + struct object *obj; obj = pic_obj_alloc_unsafe(pic, size, type); diff --git a/extlib/benz/include/picrin/private/gc.h b/extlib/benz/include/picrin/private/gc.h index 4e97e4d0..183cc6f8 100644 --- a/extlib/benz/include/picrin/private/gc.h +++ b/extlib/benz/include/picrin/private/gc.h @@ -9,8 +9,8 @@ extern "C" { #endif -struct pic_heap *pic_heap_open(pic_state *); -void pic_heap_close(pic_state *, struct pic_heap *); +struct heap *pic_heap_open(pic_state *); +void pic_heap_close(pic_state *, struct heap *); #if defined(__cplusplus) } diff --git a/extlib/benz/include/picrin/private/object.h b/extlib/benz/include/picrin/private/object.h index e6e2035c..39751196 100644 --- a/extlib/benz/include/picrin/private/object.h +++ b/extlib/benz/include/picrin/private/object.h @@ -11,88 +11,87 @@ extern "C" { #include "picrin/private/khash.h" -typedef struct pic_identifier identifier; -typedef identifier symbol; +typedef struct identifier symbol; -KHASH_DECLARE(env, identifier *, symbol *) +KHASH_DECLARE(env, struct identifier *, symbol *) KHASH_DECLARE(dict, symbol *, pic_value) -KHASH_DECLARE(weak, struct pic_object *, pic_value) +KHASH_DECLARE(weak, struct object *, pic_value) #define PIC_OBJECT_HEADER \ unsigned char tt; \ char gc_mark; -struct pic_object; /* defined in gc.c */ +struct object; /* defined in gc.c */ -struct pic_basic { +struct basic { PIC_OBJECT_HEADER }; -struct pic_identifier { +struct identifier { PIC_OBJECT_HEADER union { - struct pic_string *str; - struct pic_identifier *id; + struct string *str; + struct identifier *id; } u; - struct pic_env *env; + struct env *env; }; -struct pic_env { +struct env { PIC_OBJECT_HEADER khash_t(env) map; - struct pic_env *up; - struct pic_string *lib; + struct env *up; + struct string *lib; }; -struct pic_pair { +struct pair { PIC_OBJECT_HEADER pic_value car; pic_value cdr; }; -struct pic_blob { +struct blob { PIC_OBJECT_HEADER unsigned char *data; int len; }; -struct pic_string { +struct string { PIC_OBJECT_HEADER - struct pic_rope *rope; + struct rope *rope; }; -struct pic_dict { +struct dict { PIC_OBJECT_HEADER khash_t(dict) hash; }; -struct pic_weak { +struct weak { PIC_OBJECT_HEADER khash_t(weak) hash; - struct pic_weak *prev; /* for GC */ + struct weak *prev; /* for GC */ }; -struct pic_vector { +struct vector { PIC_OBJECT_HEADER pic_value *data; int len; }; -struct pic_data { +struct data { PIC_OBJECT_HEADER const pic_data_type *type; void *data; }; -struct pic_context { +struct context { PIC_OBJECT_HEADER pic_value *regs; int regc; - struct pic_context *up; + struct context *up; pic_value storage[1]; }; -struct pic_proc { +struct proc { PIC_OBJECT_HEADER enum { PIC_PROC_TAG_IREP, @@ -104,56 +103,56 @@ struct pic_proc { int localc; } f; struct { - struct pic_irep *irep; - struct pic_context *cxt; + struct irep *irep; + struct context *cxt; } i; } u; pic_value locals[1]; }; -struct pic_record { +struct record { PIC_OBJECT_HEADER pic_value type; pic_value datum; }; -struct pic_error { +struct error { PIC_OBJECT_HEADER symbol *type; - struct pic_string *msg; + struct string *msg; pic_value irrs; - struct pic_string *stack; + struct string *stack; }; -struct pic_port { +struct port { PIC_OBJECT_HEADER xFILE *file; }; -struct pic_checkpoint { +struct checkpoint { PIC_OBJECT_HEADER - struct pic_proc *in; - struct pic_proc *out; + struct proc *in; + struct proc *out; int depth; - struct pic_checkpoint *prev; + struct checkpoint *prev; }; -struct pic_object *pic_obj_ptr(pic_value); +struct object *pic_obj_ptr(pic_value); -#define pic_id_ptr(pic, o) (assert(pic_id_p(pic, o)), (identifier *)pic_obj_ptr(o)) +#define pic_id_ptr(pic, o) (assert(pic_id_p(pic, o)), (struct identifier *)pic_obj_ptr(o)) #define pic_sym_ptr(pic, o) (assert(pic_sym_p(pic, o)), (symbol *)pic_obj_ptr(o)) -#define pic_str_ptr(pic, o) (assert(pic_str_p(pic, o)), (struct pic_string *)pic_obj_ptr(o)) -#define pic_blob_ptr(pic, o) (assert(pic_blob_p(pic, o)), (struct pic_blob *)pic_obj_ptr(o)) -#define pic_pair_ptr(pic, o) (assert(pic_pair_p(pic, o)), (struct pic_pair *)pic_obj_ptr(o)) -#define pic_vec_ptr(pic, o) (assert(pic_vec_p(pic, o)), (struct pic_vector *)pic_obj_ptr(o)) -#define pic_dict_ptr(pic, o) (assert(pic_dict_p(pic, o)), (struct pic_dict *)pic_obj_ptr(o)) -#define pic_weak_ptr(pic, o) (assert(pic_weak_p(pic, o)), (struct pic_weak *)pic_obj_ptr(o)) -#define pic_data_ptr(pic, o) (assert(pic_data_p(pic, o, NULL)), (struct pic_data *)pic_obj_ptr(o)) -#define pic_proc_ptr(pic, o) (assert(pic_proc_p(pic, o)), (struct pic_proc *)pic_obj_ptr(o)) -#define pic_env_ptr(pic, o) (assert(pic_env_p(pic, o)), (struct pic_env *)pic_obj_ptr(o)) -#define pic_port_ptr(pic, o) (assert(pic_port_p(pic, o)), (struct pic_port *)pic_obj_ptr(o)) -#define pic_error_ptr(pic, o) (assert(pic_error_p(pic, o)), (struct pic_error *)pic_obj_ptr(o)) -#define pic_rec_ptr(pic, o) (assert(pic_rec_p(pic, o)), (struct pic_record *)pic_obj_ptr(o)) +#define pic_str_ptr(pic, o) (assert(pic_str_p(pic, o)), (struct string *)pic_obj_ptr(o)) +#define pic_blob_ptr(pic, o) (assert(pic_blob_p(pic, o)), (struct blob *)pic_obj_ptr(o)) +#define pic_pair_ptr(pic, o) (assert(pic_pair_p(pic, o)), (struct pair *)pic_obj_ptr(o)) +#define pic_vec_ptr(pic, o) (assert(pic_vec_p(pic, o)), (struct vector *)pic_obj_ptr(o)) +#define pic_dict_ptr(pic, o) (assert(pic_dict_p(pic, o)), (struct dict *)pic_obj_ptr(o)) +#define pic_weak_ptr(pic, o) (assert(pic_weak_p(pic, o)), (struct weak *)pic_obj_ptr(o)) +#define pic_data_ptr(pic, o) (assert(pic_data_p(pic, o, NULL)), (struct data *)pic_obj_ptr(o)) +#define pic_proc_ptr(pic, o) (assert(pic_proc_p(pic, o)), (struct proc *)pic_obj_ptr(o)) +#define pic_env_ptr(pic, o) (assert(pic_env_p(pic, o)), (struct env *)pic_obj_ptr(o)) +#define pic_port_ptr(pic, o) (assert(pic_port_p(pic, o)), (struct port *)pic_obj_ptr(o)) +#define pic_error_ptr(pic, o) (assert(pic_error_p(pic, o)), (struct error *)pic_obj_ptr(o)) +#define pic_rec_ptr(pic, o) (assert(pic_rec_p(pic, o)), (struct record *)pic_obj_ptr(o)) #define pic_obj_p(pic,v) (pic_type(pic,v) > PIC_IVAL_END) #define pic_env_p(pic, v) (pic_type(pic, v) == PIC_TYPE_ENV) @@ -162,7 +161,7 @@ struct pic_object *pic_obj_ptr(pic_value); #define pic_id_p(pic, v) (pic_type(pic, v) == PIC_TYPE_ID || pic_type(pic, v) == PIC_TYPE_SYMBOL) pic_value pic_obj_value(void *ptr); -struct pic_object *pic_obj_alloc(pic_state *, size_t, int type); +struct object *pic_obj_alloc(pic_state *, size_t, int type); #define VALID_INDEX(pic, len, i) do { \ if (i < 0 || len <= i) pic_errorf(pic, "index out of range: %d", i); \ @@ -179,7 +178,7 @@ struct pic_object *pic_obj_alloc(pic_state *, size_t, int type); pic_value pic_make_identifier(pic_state *, pic_value id, pic_value env); pic_value pic_make_proc(pic_state *, pic_func_t, int, pic_value *); -pic_value pic_make_proc_irep(pic_state *, struct pic_irep *, struct pic_context *); +pic_value pic_make_proc_irep(pic_state *, struct irep *, struct context *); pic_value pic_make_env(pic_state *, pic_value env); pic_value pic_make_error(pic_state *, const char *type, const char *msg, pic_value irrs); pic_value pic_make_rec(pic_state *, pic_value type, pic_value datum); @@ -189,13 +188,13 @@ pic_value pic_put_identifier(pic_state *, pic_value id, pic_value uid, pic_value pic_value pic_find_identifier(pic_state *, pic_value id, pic_value env); pic_value pic_id_name(pic_state *, pic_value id); -void pic_rope_incref(pic_state *, struct pic_rope *); -void pic_rope_decref(pic_state *, struct pic_rope *); +void pic_rope_incref(pic_state *, struct rope *); +void pic_rope_decref(pic_state *, struct rope *); #define pic_proc_func_p(proc) ((proc)->tag == PIC_PROC_TAG_FUNC) #define pic_proc_irep_p(proc) ((proc)->tag == PIC_PROC_TAG_IREP) -void pic_wind(pic_state *, struct pic_checkpoint *, struct pic_checkpoint *); +void pic_wind(pic_state *, struct checkpoint *, struct checkpoint *); #if defined(__cplusplus) diff --git a/extlib/benz/include/picrin/private/state.h b/extlib/benz/include/picrin/private/state.h index 072de9dd..a5ea7ae8 100644 --- a/extlib/benz/include/picrin/private/state.h +++ b/extlib/benz/include/picrin/private/state.h @@ -15,48 +15,48 @@ extern "C" { #include "picrin/private/vm.h" #include "picrin/private/gc.h" -struct pic_lib { - struct pic_string *name; - struct pic_env *env; - struct pic_dict *exports; +struct lib { + struct string *name; + struct env *env; + struct dict *exports; }; -struct pic_callinfo { +struct callinfo { int argc, retc; - struct pic_code *ip; + struct code *ip; pic_value *fp; - struct pic_irep *irep; - struct pic_context *cxt; + struct irep *irep; + struct context *cxt; int regc; pic_value *regs; - struct pic_context *up; + struct context *up; }; -KHASH_DECLARE(oblist, struct pic_string *, struct pic_identifier *) -KHASH_DECLARE(ltable, const char *, struct pic_lib) +KHASH_DECLARE(oblist, struct string *, struct identifier *) +KHASH_DECLARE(ltable, const char *, struct lib) struct pic_state { pic_allocf allocf; void *userdata; - struct pic_checkpoint *cp; + struct checkpoint *cp; struct pic_cont *cc; int ccnt; pic_value *sp; pic_value *stbase, *stend; - struct pic_callinfo *ci; - struct pic_callinfo *cibase, *ciend; + struct callinfo *ci; + struct callinfo *cibase, *ciend; - struct pic_proc **xp; - struct pic_proc **xpbase, **xpend; + struct proc **xp; + struct proc **xpbase, **xpend; - struct pic_code *ip; + struct code *ip; pic_value ptable; /* list of ephemerons */ - struct pic_lib *lib; + struct lib *lib; pic_value features; @@ -65,14 +65,14 @@ struct pic_state { pic_value globals; /* weak */ pic_value macros; /* weak */ khash_t(ltable) ltable; - struct pic_list_head ireps; /* chain */ + struct list_head ireps; /* chain */ xFILE files[XOPEN_MAX]; - struct pic_code iseq[2]; /* for pic_apply_trampoline */ + struct code iseq[2]; /* for pic_apply_trampoline */ bool gc_enable; - struct pic_heap *heap; - struct pic_object **arena; + struct heap *heap; + struct object **arena; size_t arena_size, arena_idx; pic_value err; diff --git a/extlib/benz/include/picrin/private/vm.h b/extlib/benz/include/picrin/private/vm.h index a51ccc95..2ad09095 100644 --- a/extlib/benz/include/picrin/private/vm.h +++ b/extlib/benz/include/picrin/private/vm.h @@ -52,31 +52,31 @@ enum { OP_STOP }; -struct pic_code { +struct code { int insn; int a; int b; }; -struct pic_list_head { - struct pic_list_head *prev, *next; +struct list_head { + struct list_head *prev, *next; }; -struct pic_irep { - struct pic_list_head list; +struct irep { + struct list_head list; unsigned refc; int argc, localc, capturec; bool varg; - struct pic_code *code; - struct pic_irep **irep; + struct code *code; + struct irep **irep; int *ints; double *nums; - struct pic_object **pool; + struct object **pool; size_t ncode, nirep, nints, nnums, npool; }; -void pic_irep_incref(pic_state *, struct pic_irep *); -void pic_irep_decref(pic_state *, struct pic_irep *); +void pic_irep_incref(pic_state *, struct irep *); +void pic_irep_decref(pic_state *, struct irep *); #if defined(__cplusplus) } diff --git a/extlib/benz/lib.c b/extlib/benz/lib.c index 62823155..e5bca1ad 100644 --- a/extlib/benz/lib.c +++ b/extlib/benz/lib.c @@ -7,9 +7,9 @@ #include "picrin/private/object.h" #include "picrin/private/state.h" -KHASH_DEFINE(ltable, const char *, struct pic_lib, kh_str_hash_func, kh_str_cmp_func) +KHASH_DEFINE(ltable, const char *, struct lib, kh_str_hash_func, kh_str_cmp_func) -static struct pic_lib * +static struct lib * get_library_opt(pic_state *pic, const char *lib) { khash_t(ltable) *h = &pic->ltable; @@ -22,10 +22,10 @@ get_library_opt(pic_state *pic, const char *lib) return &kh_val(h, it); } -static struct pic_lib * +static struct lib * get_library(pic_state *pic, const char *lib) { - struct pic_lib *libp; + struct lib *libp; if ((libp = get_library_opt(pic, lib)) == NULL) { pic_errorf(pic, "library not found: %s", lib); @@ -36,10 +36,10 @@ get_library(pic_state *pic, const char *lib) static pic_value make_library_env(pic_state *pic, pic_value name) { - struct pic_env *env; + struct env *env; pic_value e; - env = (struct pic_env *)pic_obj_alloc(pic, sizeof(struct pic_env), PIC_TYPE_ENV); + env = (struct env *)pic_obj_alloc(pic, sizeof(struct env), PIC_TYPE_ENV); env->up = NULL; env->lib = pic_str_ptr(pic, name); kh_init(env, &env->map); @@ -117,7 +117,7 @@ pic_import(pic_state *pic, const char *lib) { pic_value name, realname, uid; int it = 0; - struct pic_lib *libp; + struct lib *libp; libp = get_library(pic, lib); @@ -181,7 +181,7 @@ pic_lib_library_import(pic_state *pic) { const char *lib; pic_value name, alias, realname, uid; - struct pic_lib *libp; + struct lib *libp; int n; n = pic_get_args(pic, "zm|m", &lib, &name, &alias); @@ -231,7 +231,7 @@ pic_lib_library_exports(pic_state *pic) const char *lib; pic_value sym, exports = pic_nil_value(pic); int it = 0; - struct pic_lib *libp; + struct lib *libp; pic_get_args(pic, "z", &lib); diff --git a/extlib/benz/macro.c b/extlib/benz/macro.c index 8028f6cf..f1372bef 100644 --- a/extlib/benz/macro.c +++ b/extlib/benz/macro.c @@ -7,14 +7,14 @@ #include "picrin/private/object.h" #include "picrin/private/state.h" -KHASH_DEFINE(env, identifier *, symbol *, kh_ptr_hash_func, kh_ptr_hash_equal) +KHASH_DEFINE(env, struct identifier *, symbol *, kh_ptr_hash_func, kh_ptr_hash_equal) pic_value pic_make_env(pic_state *pic, pic_value up) { - struct pic_env *env; + struct env *env; - env = (struct pic_env *)pic_obj_alloc(pic, sizeof(struct pic_env), PIC_TYPE_ENV); + env = (struct env *)pic_obj_alloc(pic, sizeof(struct env), PIC_TYPE_ENV); env->up = pic_env_ptr(pic, up); env->lib = NULL; kh_init(env, &env->map); @@ -68,7 +68,7 @@ search_scope(pic_state *pic, pic_value id, pic_value env, pic_value *uid) static bool search(pic_state *pic, pic_value id, pic_value env, pic_value *uid) { - struct pic_env *e; + struct env *e; while (1) { if (search_scope(pic, id, env, uid)) @@ -84,7 +84,7 @@ search(pic_state *pic, pic_value id, pic_value env, pic_value *uid) pic_value pic_find_identifier(pic_state *pic, pic_value id, pic_value env) { - struct pic_env *e; + struct env *e; pic_value uid; while (! search(pic, id, env, &uid)) { diff --git a/extlib/benz/pair.c b/extlib/benz/pair.c index 4fcfab40..4d6f474a 100644 --- a/extlib/benz/pair.c +++ b/extlib/benz/pair.c @@ -9,9 +9,9 @@ pic_value pic_cons(pic_state *pic, pic_value car, pic_value cdr) { - struct pic_pair *pair; + struct pair *pair; - pair = (struct pic_pair *)pic_obj_alloc(pic, sizeof(struct pic_pair), PIC_TYPE_PAIR); + pair = (struct pair *)pic_obj_alloc(pic, sizeof(struct pair), PIC_TYPE_PAIR); pair->car = car; pair->cdr = cdr; diff --git a/extlib/benz/port.c b/extlib/benz/port.c index 016a52db..a0c70e6a 100644 --- a/extlib/benz/port.c +++ b/extlib/benz/port.c @@ -13,9 +13,9 @@ pic_value pic_open_port(pic_state *pic, xFILE *file) { - struct pic_port *port; + struct port *port; - port = (struct pic_port *)pic_obj_alloc(pic, sizeof(struct pic_port), PIC_TYPE_PORT); + port = (struct port *)pic_obj_alloc(pic, sizeof(struct port), PIC_TYPE_PORT); port->file = file; return pic_obj_value(port); diff --git a/extlib/benz/proc.c b/extlib/benz/proc.c index 7445a402..301dd09d 100644 --- a/extlib/benz/proc.c +++ b/extlib/benz/proc.c @@ -253,18 +253,18 @@ vm_gset(pic_state *pic, pic_value uid, pic_value value) static void vm_push_cxt(pic_state *pic) { - struct pic_callinfo *ci = pic->ci; + struct callinfo *ci = pic->ci; - ci->cxt = (struct pic_context *)pic_obj_alloc(pic, offsetof(struct pic_context, storage) + sizeof(pic_value) * ci->regc, PIC_TYPE_CXT); + ci->cxt = (struct context *)pic_obj_alloc(pic, offsetof(struct context, storage) + sizeof(pic_value) * ci->regc, PIC_TYPE_CXT); ci->cxt->up = ci->up; ci->cxt->regc = ci->regc; ci->cxt->regs = ci->regs; } static void -vm_tear_off(struct pic_callinfo *ci) +vm_tear_off(struct callinfo *ci) { - struct pic_context *cxt; + struct context *cxt; int i; assert(ci->cxt != NULL); @@ -283,7 +283,7 @@ vm_tear_off(struct pic_callinfo *ci) void pic_vm_tear_off(pic_state *pic) { - struct pic_callinfo *ci; + struct callinfo *ci; for (ci = pic->ci; ci > pic->cibase; ci--) { if (ci->cxt != NULL) { @@ -326,9 +326,9 @@ bool pic_ge(pic_state *, pic_value, pic_value); pic_value pic_apply(pic_state *pic, pic_value proc, int argc, pic_value *argv) { - struct pic_code c; + struct code c; size_t ai = pic_enter(pic); - struct pic_code boot[2]; + struct code boot[2]; int i; #if PIC_DIRECT_THREADED_VM @@ -411,8 +411,8 @@ pic_apply(pic_state *pic, pic_value proc, int argc, pic_value *argv) NEXT; } CASE(OP_LREF) { - struct pic_callinfo *ci = pic->ci; - struct pic_irep *irep = ci->irep; + struct callinfo *ci = pic->ci; + struct irep *irep = ci->irep; if (ci->cxt != NULL && ci->cxt->regs == ci->cxt->storage) { if (c.a >= irep->argc + irep->localc) { @@ -424,8 +424,8 @@ pic_apply(pic_state *pic, pic_value proc, int argc, pic_value *argv) NEXT; } CASE(OP_LSET) { - struct pic_callinfo *ci = pic->ci; - struct pic_irep *irep = ci->irep; + struct callinfo *ci = pic->ci; + struct irep *irep = ci->irep; if (ci->cxt != NULL && ci->cxt->regs == ci->cxt->storage) { if (c.a >= irep->argc + irep->localc) { @@ -440,7 +440,7 @@ pic_apply(pic_state *pic, pic_value proc, int argc, pic_value *argv) } CASE(OP_CREF) { int depth = c.a; - struct pic_context *cxt; + struct context *cxt; cxt = pic->ci->up; while (--depth) { @@ -451,7 +451,7 @@ pic_apply(pic_state *pic, pic_value proc, int argc, pic_value *argv) } CASE(OP_CSET) { int depth = c.a; - struct pic_context *cxt; + struct context *cxt; cxt = pic->ci->up; while (--depth) { @@ -477,8 +477,8 @@ pic_apply(pic_state *pic, pic_value proc, int argc, pic_value *argv) } CASE(OP_CALL) { pic_value x, v; - struct pic_callinfo *ci; - struct pic_proc *proc; + struct callinfo *ci; + struct proc *proc; if (c.a == -1) { pic->sp += pic->ci[1].retc - 1; @@ -514,7 +514,7 @@ pic_apply(pic_state *pic, pic_value proc, int argc, pic_value *argv) goto L_RET; } else { - struct pic_irep *irep = proc->u.i.irep; + struct irep *irep = proc->u.i.irep; int i; pic_value rest; @@ -557,7 +557,7 @@ pic_apply(pic_state *pic, pic_value proc, int argc, pic_value *argv) CASE(OP_TAILCALL) { int i, argc; pic_value *argv; - struct pic_callinfo *ci; + struct callinfo *ci; if (pic->ci->cxt != NULL) { vm_tear_off(pic->ci); @@ -583,7 +583,7 @@ pic_apply(pic_state *pic, pic_value proc, int argc, pic_value *argv) CASE(OP_RET) { int i, retc; pic_value *retv; - struct pic_callinfo *ci; + struct callinfo *ci; if (pic->ci->cxt != NULL) { vm_tear_off(pic->ci); @@ -772,7 +772,7 @@ pic_value pic_applyk(pic_state *pic, pic_value proc, int argc, pic_value *args) { pic_value *sp; - struct pic_callinfo *ci; + struct callinfo *ci; int i; pic->iseq[0].insn = OP_NOP; @@ -904,7 +904,7 @@ pic_set(pic_state *pic, const char *lib, const char *name, pic_value val) pic_value pic_closure_ref(pic_state *pic, int n) { - struct pic_proc *self = pic_proc_ptr(pic, GET_OPERAND(pic, 0)); + struct proc *self = pic_proc_ptr(pic, GET_OPERAND(pic, 0)); assert(pic_proc_func_p(self)); @@ -917,7 +917,7 @@ pic_closure_ref(pic_state *pic, int n) void pic_closure_set(pic_state *pic, int n, pic_value v) { - struct pic_proc *self = pic_proc_ptr(pic, GET_OPERAND(pic, 0)); + struct proc *self = pic_proc_ptr(pic, GET_OPERAND(pic, 0)); assert(pic_proc_func_p(self)); @@ -945,13 +945,13 @@ pic_funcall(pic_state *pic, const char *lib, const char *name, int n, ...) } void -pic_irep_incref(pic_state *PIC_UNUSED(pic), struct pic_irep *irep) +pic_irep_incref(pic_state *PIC_UNUSED(pic), struct irep *irep) { irep->refc++; } void -pic_irep_decref(pic_state *pic, struct pic_irep *irep) +pic_irep_decref(pic_state *pic, struct irep *irep) { size_t i; @@ -976,10 +976,10 @@ pic_irep_decref(pic_state *pic, struct pic_irep *irep) pic_value pic_make_proc(pic_state *pic, pic_func_t func, int n, pic_value *env) { - struct pic_proc *proc; + struct proc *proc; int i; - proc = (struct pic_proc *)pic_obj_alloc(pic, offsetof(struct pic_proc, locals) + sizeof(pic_value) * n, PIC_TYPE_PROC); + proc = (struct proc *)pic_obj_alloc(pic, offsetof(struct proc, locals) + sizeof(pic_value) * n, PIC_TYPE_PROC); proc->tag = PIC_PROC_TAG_FUNC; proc->u.f.func = func; proc->u.f.localc = n; @@ -990,11 +990,11 @@ pic_make_proc(pic_state *pic, pic_func_t func, int n, pic_value *env) } pic_value -pic_make_proc_irep(pic_state *pic, struct pic_irep *irep, struct pic_context *cxt) +pic_make_proc_irep(pic_state *pic, struct irep *irep, struct context *cxt) { - struct pic_proc *proc; + struct proc *proc; - proc = (struct pic_proc *)pic_obj_alloc(pic, offsetof(struct pic_proc, locals), PIC_TYPE_PROC); + proc = (struct proc *)pic_obj_alloc(pic, offsetof(struct proc, locals), PIC_TYPE_PROC); proc->tag = PIC_PROC_TAG_IREP; proc->u.i.irep = irep; proc->u.i.cxt = cxt; diff --git a/extlib/benz/record.c b/extlib/benz/record.c index 9d764b99..36a9dc79 100644 --- a/extlib/benz/record.c +++ b/extlib/benz/record.c @@ -8,9 +8,9 @@ pic_value pic_make_rec(pic_state *pic, pic_value type, pic_value datum) { - struct pic_record *rec; + struct record *rec; - rec = (struct pic_record *)pic_obj_alloc(pic, sizeof(struct pic_record), PIC_TYPE_RECORD); + rec = (struct record *)pic_obj_alloc(pic, sizeof(struct record), PIC_TYPE_RECORD); rec->type = type; rec->datum = datum; diff --git a/extlib/benz/state.c b/extlib/benz/state.c index 3cbeb95d..5f4c5adb 100644 --- a/extlib/benz/state.c +++ b/extlib/benz/state.c @@ -219,7 +219,7 @@ pic_open(pic_allocf allocf, void *userdata) } /* callinfo */ - pic->cibase = pic->ci = allocf(userdata, NULL, PIC_STACK_SIZE * sizeof(struct pic_callinfo)); + pic->cibase = pic->ci = allocf(userdata, NULL, PIC_STACK_SIZE * sizeof(struct callinfo)); pic->ciend = pic->cibase + PIC_STACK_SIZE; if (! pic->ci) { @@ -227,7 +227,7 @@ pic_open(pic_allocf allocf, void *userdata) } /* exception handler */ - pic->xpbase = pic->xp = allocf(userdata, NULL, PIC_RESCUE_SIZE * sizeof(struct pic_proc *)); + pic->xpbase = pic->xp = allocf(userdata, NULL, PIC_RESCUE_SIZE * sizeof(struct proc *)); pic->xpend = pic->xpbase + PIC_RESCUE_SIZE; if (! pic->xp) { @@ -235,7 +235,7 @@ pic_open(pic_allocf allocf, void *userdata) } /* GC arena */ - pic->arena = allocf(userdata, NULL, PIC_ARENA_SIZE * sizeof(struct pic_object *)); + pic->arena = allocf(userdata, NULL, PIC_ARENA_SIZE * sizeof(struct object *)); pic->arena_size = PIC_ARENA_SIZE; pic->arena_idx = 0; @@ -298,7 +298,7 @@ pic_open(pic_allocf allocf, void *userdata) pic->macros = pic_make_weak(pic); /* root block */ - pic->cp = (struct pic_checkpoint *)pic_obj_alloc(pic, sizeof(struct pic_checkpoint), PIC_TYPE_CP); + pic->cp = (struct checkpoint *)pic_obj_alloc(pic, sizeof(struct checkpoint), PIC_TYPE_CP); pic->cp->prev = NULL; pic->cp->depth = 0; pic->cp->in = pic->cp->out = NULL; @@ -356,7 +356,7 @@ pic_close(pic_state *pic) { /* FIXME */ int i = 0; - struct pic_list_head *list; + struct list_head *list; for (list = pic->ireps.next; list != &pic->ireps; list = list->next) { i++; } diff --git a/extlib/benz/string.c b/extlib/benz/string.c index 567951d1..75a703db 100644 --- a/extlib/benz/string.c +++ b/extlib/benz/string.c @@ -6,19 +6,19 @@ #include "picrin/extra.h" #include "picrin/private/object.h" -struct pic_chunk { +struct chunk { char *str; int refcnt; size_t len; char buf[1]; }; -struct pic_rope { +struct rope { int refcnt; size_t weight; - struct pic_chunk *chunk; + struct chunk *chunk; size_t offset; - struct pic_rope *left, *right; + struct rope *left, *right; }; #define CHUNK_INCREF(c) do { \ @@ -26,19 +26,19 @@ struct pic_rope { } while (0) #define CHUNK_DECREF(c) do { \ - struct pic_chunk *c_ = (c); \ + struct chunk *c_ = (c); \ if (! --c_->refcnt) { \ pic_free(pic, c_); \ } \ } while (0) void -pic_rope_incref(pic_state *PIC_UNUSED(pic), struct pic_rope *x) { +pic_rope_incref(pic_state *PIC_UNUSED(pic), struct rope *x) { x->refcnt++; } void -pic_rope_decref(pic_state *pic, struct pic_rope *x) { +pic_rope_decref(pic_state *pic, struct rope *x) { if (! --x->refcnt) { if (x->chunk) { CHUNK_DECREF(x->chunk); @@ -51,12 +51,12 @@ pic_rope_decref(pic_state *pic, struct pic_rope *x) { } } -static struct pic_chunk * +static struct chunk * pic_make_chunk(pic_state *pic, const char *str, size_t len) { - struct pic_chunk *c; + struct chunk *c; - c = pic_malloc(pic, offsetof(struct pic_chunk, buf) + len + 1); + c = pic_malloc(pic, offsetof(struct chunk, buf) + len + 1); c->refcnt = 1; c->str = c->buf; c->len = len; @@ -66,12 +66,12 @@ pic_make_chunk(pic_state *pic, const char *str, size_t len) return c; } -static struct pic_chunk * +static struct chunk * pic_make_chunk_lit(pic_state *pic, const char *str, size_t len) { - struct pic_chunk *c; + struct chunk *c; - c = pic_malloc(pic, sizeof(struct pic_chunk)); + c = pic_malloc(pic, sizeof(struct chunk)); c->refcnt = 1; c->str = (char *)str; c->len = len; @@ -79,12 +79,12 @@ pic_make_chunk_lit(pic_state *pic, const char *str, size_t len) return c; } -static struct pic_rope * -pic_make_rope(pic_state *pic, struct pic_chunk *c) +static struct rope * +pic_make_rope(pic_state *pic, struct chunk *c) { - struct pic_rope *x; + struct rope *x; - x = pic_malloc(pic, sizeof(struct pic_rope)); + x = pic_malloc(pic, sizeof(struct rope)); x->refcnt = 1; x->left = NULL; x->right = NULL; @@ -96,24 +96,24 @@ pic_make_rope(pic_state *pic, struct pic_chunk *c) } static pic_value -pic_make_str(pic_state *pic, struct pic_rope *rope) +pic_make_str(pic_state *pic, struct rope *rope) { - struct pic_string *str; + struct string *str; - str = (struct pic_string *)pic_obj_alloc(pic, sizeof(struct pic_string), PIC_TYPE_STRING); + str = (struct string *)pic_obj_alloc(pic, sizeof(struct string), PIC_TYPE_STRING); str->rope = rope; /* delegate ownership */ return pic_obj_value(str); } static size_t -rope_len(struct pic_rope *x) +rope_len(struct rope *x) { return x->weight; } static char -rope_at(struct pic_rope *x, size_t i) +rope_at(struct rope *x, size_t i) { while (i < x->weight) { if (x->chunk) { @@ -129,12 +129,12 @@ rope_at(struct pic_rope *x, size_t i) return -1; } -static struct pic_rope * -rope_cat(pic_state *pic, struct pic_rope *x, struct pic_rope *y) +static struct rope * +rope_cat(pic_state *pic, struct rope *x, struct rope *y) { - struct pic_rope *z; + struct rope *z; - z = pic_malloc(pic, sizeof(struct pic_rope)); + z = pic_malloc(pic, sizeof(struct rope)); z->refcnt = 1; z->left = x; z->right = y; @@ -148,8 +148,8 @@ rope_cat(pic_state *pic, struct pic_rope *x, struct pic_rope *y) return z; } -static struct pic_rope * -rope_sub(pic_state *pic, struct pic_rope *x, size_t i, size_t j) +static struct rope * +rope_sub(pic_state *pic, struct rope *x, size_t i, size_t j) { assert(i <= j); assert(j <= x->weight); @@ -160,9 +160,9 @@ rope_sub(pic_state *pic, struct pic_rope *x, size_t i, size_t j) } if (x->chunk) { - struct pic_rope *y; + struct rope *y; - y = pic_malloc(pic, sizeof(struct pic_rope)); + y = pic_malloc(pic, sizeof(struct rope)); y->refcnt = 1; y->left = NULL; y->right = NULL; @@ -182,7 +182,7 @@ rope_sub(pic_state *pic, struct pic_rope *x, size_t i, size_t j) return rope_sub(pic, x->right, i - x->left->weight, j - x->left->weight); } else { - struct pic_rope *r, *l; + struct rope *r, *l; l = rope_sub(pic, x->left, i, x->left->weight); r = rope_sub(pic, x->right, 0, j - x->left->weight); @@ -196,7 +196,7 @@ rope_sub(pic_state *pic, struct pic_rope *x, size_t i, size_t j) } static void -flatten(pic_state *pic, struct pic_rope *x, struct pic_chunk *c, size_t offset) +flatten(pic_state *pic, struct rope *x, struct chunk *c, size_t offset) { if (x->chunk) { memcpy(c->str + offset, x->chunk->str + x->offset, x->weight); @@ -219,15 +219,15 @@ flatten(pic_state *pic, struct pic_rope *x, struct pic_chunk *c, size_t offset) } static const char * -rope_cstr(pic_state *pic, struct pic_rope *x) +rope_cstr(pic_state *pic, struct rope *x) { - struct pic_chunk *c; + struct chunk *c; if (x->chunk && x->offset == 0 && x->weight == x->chunk->len) { return x->chunk->str; /* reuse cached chunk */ } - c = pic_malloc(pic, offsetof(struct pic_chunk, buf) + x->weight + 1); + c = pic_malloc(pic, offsetof(struct chunk, buf) + x->weight + 1); c->refcnt = 1; c->len = x->weight; c->str = c->buf; @@ -250,7 +250,7 @@ str_update(pic_state *pic, pic_value dst, pic_value src) pic_value pic_str_value(pic_state *pic, const char *str, int len) { - struct pic_chunk *c; + struct chunk *c; if (len > 0) { c = pic_make_chunk(pic, str, len); diff --git a/extlib/benz/symbol.c b/extlib/benz/symbol.c index 3f40ef43..cff34df8 100644 --- a/extlib/benz/symbol.c +++ b/extlib/benz/symbol.c @@ -10,7 +10,7 @@ #define kh_pic_str_hash(a) (pic_str_hash(pic, pic_obj_value(a))) #define kh_pic_str_cmp(a, b) (pic_str_cmp(pic, pic_obj_value(a), pic_obj_value(b)) == 0) -KHASH_DEFINE(oblist, struct pic_string *, symbol *, kh_pic_str_hash, kh_pic_str_cmp) +KHASH_DEFINE(oblist, struct string *, symbol *, kh_pic_str_hash, kh_pic_str_cmp) pic_value pic_intern(pic_state *pic, pic_value str) @@ -39,9 +39,9 @@ pic_intern(pic_state *pic, pic_value str) pic_value pic_make_identifier(pic_state *pic, pic_value base, pic_value env) { - identifier *id; + struct identifier *id; - id = (identifier *)pic_obj_alloc(pic, sizeof(identifier), PIC_TYPE_ID); + id = (struct identifier *)pic_obj_alloc(pic, sizeof(struct identifier), PIC_TYPE_ID); id->u.id = pic_id_ptr(pic, base); id->env = pic_env_ptr(pic, env); diff --git a/extlib/benz/value.c b/extlib/benz/value.c index 87dd9d7d..bd2d1e8e 100644 --- a/extlib/benz/value.c +++ b/extlib/benz/value.c @@ -45,10 +45,10 @@ pic_char(pic_state *PIC_UNUSED(pic), pic_value v) return v & 0xfffffffful; } -struct pic_object * +struct object * pic_obj_ptr(pic_value v) { - return (struct pic_object *)(0xfffffffffffful & v); + return (struct object *)(0xfffffffffffful & v); } #else @@ -79,10 +79,10 @@ pic_char(pic_state *PIC_UNUSED(pic), pic_value v) return v.u.c; } -struct pic_object * +struct object * pic_obj_ptr(pic_value v) { - return (struct pic_object *)(v.u.data); + return (struct object *)(v.u.data); } #endif @@ -198,7 +198,7 @@ pic_type(pic_state *PIC_UNUSED(pic), pic_value v) if (tt < PIC_IVAL_END) { return tt; } - return ((struct pic_basic *)pic_obj_ptr(v))->tt; + return ((struct basic *)pic_obj_ptr(v))->tt; } const char * diff --git a/extlib/benz/vector.c b/extlib/benz/vector.c index 71d12519..978cfeb1 100644 --- a/extlib/benz/vector.c +++ b/extlib/benz/vector.c @@ -9,10 +9,10 @@ pic_value pic_make_vec(pic_state *pic, int len, pic_value *argv) { - struct pic_vector *vec; + struct vector *vec; int i; - vec = (struct pic_vector *)pic_obj_alloc(pic, sizeof(struct pic_vector), PIC_TYPE_VECTOR); + vec = (struct vector *)pic_obj_alloc(pic, sizeof(struct vector), PIC_TYPE_VECTOR); vec->len = len; vec->data = (pic_value *)pic_malloc(pic, sizeof(pic_value) * len); if (argv == NULL) { diff --git a/extlib/benz/weak.c b/extlib/benz/weak.c index 6ab88f89..3064873c 100644 --- a/extlib/benz/weak.c +++ b/extlib/benz/weak.c @@ -5,14 +5,14 @@ #include "picrin.h" #include "picrin/private/object.h" -KHASH_DEFINE(weak, struct pic_object *, pic_value, kh_ptr_hash_func, kh_ptr_hash_equal) +KHASH_DEFINE(weak, struct object *, pic_value, kh_ptr_hash_func, kh_ptr_hash_equal) pic_value pic_make_weak(pic_state *pic) { - struct pic_weak *weak; + struct weak *weak; - weak = (struct pic_weak *)pic_obj_alloc(pic, sizeof(struct pic_weak), PIC_TYPE_WEAK); + weak = (struct weak *)pic_obj_alloc(pic, sizeof(struct weak), PIC_TYPE_WEAK); weak->prev = NULL; kh_init(weak, &weak->hash);