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";
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:

View File

@ -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:

View File

@ -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,

View File

@ -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);

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_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;

View File

@ -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 *)

View File

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