first implementation of unrestricted static scoping

This commit is contained in:
Roberto Ierusalimschy
2001-09-07 14:39:10 -03:00
parent 4d0935ec0f
commit abdbe883a8
18 changed files with 412 additions and 187 deletions

11
lcode.c
View File

@@ -273,6 +273,11 @@ void luaK_dischargevars (FuncState *fs, expdesc *e) {
e->k = VNONRELOC;
break;
}
case VUPVAL: {
e->u.i.info = luaK_codeABC(fs, OP_GETUPVAL, 0, e->u.i.info, 0);
e->k = VRELOCABLE;
break;
}
case VGLOBAL: {
e->u.i.info = luaK_codeABc(fs, OP_GETGLOBAL, 0, e->u.i.info);
e->k = VRELOCABLE;
@@ -437,6 +442,12 @@ void luaK_storevar (FuncState *fs, expdesc *var, expdesc *exp) {
luaK_exp2reg(fs, exp, var->u.i.info);
break;
}
case VUPVAL: {
int e = luaK_exp2anyreg(fs, exp);
freereg(fs, e);
luaK_codeABC(fs, OP_SETUPVAL, e, var->u.i.info, 0);
break;
}
case VGLOBAL: {
int e = luaK_exp2anyreg(fs, exp);
freereg(fs, e);