better implementation for list "for"

This commit is contained in:
Roberto Ierusalimschy
2001-01-29 11:14:49 -02:00
parent ca1f28b829
commit caf01b5bfa
5 changed files with 39 additions and 20 deletions

View File

@@ -1,5 +1,5 @@
/*
** $Id: lparser.c,v 1.124 2001/01/15 16:13:24 roberto Exp roberto $
** $Id: lparser.c,v 1.125 2001/01/19 13:20:30 roberto Exp roberto $
** LL(1) Parser and code generator for Lua
** See Copyright Notice in lua.h
*/
@@ -890,9 +890,10 @@ static void forlist (LexState *ls, TString *indexname) {
next(ls); /* skip `in' */
exp1(ls); /* table */
new_localvarstr(ls, "(table)", 0);
new_localvar(ls, indexname, 1);
new_localvar(ls, valname, 2);
forbody(ls, 3, OP_LFORPREP, OP_LFORLOOP);
new_localvarstr(ls, "(index)", 1);
new_localvar(ls, indexname, 2);
new_localvar(ls, valname, 3);
forbody(ls, 4, OP_LFORPREP, OP_LFORLOOP);
}