From d52dfad671be5d84cf871da4a57491a2a007cd74 Mon Sep 17 00:00:00 2001 From: Yuichi Nishiwaki Date: Sun, 9 Apr 2017 15:49:04 +0900 Subject: [PATCH] struct context -> struct frame --- lib/ext/write.c | 4 ++-- lib/gc.c | 18 +++++++++--------- lib/include/picrin/value.h | 2 +- lib/object.h | 16 +++++----------- lib/proc.c | 14 +++++++------- lib/state.h | 4 ++-- lib/vm.h | 6 ++++++ 7 files changed, 32 insertions(+), 32 deletions(-) diff --git a/lib/ext/write.c b/lib/ext/write.c index 8ddbc4db..08070cde 100644 --- a/lib/ext/write.c +++ b/lib/ext/write.c @@ -454,8 +454,8 @@ typename(pic_state *pic, pic_value obj) return "port"; case PIC_TYPE_ERROR: return "error"; - case PIC_TYPE_CXT: - return "context"; + case PIC_TYPE_FRAME: + return "frame"; case PIC_TYPE_IREP: return "irep"; case PIC_TYPE_PROC_FUNC: diff --git a/lib/gc.c b/lib/gc.c index 41ba8279..81ea3c6d 100644 --- a/lib/gc.c +++ b/lib/gc.c @@ -28,7 +28,7 @@ struct object { struct data data; struct record rec; struct proc proc; - struct context cxt; + struct frame frame; struct port port; struct error err; struct irep irep; @@ -330,14 +330,14 @@ gc_mark_object(pic_state *pic, struct object *obj) } break; } - case PIC_TYPE_CXT: { + case PIC_TYPE_FRAME: { int i; - for (i = 0; i < obj->u.cxt.regc; ++i) { - gc_mark(pic, obj->u.cxt.regs[i]); + for (i = 0; i < obj->u.frame.regc; ++i) { + gc_mark(pic, obj->u.frame.regs[i]); } - if (obj->u.cxt.up) { - LOOP(obj->u.cxt.up); + if (obj->u.frame.up) { + LOOP(obj->u.frame.up); } break; } @@ -349,8 +349,8 @@ gc_mark_object(pic_state *pic, struct object *obj) break; } case PIC_TYPE_PROC_IREP: { - if (obj->u.proc.u.i.cxt) { - gc_mark_object(pic, (struct object *)obj->u.proc.u.i.cxt); + if (obj->u.proc.u.i.fp) { + gc_mark_object(pic, (struct object *)obj->u.proc.u.i.fp); } LOOP(obj->u.proc.u.i.irep); break; @@ -542,7 +542,7 @@ gc_finalize_object(pic_state *pic, struct object *obj) } case PIC_TYPE_PAIR: - case PIC_TYPE_CXT: + case PIC_TYPE_FRAME: case PIC_TYPE_ERROR: case PIC_TYPE_RECORD: case PIC_TYPE_PROC_FUNC: diff --git a/lib/include/picrin/value.h b/lib/include/picrin/value.h index 1dc3eac5..f45e4d43 100644 --- a/lib/include/picrin/value.h +++ b/lib/include/picrin/value.h @@ -32,7 +32,7 @@ enum { PIC_TYPE_RECORD = 27, PIC_TYPE_SYMBOL = 28, PIC_TYPE_PAIR = 29, - PIC_TYPE_CXT = 30, + PIC_TYPE_FRAME = 30, PIC_TYPE_PROC_FUNC = 32, PIC_TYPE_PROC_IREP = 33, PIC_TYPE_IREP = 34, diff --git a/lib/object.h b/lib/object.h index 2d645c1d..3e8b549b 100644 --- a/lib/object.h +++ b/lib/object.h @@ -81,12 +81,6 @@ struct record { pic_value datum; }; -struct code { - int insn; - int a; - int b; -}; - struct irep { OBJECT_HEADER int argc, localc, capturec; @@ -99,11 +93,11 @@ struct irep { size_t ncode, nirep, nints, nnums, npool; }; -struct context { +struct frame { OBJECT_HEADER - pic_value *regs; int regc; - struct context *up; + pic_value *regs; + struct frame *up; pic_value storage[1]; }; @@ -116,7 +110,7 @@ struct proc { } f; struct { struct irep *irep; - struct context *cxt; + struct frame *fp; } i; } u; pic_value locals[1]; @@ -260,7 +254,7 @@ DEFPTR(irep, struct irep) struct object *pic_obj_alloc(pic_state *, size_t, int type); pic_value pic_make_proc_func(pic_state *, pic_func_t, int, pic_value *); -pic_value pic_make_proc_irep(pic_state *, struct irep *, struct context *); +pic_value pic_make_proc_irep(pic_state *, struct irep *, struct frame *); 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/proc.c b/lib/proc.c index 56644d79..25127a0a 100644 --- a/lib/proc.c +++ b/lib/proc.c @@ -47,13 +47,13 @@ pic_make_proc_func(pic_state *pic, pic_func_t func, int n, pic_value *env) } pic_value -pic_make_proc_irep(pic_state *pic, struct irep *irep, struct context *cxt) +pic_make_proc_irep(pic_state *pic, struct irep *irep, struct frame *fp) { struct proc *proc; proc = (struct proc *)pic_obj_alloc(pic, offsetof(struct proc, locals), PIC_TYPE_PROC_IREP); proc->u.i.irep = irep; - proc->u.i.cxt = cxt; + proc->u.i.fp = fp; return obj_value(pic, proc); } @@ -340,7 +340,7 @@ vm_push_cxt(pic_state *pic) { struct callinfo *ci = pic->ci; - ci->cxt = (struct context *)pic_obj_alloc(pic, offsetof(struct context, storage) + sizeof(pic_value) * ci->regc, PIC_TYPE_CXT); + ci->cxt = (struct frame *)pic_obj_alloc(pic, offsetof(struct frame, storage) + sizeof(pic_value) * ci->regc, PIC_TYPE_FRAME); ci->cxt->up = ci->up; ci->cxt->regc = ci->regc; ci->cxt->regs = ci->regs; @@ -349,7 +349,7 @@ vm_push_cxt(pic_state *pic) static void vm_tear_off(struct callinfo *ci) { - struct context *cxt; + struct frame *cxt; int i; assert(ci->cxt != NULL); @@ -525,7 +525,7 @@ pic_apply(pic_state *pic, pic_value proc, int argc, pic_value *argv) } CASE(OP_CREF) { int depth = c.a; - struct context *cxt; + struct frame *cxt; cxt = pic->ci->up; while (--depth) { @@ -536,7 +536,7 @@ pic_apply(pic_state *pic, pic_value proc, int argc, pic_value *argv) } CASE(OP_CSET) { int depth = c.a; - struct context *cxt; + struct frame *cxt; cxt = pic->ci->up; while (--depth) { @@ -630,7 +630,7 @@ pic_apply(pic_state *pic, pic_value proc, int argc, pic_value *argv) } /* prepare cxt */ - ci->up = proc->u.i.cxt; + ci->up = proc->u.i.fp; ci->regc = irep->capturec; ci->regs = ci->fp + irep->argc + irep->localc; diff --git a/lib/state.h b/lib/state.h index 32f079a6..47433a7b 100644 --- a/lib/state.h +++ b/lib/state.h @@ -17,10 +17,10 @@ struct callinfo { const struct code *ip; pic_value *fp; struct irep *irep; - struct context *cxt; + struct frame *cxt; int regc; pic_value *regs; - struct context *up; + struct frame *up; }; KHASH_DECLARE(oblist, struct string *, struct symbol *) diff --git a/lib/vm.h b/lib/vm.h index 6bc6835a..d980e35a 100644 --- a/lib/vm.h +++ b/lib/vm.h @@ -52,6 +52,12 @@ enum { OP_STOP = 39 }; +struct code { + int insn; + int a; + int b; +}; + #if defined(__cplusplus) } #endif