diff --git a/lcode.c b/lcode.c index 1c1517bf..5413058e 100644 --- a/lcode.c +++ b/lcode.c @@ -1,5 +1,5 @@ /* -** $Id: lcode.c,v 1.73 2001/06/08 19:00:57 roberto Exp roberto $ +** $Id: lcode.c,v 1.74 2001/06/11 14:56:42 roberto Exp roberto $ ** Code generator for Lua ** See Copyright Notice in lua.h */ @@ -271,7 +271,7 @@ void luaK_setcallreturns (FuncState *fs, expdesc *e, int nresults) { } -static void dischargevars (FuncState *fs, expdesc *e) { +void luaK_dischargevars (FuncState *fs, expdesc *e) { switch (e->k) { case VLOCAL: { e->k = VNONRELOC; @@ -325,7 +325,7 @@ static void dischargejumps (FuncState *fs, expdesc *e, int reg) { static void discharge2reg (FuncState *fs, expdesc *e, int reg) { - dischargevars(fs, e); + luaK_dischargevars(fs, e); switch (e->k) { case VNIL: { luaK_nil(fs, reg, 1); @@ -392,7 +392,7 @@ static void luaK_exp2reg (FuncState *fs, expdesc *e, int reg) { void luaK_exp2nextreg (FuncState *fs, expdesc *e) { int reg; - dischargevars(fs, e); + luaK_dischargevars(fs, e); freeexp(fs, e); reg = fs->freereg; luaK_reserveregs(fs, 1); @@ -401,7 +401,7 @@ void luaK_exp2nextreg (FuncState *fs, expdesc *e) { int luaK_exp2anyreg (FuncState *fs, expdesc *e) { - dischargevars(fs, e); + luaK_dischargevars(fs, e); if (e->k == VNONRELOC) { if (!hasjumps(e)) return e->u.i.info; /* exp is already in a register */ if (e->u.i.info >= fs->nactloc) { /* reg. is not a local? */ @@ -418,7 +418,7 @@ void luaK_exp2val (FuncState *fs, expdesc *e) { if (hasjumps(e)) luaK_exp2anyreg(fs, e); else - dischargevars(fs, e); + luaK_dischargevars(fs, e); } @@ -510,7 +510,7 @@ static int jumponcond (FuncState *fs, expdesc *e, OpCode op) { void luaK_goiftrue (FuncState *fs, expdesc *e) { int pc; /* pc of last jump */ - dischargevars(fs, e); + luaK_dischargevars(fs, e); switch (e->k) { case VK: case VNUMBER: { pc = NO_JUMP; /* always true; do nothing */ @@ -544,7 +544,7 @@ void luaK_goiftrue (FuncState *fs, expdesc *e) { static void luaK_goiffalse (FuncState *fs, expdesc *e) { int pc; /* pc of last jump */ - dischargevars(fs, e); + luaK_dischargevars(fs, e); switch (e->k) { case VNIL: { pc = NO_JUMP; /* always false; do nothing */ @@ -573,7 +573,7 @@ static void luaK_goiffalse (FuncState *fs, expdesc *e) { static void codenot (FuncState *fs, expdesc *e) { - dischargevars(fs, e); + luaK_dischargevars(fs, e); switch (e->k) { case VNIL: { e->u.n = 1; @@ -680,14 +680,14 @@ void luaK_posfix (FuncState *fs, BinOpr op, expdesc *e1, expdesc *e2) { switch (op) { case OPR_AND: { lua_assert(e1->t == NO_JUMP); /* list must be closed */ - dischargevars(fs, e2); + luaK_dischargevars(fs, e2); luaK_concat(fs, &e1->f, e2->f); e1->k = e2->k; e1->u = e2->u; e1->t = e2->t; break; } case OPR_OR: { lua_assert(e1->f == NO_JUMP); /* list must be closed */ - dischargevars(fs, e2); + luaK_dischargevars(fs, e2); luaK_concat(fs, &e1->t, e2->t); e1->k = e2->k; e1->u = e2->u; e1->f = e2->f; break; diff --git a/lcode.h b/lcode.h index e82d1b17..82e77388 100644 --- a/lcode.h +++ b/lcode.h @@ -1,5 +1,5 @@ /* -** $Id: lcode.h,v 1.21 2001/02/23 17:17:25 roberto Exp roberto $ +** $Id: lcode.h,v 1.22 2001/06/05 18:17:01 roberto Exp roberto $ ** Code generator for Lua ** See Copyright Notice in lua.h */ @@ -44,6 +44,7 @@ int luaK_codeABC (FuncState *fs, OpCode o, int A, int B, int C); void luaK_nil (FuncState *fs, int from, int n); void luaK_reserveregs (FuncState *fs, int n); int luaK_stringk (FuncState *fs, TString *s); +void luaK_dischargevars (FuncState *fs, expdesc *e); int luaK_exp2anyreg (FuncState *fs, expdesc *e); void luaK_exp2nextreg (FuncState *fs, expdesc *e); void luaK_exp2val (FuncState *fs, expdesc *e); diff --git a/lparser.c b/lparser.c index b077c324..fa6ada93 100644 --- a/lparser.c +++ b/lparser.c @@ -1,5 +1,5 @@ /* -** $Id: lparser.c,v 1.147 2001/06/08 19:00:57 roberto Exp roberto $ +** $Id: lparser.c,v 1.148 2001/06/11 14:56:42 roberto Exp roberto $ ** LL(1) Parser and code generator for Lua ** See Copyright Notice in lua.h */ @@ -636,6 +636,7 @@ static void primaryexp (LexState *ls, expdesc *v) { next(ls); expr(ls, v); check(ls, l_c(')')); + luaK_dischargevars(ls->fs, v); return; } case TK_NAME: {