| 887 | |
| 888 | |
| 889 | LUA_API void lua_callk (lua_State *L, int nargs, int nresults, int ctx, |
| 890 | lua_CFunction k) { |
| 891 | StkId func; |
| 892 | lua_lock(L); |
| 893 | api_check(L, k == NULL || !isLua(L->ci), |
| 894 | "cannot use continuations inside hooks"); |
| 895 | api_checknelems(L, nargs+1); |
| 896 | api_check(L, L->status == LUA_OK, "cannot do calls on non-normal thread"); |
| 897 | checkresults(L, nargs, nresults); |
| 898 | func = L->top - (nargs+1); |
| 899 | if (k != NULL && L->nny == 0) { /* need to prepare continuation? */ |
| 900 | L->ci->u.c.k = k; /* save continuation */ |
| 901 | L->ci->u.c.ctx = ctx; /* save context */ |
| 902 | luaD_call(L, func, nresults, 1); /* do the call */ |
| 903 | } |
| 904 | else /* no continuation or no yieldable */ |
| 905 | luaD_call(L, func, nresults, 0); /* just do the call */ |
| 906 | adjustresults(L, nresults); |
| 907 | lua_unlock(L); |
| 908 | } |
| 909 | |
| 910 | |
| 911 |
no test coverage detected