s/cv_tbl/dirty_flags/g
This commit is contained in:
parent
d0602303e3
commit
2dc955aaf5
|
@ -15,8 +15,8 @@ typedef struct codegen_scope {
|
||||||
struct xhash *local_tbl;
|
struct xhash *local_tbl;
|
||||||
/* rest args variable is counted at localc */
|
/* rest args variable is counted at localc */
|
||||||
size_t argc, localc;
|
size_t argc, localc;
|
||||||
/* dirty flags: if local var i is captured, then cv_tbl[i] == 1 */
|
/* if local var i is captured, then dirty_flags[i] == 1 */
|
||||||
int *cv_tbl;
|
int *dirty_flags;
|
||||||
bool varg;
|
bool varg;
|
||||||
} codegen_scope;
|
} codegen_scope;
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ new_global_scope(pic_state *pic)
|
||||||
scope->local_tbl = pic->global_tbl;
|
scope->local_tbl = pic->global_tbl;
|
||||||
scope->argc = -1;
|
scope->argc = -1;
|
||||||
scope->localc = -1;
|
scope->localc = -1;
|
||||||
scope->cv_tbl = NULL;
|
scope->dirty_flags = NULL;
|
||||||
scope->varg = false;
|
scope->varg = false;
|
||||||
return scope;
|
return scope;
|
||||||
}
|
}
|
||||||
|
@ -67,7 +67,7 @@ new_local_scope(pic_state *pic, pic_value args, codegen_scope *scope)
|
||||||
}
|
}
|
||||||
new_scope->argc = i;
|
new_scope->argc = i;
|
||||||
new_scope->localc = l;
|
new_scope->localc = l;
|
||||||
new_scope->cv_tbl = (int *)pic_calloc(pic, i + l, sizeof(int));
|
new_scope->dirty_flags = (int *)pic_calloc(pic, i + l, sizeof(int));
|
||||||
|
|
||||||
return new_scope;
|
return new_scope;
|
||||||
}
|
}
|
||||||
|
@ -77,7 +77,7 @@ destroy_scope(pic_state *pic, codegen_scope *scope)
|
||||||
{
|
{
|
||||||
if (scope->up) {
|
if (scope->up) {
|
||||||
xh_destory(scope->local_tbl);
|
xh_destory(scope->local_tbl);
|
||||||
pic_free(pic, scope->cv_tbl);
|
pic_free(pic, scope->dirty_flags);
|
||||||
}
|
}
|
||||||
pic_free(pic, scope);
|
pic_free(pic, scope);
|
||||||
}
|
}
|
||||||
|
@ -194,8 +194,7 @@ codegen(codegen_state *state, pic_value obj, bool tailpos)
|
||||||
irep->clen++;
|
irep->clen++;
|
||||||
break;
|
break;
|
||||||
default: /* nonlocal */
|
default: /* nonlocal */
|
||||||
/* dirty flag */
|
s->dirty_flags[idx] = 1;
|
||||||
s->cv_tbl[idx] = 1;
|
|
||||||
/* at this stage, lref and cref are not distinguished */
|
/* at this stage, lref and cref are not distinguished */
|
||||||
FALLTHROUGH;
|
FALLTHROUGH;
|
||||||
case 0: /* local */
|
case 0: /* local */
|
||||||
|
@ -343,8 +342,7 @@ codegen(codegen_state *state, pic_value obj, bool tailpos)
|
||||||
irep->clen++;
|
irep->clen++;
|
||||||
break;
|
break;
|
||||||
default: /* nonlocal */
|
default: /* nonlocal */
|
||||||
/* dirty flag */
|
s->dirty_flags[idx] = 1;
|
||||||
s->cv_tbl[idx] = 1;
|
|
||||||
/* at this stage, lset and cset are not distinguished */
|
/* at this stage, lset and cset are not distinguished */
|
||||||
FALLTHROUGH;
|
FALLTHROUGH;
|
||||||
case 0: /* local */
|
case 0: /* local */
|
||||||
|
@ -619,13 +617,23 @@ codegen_lambda(codegen_state *state, pic_value obj)
|
||||||
/* fixup */
|
/* fixup */
|
||||||
for (i = 0; i < irep->clen; ++i) {
|
for (i = 0; i < irep->clen; ++i) {
|
||||||
struct pic_code c = irep->code[i];
|
struct pic_code c = irep->code[i];
|
||||||
if (c.insn == OP_CREF && c.u.c.depth == 0 && ! state->scope->cv_tbl[c.u.c.idx]) {
|
switch (c.insn) {
|
||||||
irep->code[i].insn = OP_LREF;
|
default:
|
||||||
irep->code[i].u.i = irep->code[i].u.c.idx;
|
/* pass */
|
||||||
|
break;
|
||||||
|
case OP_CREF:
|
||||||
|
if (c.u.c.depth == 0 && ! state->scope->dirty_flags[c.u.c.idx]) {
|
||||||
|
irep->code[i].insn = OP_LREF;
|
||||||
|
irep->code[i].u.i = irep->code[i].u.c.idx;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case OP_CSET:
|
||||||
|
if (c.u.c.depth == 0 && ! state->scope->dirty_flags[c.u.c.idx]) {
|
||||||
|
irep->code[i].insn = OP_LSET;
|
||||||
|
irep->code[i].u.i = irep->code[i].u.c.idx;
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
if (c.insn == OP_CSET && c.u.c.depth == 0 && ! state->scope->cv_tbl[c.u.c.idx]) {
|
|
||||||
irep->code[i].insn = OP_LSET;
|
|
||||||
irep->code[i].u.i = irep->code[i].u.c.idx;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue