aboutsummaryrefslogtreecommitdiff
path: root/lvm.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2002-04-09 16:47:44 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2002-04-09 16:47:44 -0300
commit7b65328c8e89ecc999e47d00288bfa4cf6692cdc (patch)
tree4bff202763e7389ca40a44003703376d32eeaf78 /lvm.c
parentd2e05589d738c3a1b563879435d5cc0830719fd1 (diff)
downloadlua-7b65328c8e89ecc999e47d00288bfa4cf6692cdc.tar.gz
lua-7b65328c8e89ecc999e47d00288bfa4cf6692cdc.tar.bz2
lua-7b65328c8e89ecc999e47d00288bfa4cf6692cdc.zip
new semantics for `generic for' (with state)
Diffstat (limited to 'lvm.c')
-rw-r--r--lvm.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/lvm.c b/lvm.c
index 7f358cca..bb1b9852 100644
--- a/lvm.c
+++ b/lvm.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lvm.c,v 1.222 2002/03/22 16:54:31 roberto Exp roberto $ 2** $Id: lvm.c,v 1.223 2002/03/25 17:47:14 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*/
@@ -549,21 +549,21 @@ StkId luaV_execute (lua_State *L) {
549 break; 549 break;
550 } 550 }
551 case OP_TFORLOOP: { 551 case OP_TFORLOOP: {
552 setobj(ra+4, ra+2);
553 setobj(ra+3, ra+1);
554 setobj(ra+2, ra);
555 L->top = ra+5;
556 luaD_call(L, ra+2, GETARG_C(i) + 1);
557 L->top = L->ci->top;
558 if (ttype(ra+2) != LUA_TNIL) pc++; /* skip jump (keep looping) */
559 break;
560 }
561 case OP_TFORPREP: {
552 if (ttype(ra) == LUA_TTABLE) { 562 if (ttype(ra) == LUA_TTABLE) {
553 Table *t = hvalue(ra);
554 if (luaH_next(L, t, ra+1))
555 pc++; /* skip jump (keep looping) */
556 }
557 else if (ttype(ra) == LUA_TFUNCTION) {
558 setobj(ra+1, ra); 563 setobj(ra+1, ra);
559 L->top = ra+2; /* no arguments */ 564 setsvalue(ra, luaS_new(L, "next"));
560 luaD_call(L, ra+1, GETARG_C(i)); 565 luaV_gettable(L, gt(L), ra, ra);
561 L->top = L->ci->top;
562 if (ttype(ra+1) != LUA_TNIL)
563 pc++; /* skip jump (keep looping) */
564 } 566 }
565 else
566 luaD_error(L, "`for' generator must be a table or function");
567 break; 567 break;
568 } 568 }
569 case OP_SETLIST: 569 case OP_SETLIST: