MCPcopy Create free account
hub / github.com/F-Stack/f-stack / lua_pcallk

Function lua_pcallk

freebsd/contrib/openzfs/module/lua/lapi.c:925–967  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

923
924
925LUA_API int lua_pcallk (lua_State *L, int nargs, int nresults, int errfunc,
926 int ctx, lua_CFunction k) {
927 struct CallS c;
928 int status;
929 ptrdiff_t func;
930 lua_lock(L);
931 api_check(L, k == NULL || !isLua(L->ci),
932 "cannot use continuations inside hooks");
933 api_checknelems(L, nargs+1);
934 api_check(L, L->status == LUA_OK, "cannot do calls on non-normal thread");
935 checkresults(L, nargs, nresults);
936 if (errfunc == 0)
937 func = 0;
938 else {
939 StkId o = index2addr(L, errfunc);
940 api_checkstackindex(L, errfunc, o);
941 func = savestack(L, o);
942 }
943 c.func = L->top - (nargs+1); /* function to be called */
944 if (k == NULL || L->nny > 0) { /* no continuation or no yieldable? */
945 c.nresults = nresults; /* do a 'conventional' protected call */
946 status = luaD_pcall(L, f_call, &c, savestack(L, c.func), func);
947 }
948 else { /* prepare continuation (call is already protected by 'resume') */
949 CallInfo *ci = L->ci;
950 ci->u.c.k = k; /* save continuation */
951 ci->u.c.ctx = ctx; /* save context */
952 /* save information for error recovery */
953 ci->extra = savestack(L, c.func);
954 ci->u.c.old_allowhook = L->allowhook;
955 ci->u.c.old_errfunc = L->errfunc;
956 L->errfunc = func;
957 /* mark that function may do error recovery */
958 ci->callstatus |= CIST_YPCALL;
959 luaD_call(L, c.func, nresults, 1); /* do the call */
960 ci->callstatus &= ~CIST_YPCALL;
961 L->errfunc = ci->u.c.old_errfunc;
962 status = LUA_OK; /* if it is here, there were no errors */
963 }
964 adjustresults(L, nresults);
965 lua_unlock(L);
966 return status;
967}
968
969
970LUA_API int lua_load (lua_State *L, lua_Reader reader, void *data,

Callers

nothing calls this directly

Calls 3

index2addrFunction · 0.85
luaD_pcallFunction · 0.70
luaD_callFunction · 0.70

Tested by

no test coverage detected