MCPcopy Create free account
hub / github.com/EmmyLua/EmmyLuaDebugger / luaV_finishOp

Function luaV_finishOp

third-party/lua-5.4.6/src/lvm.c:817–880  ·  view source on GitHub ↗

** finish execution of an opcode interrupted by a yield */

Source from the content-addressed store, hash-verified

815** finish execution of an opcode interrupted by a yield
816*/
817void luaV_finishOp (lua_State *L) {
818 CallInfo *ci = L->ci;
819 StkId base = ci->func.p + 1;
820 Instruction inst = *(ci->u.l.savedpc - 1); /* interrupted instruction */
821 OpCode op = GET_OPCODE(inst);
822 switch (op) { /* finish its execution */
823 case OP_MMBIN: case OP_MMBINI: case OP_MMBINK: {
824 setobjs2s(L, base + GETARG_A(*(ci->u.l.savedpc - 2)), --L->top.p);
825 break;
826 }
827 case OP_UNM: case OP_BNOT: case OP_LEN:
828 case OP_GETTABUP: case OP_GETTABLE: case OP_GETI:
829 case OP_GETFIELD: case OP_SELF: {
830 setobjs2s(L, base + GETARG_A(inst), --L->top.p);
831 break;
832 }
833 case OP_LT: case OP_LE:
834 case OP_LTI: case OP_LEI:
835 case OP_GTI: case OP_GEI:
836 case OP_EQ: { /* note that 'OP_EQI'/'OP_EQK' cannot yield */
837 int res = !l_isfalse(s2v(L->top.p - 1));
838 L->top.p--;
839#if defined(LUA_COMPAT_LT_LE)
840 if (ci->callstatus & CIST_LEQ) { /* "<=" using "<" instead? */
841 ci->callstatus ^= CIST_LEQ; /* clear mark */
842 res = !res; /* negate result */
843 }
844#endif
845 lua_assert(GET_OPCODE(*ci->u.l.savedpc) == OP_JMP);
846 if (res != GETARG_k(inst)) /* condition failed? */
847 ci->u.l.savedpc++; /* skip jump instruction */
848 break;
849 }
850 case OP_CONCAT: {
851 StkId top = L->top.p - 1; /* top when 'luaT_tryconcatTM' was called */
852 int a = GETARG_A(inst); /* first element to concatenate */
853 int total = cast_int(top - 1 - (base + a)); /* yet to concatenate */
854 setobjs2s(L, top - 2, top); /* put TM result in proper position */
855 L->top.p = top - 1; /* top is one after last element (at top-2) */
856 luaV_concat(L, total); /* concat them (may yield again) */
857 break;
858 }
859 case OP_CLOSE: { /* yielded closing variables */
860 ci->u.l.savedpc--; /* repeat instruction to close other vars. */
861 break;
862 }
863 case OP_RETURN: { /* yielded closing variables */
864 StkId ra = base + GETARG_A(inst);
865 /* adjust top to signal correct number of returns, in case the
866 return is "up to top" ('isIT') */
867 L->top.p = ra + ci->u2.nres;
868 /* repeat instruction to close other vars. and complete the return */
869 ci->u.l.savedpc--;
870 break;
871 }
872 default: {
873 /* only these other opcodes can yield */
874 lua_assert(op == OP_TFORCALL || op == OP_CALL ||

Callers 1

unrollFunction · 0.70

Calls 1

luaV_concatFunction · 0.70

Tested by

no test coverage detected