MCPcopy Create free account
hub / github.com/ObEngine/ObEngine / luaV_finishOp

Function luaV_finishOp

extlibs/lua/src/lvm.c:805–857  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

803** finish execution of an opcode interrupted by a yield
804*/
805void luaV_finishOp (lua_State *L) {
806 CallInfo *ci = L->ci;
807 StkId base = ci->func + 1;
808 Instruction inst = *(ci->u.l.savedpc - 1); /* interrupted instruction */
809 OpCode op = GET_OPCODE(inst);
810 switch (op) { /* finish its execution */
811 case OP_MMBIN: case OP_MMBINI: case OP_MMBINK: {
812 setobjs2s(L, base + GETARG_A(*(ci->u.l.savedpc - 2)), --L->top);
813 break;
814 }
815 case OP_UNM: case OP_BNOT: case OP_LEN:
816 case OP_GETTABUP: case OP_GETTABLE: case OP_GETI:
817 case OP_GETFIELD: case OP_SELF: {
818 setobjs2s(L, base + GETARG_A(inst), --L->top);
819 break;
820 }
821 case OP_LT: case OP_LE:
822 case OP_LTI: case OP_LEI:
823 case OP_GTI: case OP_GEI:
824 case OP_EQ: { /* note that 'OP_EQI'/'OP_EQK' cannot yield */
825 int res = !l_isfalse(s2v(L->top - 1));
826 L->top--;
827#if defined(LUA_COMPAT_LT_LE)
828 if (ci->callstatus & CIST_LEQ) { /* "<=" using "<" instead? */
829 ci->callstatus ^= CIST_LEQ; /* clear mark */
830 res = !res; /* negate result */
831 }
832#endif
833 lua_assert(GET_OPCODE(*ci->u.l.savedpc) == OP_JMP);
834 if (res != GETARG_k(inst)) /* condition failed? */
835 ci->u.l.savedpc++; /* skip jump instruction */
836 break;
837 }
838 case OP_CONCAT: {
839 StkId top = L->top - 1; /* top when 'luaT_tryconcatTM' was called */
840 int a = GETARG_A(inst); /* first element to concatenate */
841 int total = cast_int(top - 1 - (base + a)); /* yet to concatenate */
842 setobjs2s(L, top - 2, top); /* put TM result in proper position */
843 if (total > 1) { /* are there elements to concat? */
844 L->top = top - 1; /* top is one after last element (at top-2) */
845 luaV_concat(L, total); /* concat them (may yield again) */
846 }
847 break;
848 }
849 default: {
850 /* only these other opcodes can yield */
851 lua_assert(op == OP_TFORCALL || op == OP_CALL ||
852 op == OP_TAILCALL || op == OP_SETTABUP || op == OP_SETTABLE ||
853 op == OP_SETI || op == OP_SETFIELD);
854 break;
855 }
856 }
857}
858
859
860

Callers 1

unrollFunction · 0.85

Calls 1

luaV_concatFunction · 0.85

Tested by

no test coverage detected