struct context -> struct frame

This commit is contained in:
Yuichi Nishiwaki 2017-04-09 15:49:04 +09:00
parent 1d28290c14
commit d52dfad671
7 changed files with 32 additions and 32 deletions

View File

@ -454,8 +454,8 @@ typename(pic_state *pic, pic_value obj)
return "port"; return "port";
case PIC_TYPE_ERROR: case PIC_TYPE_ERROR:
return "error"; return "error";
case PIC_TYPE_CXT: case PIC_TYPE_FRAME:
return "context"; return "frame";
case PIC_TYPE_IREP: case PIC_TYPE_IREP:
return "irep"; return "irep";
case PIC_TYPE_PROC_FUNC: case PIC_TYPE_PROC_FUNC:

View File

@ -28,7 +28,7 @@ struct object {
struct data data; struct data data;
struct record rec; struct record rec;
struct proc proc; struct proc proc;
struct context cxt; struct frame frame;
struct port port; struct port port;
struct error err; struct error err;
struct irep irep; struct irep irep;
@ -330,14 +330,14 @@ gc_mark_object(pic_state *pic, struct object *obj)
} }
break; break;
} }
case PIC_TYPE_CXT: { case PIC_TYPE_FRAME: {
int i; int i;
for (i = 0; i < obj->u.cxt.regc; ++i) { for (i = 0; i < obj->u.frame.regc; ++i) {
gc_mark(pic, obj->u.cxt.regs[i]); gc_mark(pic, obj->u.frame.regs[i]);
} }
if (obj->u.cxt.up) { if (obj->u.frame.up) {
LOOP(obj->u.cxt.up); LOOP(obj->u.frame.up);
} }
break; break;
} }
@ -349,8 +349,8 @@ gc_mark_object(pic_state *pic, struct object *obj)
break; break;
} }
case PIC_TYPE_PROC_IREP: { case PIC_TYPE_PROC_IREP: {
if (obj->u.proc.u.i.cxt) { if (obj->u.proc.u.i.fp) {
gc_mark_object(pic, (struct object *)obj->u.proc.u.i.cxt); gc_mark_object(pic, (struct object *)obj->u.proc.u.i.fp);
} }
LOOP(obj->u.proc.u.i.irep); LOOP(obj->u.proc.u.i.irep);
break; break;
@ -542,7 +542,7 @@ gc_finalize_object(pic_state *pic, struct object *obj)
} }
case PIC_TYPE_PAIR: case PIC_TYPE_PAIR:
case PIC_TYPE_CXT: case PIC_TYPE_FRAME:
case PIC_TYPE_ERROR: case PIC_TYPE_ERROR:
case PIC_TYPE_RECORD: case PIC_TYPE_RECORD:
case PIC_TYPE_PROC_FUNC: case PIC_TYPE_PROC_FUNC:

View File

@ -32,7 +32,7 @@ enum {
PIC_TYPE_RECORD = 27, PIC_TYPE_RECORD = 27,
PIC_TYPE_SYMBOL = 28, PIC_TYPE_SYMBOL = 28,
PIC_TYPE_PAIR = 29, PIC_TYPE_PAIR = 29,
PIC_TYPE_CXT = 30, PIC_TYPE_FRAME = 30,
PIC_TYPE_PROC_FUNC = 32, PIC_TYPE_PROC_FUNC = 32,
PIC_TYPE_PROC_IREP = 33, PIC_TYPE_PROC_IREP = 33,
PIC_TYPE_IREP = 34, PIC_TYPE_IREP = 34,

View File

@ -81,12 +81,6 @@ struct record {
pic_value datum; pic_value datum;
}; };
struct code {
int insn;
int a;
int b;
};
struct irep { struct irep {
OBJECT_HEADER OBJECT_HEADER
int argc, localc, capturec; int argc, localc, capturec;
@ -99,11 +93,11 @@ struct irep {
size_t ncode, nirep, nints, nnums, npool; size_t ncode, nirep, nints, nnums, npool;
}; };
struct context { struct frame {
OBJECT_HEADER OBJECT_HEADER
pic_value *regs;
int regc; int regc;
struct context *up; pic_value *regs;
struct frame *up;
pic_value storage[1]; pic_value storage[1];
}; };
@ -116,7 +110,7 @@ struct proc {
} f; } f;
struct { struct {
struct irep *irep; struct irep *irep;
struct context *cxt; struct frame *fp;
} i; } i;
} u; } u;
pic_value locals[1]; pic_value locals[1];
@ -260,7 +254,7 @@ DEFPTR(irep, struct irep)
struct object *pic_obj_alloc(pic_state *, size_t, int type); 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_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_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_type(pic_state *pic, pic_value record);
pic_value pic_record_datum(pic_state *pic, pic_value record); pic_value pic_record_datum(pic_state *pic, pic_value record);

