better organization for fields in struct 'expdesc'

This commit is contained in:
Roberto Ierusalimschy
2010-07-02 17:42:40 -03:00
parent 7631c29b2f
commit 6a02bbe1e2
4 changed files with 67 additions and 62 deletions

View File

@@ -1,5 +1,5 @@
/*
** $Id: lparser.c,v 2.87 2010/05/31 16:08:55 roberto Exp roberto $
** $Id: lparser.c,v 2.88 2010/06/21 16:30:12 roberto Exp roberto $
** Lua Parser
** See Copyright Notice in lua.h
*/
@@ -138,7 +138,7 @@ static TString *str_checkname (LexState *ls) {
static void init_exp (expdesc *e, expkind k, int i) {
e->f = e->t = NO_JUMP;
e->k = k;
e->u.s.info = i;
e->u.info = i;
}
@@ -226,7 +226,7 @@ static int newupvalue (FuncState *fs, TString *name, expdesc *v) {
Upvaldesc, MAXUPVAL, "upvalues");
while (oldsize < f->sizeupvalues) f->upvalues[oldsize++].name = NULL;
f->upvalues[fs->nups].instack = (v->k == VLOCAL);
f->upvalues[fs->nups].idx = cast_byte(v->u.s.info);
f->upvalues[fs->nups].idx = cast_byte(v->u.info);
f->upvalues[fs->nups].name = name;
luaC_objbarrier(fs->L, f, name);
return fs->nups++;
@@ -518,7 +518,7 @@ static void recfield (LexState *ls, struct ConsControl *cc) {
checknext(ls, '=');
rkkey = luaK_exp2RK(fs, &key);
expr(ls, &val);
luaK_codeABC(fs, OP_SETTABLE, cc->t->u.s.info, rkkey, luaK_exp2RK(fs, &val));
luaK_codeABC(fs, OP_SETTABLE, cc->t->u.info, rkkey, luaK_exp2RK(fs, &val));
fs->freereg = reg; /* free registers */
}
@@ -528,7 +528,7 @@ static void closelistfield (FuncState *fs, struct ConsControl *cc) {
luaK_exp2nextreg(fs, &cc->v);
cc->v.k = VVOID;
if (cc->tostore == LFIELDS_PER_FLUSH) {
luaK_setlist(fs, cc->t->u.s.info, cc->na, cc->tostore); /* flush */
luaK_setlist(fs, cc->t->u.info, cc->na, cc->tostore); /* flush */
cc->tostore = 0; /* no more items pending */
}
}
@@ -538,13 +538,13 @@ static void lastlistfield (FuncState *fs, struct ConsControl *cc) {
if (cc->tostore == 0) return;
if (hasmultret(cc->v.k)) {
luaK_setmultret(fs, &cc->v);
luaK_setlist(fs, cc->t->u.s.info, cc->na, LUA_MULTRET);
luaK_setlist(fs, cc->t->u.info, cc->na, LUA_MULTRET);
cc->na--; /* do not count last expression (unknown number of elements) */
}
else {
if (cc->v.k != VVOID)
luaK_exp2nextreg(fs, &cc->v);
luaK_setlist(fs, cc->t->u.s.info, cc->na, cc->tostore);
luaK_setlist(fs, cc->t->u.info, cc->na, cc->tostore);
}
}
@@ -702,7 +702,7 @@ static void funcargs (LexState *ls, expdesc *f, int line) {
}
}
lua_assert(f->k == VNONRELOC);
base = f->u.s.info; /* base register for call */
base = f->u.info; /* base register for call */
if (hasmultret(args.k))
nparams = LUA_MULTRET; /* open call */
else {
@@ -976,20 +976,20 @@ static void check_conflict (LexState *ls, struct LHS_assign *lh, expdesc *v,
int conflict = 0;
for (; lh; lh = lh->prev) {
if (lh->v.k == ix) {
if (lh->v.u.s.info == v->u.s.info) { /* conflict? */
if (lh->v.u.ind.t == v->u.info) { /* conflict? */
conflict = 1;
lh->v.k = VINDEXED;
lh->v.u.s.info = extra; /* previous assignment will use safe copy */
lh->v.u.ind.t = extra; /* previous assignment will use safe copy */
}
if (v->k == VLOCAL && lh->v.u.s.aux == v->u.s.info) { /* conflict? */
if (v->k == VLOCAL && lh->v.u.ind.idx == v->u.info) { /* conflict? */
conflict = 1;
lua_assert(lh->v.k == VINDEXED);
lh->v.u.s.aux = extra; /* previous assignment will use safe copy */
lh->v.u.ind.idx = extra; /* previous assignment will use safe copy */
}
}
}
if (conflict) {
luaK_codeABC(fs, op, fs->freereg, v->u.s.info, 0); /* make copy */
luaK_codeABC(fs, op, fs->freereg, v->u.info, 0); /* make copy */
luaK_reserveregs(fs, 1);
}
}
@@ -1108,7 +1108,7 @@ static int exp1 (LexState *ls) {
expr(ls, &e);
luaK_exp2nextreg(ls->fs, &e);
lua_assert(e.k == VNONRELOC);
reg = e.u.s.info;
reg = e.u.info;
return reg;
}