s/env.values/env.regs/g

This commit is contained in:
Yuichi Nishiwaki 2014-03-23 12:45:36 +09:00
parent 25e5b51c1c
commit 93414fac52
6 changed files with 19 additions and 19 deletions

View File

@ -17,8 +17,8 @@ struct pic_func {
struct pic_env {
PIC_OBJECT_HEADER
pic_value *values;
int valuec;
pic_value *regs;
int regc;
struct pic_env *up;
pic_value storage[];
};

View File

@ -208,7 +208,7 @@ cont_call(pic_state *pic)
proc = pic_get_proc(pic);
pic_get_args(pic, "*", &argc, &argv);
cont = (struct pic_cont *)pic_ptr(proc->env->values[0]);
cont = (struct pic_cont *)pic_ptr(pic_proc_cv_ref(pic, proc, 0));
cont->results = pic_list_by_array(pic, argc, argv);
/* execute guard handlers */

View File

@ -362,8 +362,8 @@ gc_mark_object(pic_state *pic, struct pic_object *obj)
struct pic_env *env = (struct pic_env *)obj;
int i;
for (i = 0; i < env->valuec; ++i) {
gc_mark(pic, env->values[i]);
for (i = 0; i < env->regc; ++i) {
gc_mark(pic, env->regs[i]);
}
if (env->up) {
gc_mark_object(pic, (struct pic_object *)env->up);

View File

@ -41,8 +41,8 @@ pic_proc_cv_init(pic_state *pic, struct pic_proc *proc, size_t cv_size)
pic_error(pic, "env slot already in use");
}
env = (struct pic_env *)pic_obj_alloc(pic, sizeof(struct pic_env), PIC_TT_ENV);
env->valuec = cv_size;
env->values = (pic_value *)pic_calloc(pic, cv_size, sizeof(pic_value));
env->regc = cv_size;
env->regs = (pic_value *)pic_calloc(pic, cv_size, sizeof(pic_value));
env->up = NULL;
proc->env = env;
@ -52,7 +52,7 @@ int
pic_proc_cv_size(pic_state *pic, struct pic_proc *proc)
{
UNUSED(pic);
return proc->env ? proc->env->valuec : 0;
return proc->env ? proc->env->regc : 0;
}
pic_value
@ -61,7 +61,7 @@ pic_proc_cv_ref(pic_state *pic, struct pic_proc *proc, size_t i)
if (proc->env == NULL) {
pic_error(pic, "no closed env");
}
return proc->env->values[i];
return proc->env->regs[i];
}
void
@ -70,7 +70,7 @@ pic_proc_cv_set(pic_state *pic, struct pic_proc *proc, size_t i, pic_value v)
if (proc->env == NULL) {
pic_error(pic, "no closed env");
}
proc->env->values[i] = v;
proc->env->regs[i] = v;
}
static pic_value

View File

@ -80,11 +80,11 @@ var_call(pic_state *pic)
c = pic_get_args(pic, "|o", &v);
if (c == 0) {
var = pic_var_ptr(proc->env->values[0]);
var = pic_var_ptr(proc->env->regs[0]);
return pic_var_ref(pic, var);
}
else if (c == 1) {
var = pic_var_ptr(proc->env->values[0]);
var = pic_var_ptr(proc->env->regs[0]);
pic_var_set(pic, var, v);
return pic_none_value();

View File

@ -431,10 +431,10 @@ vm_tear_off(pic_state *pic)
int i;
env = pic->ci->env;
for (i = 0; i < env->valuec; ++i) {
env->storage[i] = env->values[i];
for (i = 0; i < env->regc; ++i) {
env->storage[i] = env->regs[i];
}
env->values = env->storage;
env->regs = env->storage;
}
pic_value
@ -600,7 +600,7 @@ pic_apply(pic_state *pic, struct pic_proc *proc, pic_value argv)
while (depth--) {
env = env->up;
}
PUSH(env->values[c.u.r.idx]);
PUSH(env->regs[c.u.r.idx]);
NEXT;
}
CASE(OP_CSET) {
@ -611,7 +611,7 @@ pic_apply(pic_state *pic, struct pic_proc *proc, pic_value argv)
while (depth--) {
env = env->up;
}
env->values[c.u.r.idx] = POP();
env->regs[c.u.r.idx] = POP();
NEXT;
}
CASE(OP_JMP) {
@ -722,8 +722,8 @@ pic_apply(pic_state *pic, struct pic_proc *proc, pic_value argv)
/* prepare env */
ci->env = (struct pic_env *)pic_obj_alloc(pic, offsetof(struct pic_env, storage) + sizeof(pic_value) * irep->capturec, PIC_TT_ENV);
ci->env->up = proc->env;
ci->env->valuec = irep->capturec;
ci->env->values = ci->fp + irep->argc + irep->localc;
ci->env->regc = irep->capturec;
ci->env->regs = ci->fp + irep->argc + irep->localc;
pic->ip = irep->code;
pic_gc_arena_restore(pic, ai);