diff options
Diffstat (limited to 'lvm.c')
-rw-r--r-- | lvm.c | 28 |
1 files changed, 27 insertions, 1 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lvm.c,v 2.324 2017/12/04 17:41:30 roberto Exp roberto $ | 2 | ** $Id: lvm.c,v 2.326 2017/12/18 17:49:31 roberto Exp $ |
3 | ** Lua virtual machine | 3 | ** Lua virtual machine |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -1564,6 +1564,32 @@ void luaV_execute (lua_State *L, CallInfo *ci) { | |||
1564 | } | 1564 | } |
1565 | return; | 1565 | return; |
1566 | } | 1566 | } |
1567 | vmcase(OP_FORLOOP1) { | ||
1568 | lua_Integer idx = intop(+, ivalue(vra), 1); /* increment index */ | ||
1569 | lua_Integer limit = ivalue(s2v(ra + 1)); | ||
1570 | if (idx <= limit) { | ||
1571 | pc -= GETARG_Bx(i); /* jump back */ | ||
1572 | chgivalue(vra, idx); /* update internal index... */ | ||
1573 | setivalue(s2v(ra + 3), idx); /* ...and external index */ | ||
1574 | } | ||
1575 | updatetrap(ci); | ||
1576 | vmbreak; | ||
1577 | } | ||
1578 | vmcase(OP_FORPREP1) { | ||
1579 | TValue *init = vra; | ||
1580 | TValue *plimit = s2v(ra + 1); | ||
1581 | lua_Integer ilimit, initv; | ||
1582 | int stopnow; | ||
1583 | if (!forlimit(plimit, &ilimit, 1, &stopnow)) { | ||
1584 | savepc(L); /* for the error message */ | ||
1585 | luaG_runerror(L, "'for' limit must be a number"); | ||
1586 | } | ||
1587 | initv = (stopnow ? 0 : ivalue(init)); | ||
1588 | setivalue(plimit, ilimit); | ||
1589 | setivalue(init, intop(-, initv, 1)); | ||
1590 | pc += GETARG_Bx(i); | ||
1591 | vmbreak; | ||
1592 | } | ||
1567 | vmcase(OP_FORLOOP) { | 1593 | vmcase(OP_FORLOOP) { |
1568 | if (ttisinteger(vra)) { /* integer loop? */ | 1594 | if (ttisinteger(vra)) { /* integer loop? */ |
1569 | lua_Integer step = ivalue(s2v(ra + 2)); | 1595 | lua_Integer step = ivalue(s2v(ra + 2)); |