aboutsummaryrefslogtreecommitdiff
path: root/lvm.c
diff options
context:
space:
mode:
Diffstat (limited to 'lvm.c')
-rw-r--r--lvm.c20
1 files changed, 7 insertions, 13 deletions
diff --git a/lvm.c b/lvm.c
index e4b1903e..485b9caa 100644
--- a/lvm.c
+++ b/lvm.c
@@ -1632,11 +1632,11 @@ void luaV_execute (lua_State *L, CallInfo *ci) {
1632 L->top = ra + b; /* top signals number of arguments */ 1632 L->top = ra + b; /* top signals number of arguments */
1633 /* else previous instruction set top */ 1633 /* else previous instruction set top */
1634 savepc(L); /* in case of errors */ 1634 savepc(L); /* in case of errors */
1635 if ((newci = luaD_precall(L, ra, nresults)) == NULL) 1635 if ((newci = luaD_precall(L, ra, nresults, 0)) == NULL)
1636 updatetrap(ci); /* C call; nothing else to be done */ 1636 updatetrap(ci); /* C call; nothing else to be done */
1637 else { /* Lua call: run function in this same C frame */ 1637 else { /* Lua call: run function in this same C frame */
1638 ci = newci; 1638 ci = newci;
1639 ci->callstatus = 0; /* call re-uses 'luaV_execute' */ 1639 ci->callstatus = 0;
1640 goto startfunc; 1640 goto startfunc;
1641 } 1641 }
1642 vmbreak; 1642 vmbreak;
@@ -1648,21 +1648,18 @@ void luaV_execute (lua_State *L, CallInfo *ci) {
1648 int delta = (nparams1) ? ci->u.l.nextraargs + nparams1 : 0; 1648 int delta = (nparams1) ? ci->u.l.nextraargs + nparams1 : 0;
1649 if (b != 0) 1649 if (b != 0)
1650 L->top = ra + b; 1650 L->top = ra + b;
1651 else /* previous instruction set top */ 1651 /* else previous instruction set top */
1652 b = cast_int(L->top - ra);
1653 savepc(ci); /* several calls here can raise errors */ 1652 savepc(ci); /* several calls here can raise errors */
1654 if (TESTARG_k(i)) { 1653 if (TESTARG_k(i)) {
1655 luaF_closeupval(L, base); /* close upvalues from current call */ 1654 luaF_closeupval(L, base); /* close upvalues from current call */
1656 lua_assert(L->tbclist < base); /* no pending tbc variables */ 1655 lua_assert(L->tbclist < base); /* no pending tbc variables */
1657 lua_assert(base == ci->func + 1); 1656 lua_assert(base == ci->func + 1);
1658 } 1657 }
1659 while (!ttisfunction(s2v(ra))) { /* not a function? */ 1658 if (luaD_precall(L, ra, LUA_MULTRET, delta + 1)) { /* Lua function? */
1660 luaD_tryfuncTM(L, ra); /* try '__call' metamethod */ 1659 ci->callstatus |= CIST_TAIL;
1661 b++; /* there is now one extra argument */ 1660 goto startfunc; /* execute the callee */
1662 checkstackGCp(L, 1, ra);
1663 } 1661 }
1664 if (!ttisLclosure(s2v(ra))) { /* C function? */ 1662 else { /* C function */
1665 luaD_precall(L, ra, LUA_MULTRET); /* call it */
1666 updatetrap(ci); 1663 updatetrap(ci);
1667 updatestack(ci); /* stack may have been relocated */ 1664 updatestack(ci); /* stack may have been relocated */
1668 ci->func -= delta; /* restore 'func' (if vararg) */ 1665 ci->func -= delta; /* restore 'func' (if vararg) */
@@ -1670,9 +1667,6 @@ void luaV_execute (lua_State *L, CallInfo *ci) {
1670 updatetrap(ci); /* 'luaD_poscall' can change hooks */ 1667 updatetrap(ci); /* 'luaD_poscall' can change hooks */
1671 goto ret; /* caller returns after the tail call */ 1668 goto ret; /* caller returns after the tail call */
1672 } 1669 }
1673 ci->func -= delta; /* restore 'func' (if vararg) */
1674 luaD_pretailcall(L, ci, ra, b); /* prepare call frame */
1675 goto startfunc; /* execute the callee */
1676 } 1670 }
1677 vmcase(OP_RETURN) { 1671 vmcase(OP_RETURN) {
1678 int n = GETARG_B(i) - 1; /* number of results */ 1672 int n = GETARG_B(i) - 1; /* number of results */