View File

@ -47,13 +47,13 @@ pic_make_proc_func(pic_state *pic, pic_func_t func, int n, pic_value *env)
} }
pic_value 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; struct proc *proc;
proc = (struct proc *)pic_obj_alloc(pic, offsetof(struct proc, locals), PIC_TYPE_PROC_IREP); proc = (struct proc *)pic_obj_alloc(pic, offsetof(struct proc, locals), PIC_TYPE_PROC_IREP);
proc->u.i.irep = irep; proc->u.i.irep = irep;
proc->u.i.cxt = cxt; proc->u.i.fp = fp;
return obj_value(pic, proc); return obj_value(pic, proc);
} }
@ -340,7 +340,7 @@ vm_push_cxt(pic_state *pic)
{ {
struct callinfo *ci = pic->ci; 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->up = ci->up;
ci->cxt->regc = ci->regc; ci->cxt->regc = ci->regc;
ci->cxt->regs = ci->regs; ci->cxt->regs = ci->regs;
@ -349,7 +349,7 @@ vm_push_cxt(pic_state *pic)
static void static void
vm_tear_off(struct callinfo *ci) vm_tear_off(struct callinfo *ci)
{ {
struct context *cxt; struct frame *cxt;
int i; int i;
assert(ci->cxt != NULL); assert(ci->cxt != NULL);
@ -525,7 +525,7 @@ pic_apply(pic_state *pic, pic_value proc, int argc, pic_value *argv)
} }
CASE(OP_CREF) { CASE(OP_CREF) {
int depth = c.a; int depth = c.a;
struct context *cxt; struct frame *cxt;
cxt = pic->ci->up; cxt = pic->ci->up;
while (--depth) { while (--depth) {
@ -536,7 +536,7 @@ pic_apply(pic_state *pic, pic_value proc, int argc, pic_value *argv)
} }
CASE(OP_CSET) { CASE(OP_CSET) {
int depth = c.a; int depth = c.a;
struct context *cxt; struct frame *cxt;
cxt = pic->ci->up; cxt = pic->ci->up;
while (--depth) { while (--depth) {
@ -630,7 +630,7 @@ pic_apply(pic_state *pic, pic_value proc, int argc, pic_value *argv)
} }
/* prepare cxt */ /* prepare cxt */
ci->up = proc->u.i.cxt; ci->up = proc->u.i.fp;
ci->regc = irep->capturec; ci->regc = irep->capturec;
ci->regs = ci->fp + irep->argc + irep->localc; ci->regs = ci->fp + irep->argc + irep->localc;

View File

@ -17,10 +17,10 @@ struct callinfo {
const struct code *ip; const struct code *ip;
pic_value *fp; pic_value *fp;
struct irep *irep; struct irep *irep;
struct context *cxt; struct frame *cxt;
int regc; int regc;
pic_value *regs; pic_value *regs;
struct context *up; struct frame *up;
}; };
KHASH_DECLARE(oblist, struct string *, struct symbol *) KHASH_DECLARE(oblist, struct string *, struct symbol *)

View File

@ -52,6 +52,12 @@ enum {
OP_STOP = 39 OP_STOP = 39
}; };
struct code {
int insn;
int a;
int b;
};
#if defined(__cplusplus) #if defined(__cplusplus)
} }
#endif #endif