| 1002 | |
| 1003 | |
| 1004 | LUA_API void lua_callk (lua_State *L, int nargs, int nresults, |
| 1005 | lua_KContext ctx, lua_KFunction k) { |
| 1006 | StkId func; |
| 1007 | lua_lock(L); |
| 1008 | api_check(L, k == NULL || !isLua(L->ci), |
| 1009 | "cannot use continuations inside hooks"); |
| 1010 | api_checknelems(L, nargs+1); |
| 1011 | api_check(L, L->status == LUA_OK, "cannot do calls on non-normal thread"); |
| 1012 | checkresults(L, nargs, nresults); |
| 1013 | func = L->top.p - (nargs+1); |
| 1014 | if (k != NULL && yieldable(L)) { /* need to prepare continuation? */ |
| 1015 | L->ci->u.c.k = k; /* save continuation */ |
| 1016 | L->ci->u.c.ctx = ctx; /* save context */ |
| 1017 | luaD_call(L, func, nresults); /* do the call */ |
| 1018 | } |
| 1019 | else /* no continuation or no yieldable */ |
| 1020 | luaD_callnoyield(L, func, nresults); /* just do the call */ |
| 1021 | adjustresults(L, nresults); |
| 1022 | lua_unlock(L); |
| 1023 | } |
| 1024 | |
| 1025 | |
| 1026 |
no test coverage detected