I'm reading the source code of lua515, there is some code then I don't understand yet
int luaK_exp2anyreg (FuncState *fs, expdesc *e) {
luaK_dischargevars(fs, e);
if (e->k == VNONRELOC) {
if (!hasjumps(e)) return e->
u.s.info; /* exp is already in a register */
if (e->
u.s.info >= fs->nactvar) { /* reg. is not a local? */
exp2reg(fs, e, e->
u.s.info); /* put value on it */
return e->
u.s.info;
}
}
luaK_exp2nextreg(fs, e); /* default */
return e->
u.s.info;
}