mirror of
https://github.com/LuaJIT/LuaJIT.git
synced 2025-02-07 23:24:09 +00:00
Fix predict_next() in parser (for real now).
Reported by Sergey Kaplun. #1226 #1054
This commit is contained in:
parent
f2a1cd4328
commit
f602f0154b
@ -2527,11 +2527,9 @@ static void parse_for_num(LexState *ls, GCstr *varname, BCLine line)
|
|||||||
*/
|
*/
|
||||||
static int predict_next(LexState *ls, FuncState *fs, BCPos pc)
|
static int predict_next(LexState *ls, FuncState *fs, BCPos pc)
|
||||||
{
|
{
|
||||||
BCIns ins;
|
BCIns ins = fs->bcbase[pc].ins;
|
||||||
GCstr *name;
|
GCstr *name;
|
||||||
cTValue *o;
|
cTValue *o;
|
||||||
if (pc >= fs->bclim) return 0;
|
|
||||||
ins = fs->bcbase[pc].ins;
|
|
||||||
switch (bc_op(ins)) {
|
switch (bc_op(ins)) {
|
||||||
case BC_MOV:
|
case BC_MOV:
|
||||||
if (bc_d(ins) >= fs->nactvar) return 0;
|
if (bc_d(ins) >= fs->nactvar) return 0;
|
||||||
@ -2579,7 +2577,7 @@ static void parse_for_iter(LexState *ls, GCstr *indexname)
|
|||||||
line = ls->linenumber;
|
line = ls->linenumber;
|
||||||
assign_adjust(ls, 3, expr_list(ls, &e), &e);
|
assign_adjust(ls, 3, expr_list(ls, &e), &e);
|
||||||
bcreg_bump(fs, 3); /* The iterator needs another 3 slots (func + 2 args). */
|
bcreg_bump(fs, 3); /* The iterator needs another 3 slots (func + 2 args). */
|
||||||
isnext = (nvars <= 5 && predict_next(ls, fs, exprpc));
|
isnext = (nvars <= 5 && fs->pc > exprpc && predict_next(ls, fs, exprpc));
|
||||||
var_add(ls, 3); /* Hidden control variables. */
|
var_add(ls, 3); /* Hidden control variables. */
|
||||||
lex_check(ls, TK_do);
|
lex_check(ls, TK_do);
|
||||||
loop = bcemit_AJ(fs, isnext ? BC_ISNEXT : BC_JMP, base, NO_JMP);
|
loop = bcemit_AJ(fs, isnext ? BC_ISNEXT : BC_JMP, base, NO_JMP);
|
||||||
|
Loading…
Reference in New Issue
Block a user