diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2002-03-08 16:10:32 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2002-03-08 16:10:32 -0300 |
| commit | bd8b9c94b38ddaa3cd7324cbca98571633e03f91 (patch) | |
| tree | 599551d4713dc039c2603e1830cc13acc9552779 /lvm.c | |
| parent | 4db04555f06b90f3b2cda96c2f4aaeb78266ea86 (diff) | |
| download | lua-bd8b9c94b38ddaa3cd7324cbca98571633e03f91.tar.gz lua-bd8b9c94b38ddaa3cd7324cbca98571633e03f91.tar.bz2 lua-bd8b9c94b38ddaa3cd7324cbca98571633e03f91.zip | |
generic for (with any number of control variables)
Diffstat (limited to 'lvm.c')
| -rw-r--r-- | lvm.c | 15 |
1 files changed, 6 insertions, 9 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lvm.c,v 1.217 2002/03/04 15:40:04 roberto Exp roberto $ | 2 | ** $Id: lvm.c,v 1.218 2002/03/04 21:33:09 roberto Exp roberto $ |
| 3 | ** Lua virtual machine | 3 | ** Lua virtual machine |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -560,24 +560,21 @@ StkId luaV_execute (lua_State *L) { | |||
| 560 | break; | 560 | break; |
| 561 | } | 561 | } |
| 562 | case OP_TFORLOOP: { | 562 | case OP_TFORLOOP: { |
| 563 | int j = GETARG_sBc(i); | ||
| 564 | int loop = 0; | ||
| 565 | pc += j; /* jump back before tests (for error messages) */ | ||
| 566 | if (ttype(ra) == LUA_TTABLE) { | 563 | if (ttype(ra) == LUA_TTABLE) { |
| 567 | Table *t = hvalue(ra); | 564 | Table *t = hvalue(ra); |
| 568 | loop = luaH_next(L, t, ra+1); | 565 | if (luaH_next(L, t, ra+1)) |
| 566 | pc++; /* skip jump (keep looping) */ | ||
| 569 | } | 567 | } |
| 570 | else if (ttype(ra) == LUA_TFUNCTION) { | 568 | else if (ttype(ra) == LUA_TFUNCTION) { |
| 571 | setobj(ra+1, ra); | 569 | setobj(ra+1, ra); |
| 572 | L->top = ra+2; /* no arguments */ | 570 | L->top = ra+2; /* no arguments */ |
| 573 | luaD_call(L, ra+1, 2); | 571 | luaD_call(L, ra+1, GETARG_C(i)); |
| 574 | L->top = L->ci->top; | 572 | L->top = L->ci->top; |
| 575 | loop = (ttype(ra+1) != LUA_TNIL); | 573 | if (ttype(ra+1) != LUA_TNIL) |
| 574 | pc++; /* skip jump (keep looping) */ | ||
| 576 | } | 575 | } |
| 577 | else | 576 | else |
| 578 | luaD_error(L, "`for' generator must be a table or function"); | 577 | luaD_error(L, "`for' generator must be a table or function"); |
| 579 | if (!loop) | ||
| 580 | pc -= j; /* undo jump */ | ||
| 581 | break; | 578 | break; |
| 582 | } | 579 | } |
| 583 | case OP_SETLIST: | 580 | case OP_SETLIST: |
