aboutsummaryrefslogtreecommitdiff
path: root/src/3rdParty/lua/lvm.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/3rdParty/lua/lvm.c')
-rw-r--r--src/3rdParty/lua/lvm.c41
1 files changed, 20 insertions, 21 deletions
diff --git a/src/3rdParty/lua/lvm.c b/src/3rdParty/lua/lvm.c
index c9729bc..c84a665 100644
--- a/src/3rdParty/lua/lvm.c
+++ b/src/3rdParty/lua/lvm.c
@@ -766,7 +766,7 @@ lua_Number luaV_modf (lua_State *L, lua_Number m, lua_Number n) {
766/* 766/*
767** Shift left operation. (Shift right just negates 'y'.) 767** Shift left operation. (Shift right just negates 'y'.)
768*/ 768*/
769#define luaV_shiftr(x,y) luaV_shiftl(x,-(y)) 769#define luaV_shiftr(x,y) luaV_shiftl(x,intop(-, 0, y))
770 770
771lua_Integer luaV_shiftl (lua_Integer x, lua_Integer y) { 771lua_Integer luaV_shiftl (lua_Integer x, lua_Integer y) {
772 if (y < 0) { /* shift right? */ 772 if (y < 0) { /* shift right? */
@@ -847,10 +847,19 @@ void luaV_finishOp (lua_State *L) {
847 luaV_concat(L, total); /* concat them (may yield again) */ 847 luaV_concat(L, total); /* concat them (may yield again) */
848 break; 848 break;
849 } 849 }
850 case OP_CLOSE: case OP_RETURN: { /* yielded closing variables */ 850 case OP_CLOSE: { /* yielded closing variables */
851 ci->u.l.savedpc--; /* repeat instruction to close other vars. */ 851 ci->u.l.savedpc--; /* repeat instruction to close other vars. */
852 break; 852 break;
853 } 853 }
854 case OP_RETURN: { /* yielded closing variables */
855 StkId ra = base + GETARG_A(inst);
856 /* adjust top to signal correct number of returns, in case the
857 return is "up to top" ('isIT') */
858 L->top = ra + ci->u2.nres;
859 /* repeat instruction to close other vars. and complete the return */
860 ci->u.l.savedpc--;
861 break;
862 }
854 default: { 863 default: {
855 /* only these other opcodes can yield */ 864 /* only these other opcodes can yield */
856 lua_assert(op == OP_TFORCALL || op == OP_CALL || 865 lua_assert(op == OP_TFORCALL || op == OP_CALL ||
@@ -1156,8 +1165,10 @@ void luaV_execute (lua_State *L, CallInfo *ci) {
1156 Instruction i; /* instruction being executed */ 1165 Instruction i; /* instruction being executed */
1157 StkId ra; /* instruction's A register */ 1166 StkId ra; /* instruction's A register */
1158 vmfetch(); 1167 vmfetch();
1159// low-level line tracing for debugging Lua 1168 #if 0
1160// printf("line: %d\n", luaG_getfuncline(cl->p, pcRel(pc, cl->p))); 1169 /* low-level line tracing for debugging Lua */
1170 printf("line: %d\n", luaG_getfuncline(cl->p, pcRel(pc, cl->p)));
1171 #endif
1161 lua_assert(base == ci->func + 1); 1172 lua_assert(base == ci->func + 1);
1162 lua_assert(base <= L->top && L->top < L->stack_last); 1173 lua_assert(base <= L->top && L->top < L->stack_last);
1163 /* invalidate top for instructions not expecting it */ 1174 /* invalidate top for instructions not expecting it */
@@ -1625,7 +1636,6 @@ void luaV_execute (lua_State *L, CallInfo *ci) {
1625 updatetrap(ci); /* C call; nothing else to be done */ 1636 updatetrap(ci); /* C call; nothing else to be done */
1626 else { /* Lua call: run function in this same C frame */ 1637 else { /* Lua call: run function in this same C frame */
1627 ci = newci; 1638 ci = newci;
1628 ci->callstatus = 0; /* call re-uses 'luaV_execute' */
1629 goto startfunc; 1639 goto startfunc;
1630 } 1640 }
1631 vmbreak; 1641 vmbreak;
@@ -1637,31 +1647,19 @@ void luaV_execute (lua_State *L, CallInfo *ci) {
1637 int delta = (nparams1) ? ci->u.l.nextraargs + nparams1 : 0; 1647 int delta = (nparams1) ? ci->u.l.nextraargs + nparams1 : 0;
1638 if (b != 0) 1648 if (b != 0)
1639 L->top = ra + b; 1649 L->top = ra + b;
1640 else /* previous instruction set top */ 1650 /* else previous instruction set top */
1641 b = cast_int(L->top - ra);
1642 savepc(ci); /* several calls here can raise errors */ 1651 savepc(ci); /* several calls here can raise errors */
1643 if (TESTARG_k(i)) { 1652 if (TESTARG_k(i)) {
1644 luaF_closeupval(L, base); /* close upvalues from current call */ 1653 luaF_closeupval(L, base); /* close upvalues from current call */
1645 lua_assert(L->tbclist < base); /* no pending tbc variables */ 1654 lua_assert(L->tbclist < base); /* no pending tbc variables */
1646 lua_assert(base == ci->func + 1); 1655 lua_assert(base == ci->func + 1);
1647 } 1656 }
1648 while (!ttisfunction(s2v(ra))) { /* not a function? */ 1657 if (luaD_precall(L, ra, delta2retdel(delta))) /* Lua function? */
1649 luaD_tryfuncTM(L, ra); /* try '__call' metamethod */ 1658 goto startfunc; /* execute the callee */
1650 b++; /* there is now one extra argument */ 1659 else { /* C function */
1651 checkstackGCp(L, 1, ra);
1652 }
1653 if (!ttisLclosure(s2v(ra))) { /* C function? */
1654 luaD_precall(L, ra, LUA_MULTRET); /* call it */
1655 updatetrap(ci); 1660 updatetrap(ci);
1656 updatestack(ci); /* stack may have been relocated */
1657 ci->func -= delta; /* restore 'func' (if vararg) */
1658 luaD_poscall(L, ci, cast_int(L->top - ra)); /* finish caller */
1659 updatetrap(ci); /* 'luaD_poscall' can change hooks */
1660 goto ret; /* caller returns after the tail call */ 1661 goto ret; /* caller returns after the tail call */
1661 } 1662 }
1662 ci->func -= delta; /* restore 'func' (if vararg) */
1663 luaD_pretailcall(L, ci, ra, b); /* prepare call frame */
1664 goto startfunc; /* execute the callee */
1665 } 1663 }
1666 vmcase(OP_RETURN) { 1664 vmcase(OP_RETURN) {
1667 int n = GETARG_B(i) - 1; /* number of results */ 1665 int n = GETARG_B(i) - 1; /* number of results */
@@ -1670,6 +1668,7 @@ void luaV_execute (lua_State *L, CallInfo *ci) {
1670 n = cast_int(L->top - ra); /* get what is available */ 1668 n = cast_int(L->top - ra); /* get what is available */
1671 savepc(ci); 1669 savepc(ci);
1672 if (TESTARG_k(i)) { /* may there be open upvalues? */ 1670 if (TESTARG_k(i)) { /* may there be open upvalues? */
1671 ci->u2.nres = n; /* save number of returns */
1673 if (L->top < ci->top) 1672 if (L->top < ci->top)
1674 L->top = ci->top; 1673 L->top = ci->top;
1675 luaF_close(L, base, CLOSEKTOP, 1); 1674 luaF_close(L, base, CLOSEKTOP, 1);