38 #define errorstatus(s) ((s) > LUA_YIELD) 53 #if !defined(LUAI_THROW) 55 #if defined(__cplusplus) && !defined(LUA_USE_LONGJMP) 58 #define LUAI_THROW(L,c) throw(c) 59 #define LUAI_TRY(L,c,a) \ 60 try { a } catch(...) { if ((c)->status == 0) (c)->status = -1; } 61 #define luai_jmpbuf int 63 #elif defined(LUA_USE_POSIX) 66 #define LUAI_THROW(L,c) _longjmp((c)->b, 1) 67 #define LUAI_TRY(L,c,a) if (_setjmp((c)->b) == 0) { a } 68 #define luai_jmpbuf jmp_buf 73 #define LUAI_THROW(L,c) longjmp((c)->b, 1) 74 #define LUAI_TRY(L,c,a) if (setjmp((c)->b) == 0) { a } 75 #define luai_jmpbuf jmp_buf 167 if (oldstack == newstack)
169 L->
top = (L->
top - oldstack) + newstack;
172 for (ci = L->
ci; ci != NULL; ci = ci->
previous) {
173 ci->
top = (ci->
top - oldstack) + newstack;
174 ci->
func = (ci->
func - oldstack) + newstack;
182 #define ERRORSTACKSIZE (LUAI_MAXSTACK + 200) 195 for (; lim < newsize; lim++)
211 int newsize = 2 * size;
221 if (newsize < needed)
238 for (ci = L->
ci; ci != NULL; ci = ci->
previous) {
239 if (lim < ci->
top) lim = ci->
top;
275 int ftransfer,
int ntransfer) {
286 if (ntransfer != 0) {
339 ftransfer =
cast(
unsigned short, firstres - ci->
func);
359 for (p = L->
top; p > func; p--)
400 firstresult = L->
top - nres;
402 for (i = 0; i < nres && i < wanted; i++)
404 for (; i < wanted; i++)
406 L->
top = res + wanted;
424 #define next_ci(L) (L->ci->next ? L->ci->next : luaE_extendCI(L)) 437 for (i = 0; i < narg1; i++)
441 for (; narg1 <= nfixparams; narg1++)
443 ci->
top = func + 1 + fsize;
445 ci->
u.
l.savedpc = p->
code;
447 L->
top = func + narg1;
496 ci->
u.
l.savedpc = p->
code;
498 ci->
top = func + 1 + fsize;
501 for (; narg < nfixparams; narg++)
549 n = (*ci->
u.
c.k)(L, status, ci->
u.
c.ctx);
585 for (ci = L->
ci; ci != NULL; ci = ci->
previous) {
601 if (ci == NULL)
return 0;
637 int n = *(
cast(
int*, ud));
649 if (ci->
u.
c.k != NULL) {
667 return resume_error(L,
"cannot resume non-suspended coroutine", nargs);
668 else if (L->
top - (L->
ci->
func + 1) == nargs)
669 return resume_error(L,
"cannot resume dead coroutine", nargs);
672 return resume_error(L,
"cannot resume dead coroutine", nargs);
714 if (L !=
G(L)->mainthread)
715 luaG_runerror(L,
"attempt to yield across a C-call boundary");
717 luaG_runerror(L,
"attempt to yield from outside a coroutine");
722 api_check(L, k == NULL,
"hooks cannot continue after yielding");
726 if ((ci->
u.
c.k = k) != NULL)
743 ptrdiff_t old_top, ptrdiff_t ef) {
747 ptrdiff_t old_errfunc = L->
errfunc;
778 if (mode && strchr(mode, x[0]) == NULL) {
780 "attempt to load a %s chunk (mode is '%s')", x, mode);
unsigned short callstatus
#define luaZ_freebuffer(L, buff)
#define luaZ_initbuffer(L, buff)
LClosure * luaU_undump(lua_State *L, ZIO *Z, const char *name)
static void unroll(lua_State *L, void *ud)
void luaD_callnoyield(lua_State *L, StkId func, int nResults)
LUA_API int lua_yieldk(lua_State *L, int nresults, lua_KContext ctx, lua_KFunction k)
int luaF_close(lua_State *L, StkId level, int status)
LUA_KCONTEXT lua_KContext
#define luaM_freearray(L, b, n)
void luaD_hookcall(lua_State *L, CallInfo *ci)
LUA_API int lua_isyieldable(lua_State *L)
LUA_API int lua_resume(lua_State *L, lua_State *from, int nargs, int *nresults)
struct lua_longjmp * previous
static void resume(lua_State *L, void *ud)
static CallInfo * findpcall(lua_State *L)
LClosure * luaY_parser(lua_State *L, ZIO *z, Mbuffer *buff, Dyndata *dyd, const char *name, int firstchar)
#define luai_userstateresume(L, n)
int luaD_reallocstack(lua_State *L, int newsize, int raiseerror)
#define luaE_exitCcall(L)
l_noret luaG_typeerror(lua_State *L, const TValue *o, const char *op)
void luaD_call(lua_State *L, StkId func, int nresults)
struct CallInfo::@30::@33 c
#define luai_userstateyield(L, n)
void luaE_shrinkCI(lua_State *L)
void luaD_inctop(lua_State *L)
void luaD_shrinkstack(lua_State *L)
#define checkstackGC(L, fsize)
#define luaM_reallocvector(L, v, oldn, n, t)
#define luaS_newliteral(L, s)
#define restorestack(L, n)
int luaD_protectedparser(lua_State *L, ZIO *z, const char *name, const char *mode)
struct CallInfo::@31::@34 transferinfo
static StkId rethook(lua_State *L, CallInfo *ci, StkId firstres, int nres)
int(* lua_CFunction)(lua_State *L)
struct lua_State * mainthread
void luaD_seterrorobj(lua_State *L, int errcode, StkId oldtop)
void luaD_poscall(lua_State *L, CallInfo *ci, int nres)
const TValue * luaT_gettmbyobj(lua_State *L, const TValue *o, TMS event)
static int stackinuse(lua_State *L)
static void checkmode(lua_State *L, const char *mode, const char *x)
void luaF_initupvals(lua_State *L, LClosure *cl)
#define luaD_checkstack(L, n)
int(* lua_KFunction)(lua_State *L, int status, lua_KContext ctx)
volatile l_signalT hookmask
void luaD_hook(lua_State *L, int event, int line, int ftransfer, int ntransfer)
void(* Pfunc)(lua_State *L, void *ud)
int luaD_pcall(lua_State *L, Pfunc func, void *u, ptrdiff_t old_top, ptrdiff_t ef)
static int recover(lua_State *L, int status)
static void moveresults(lua_State *L, StkId res, int nres, int wanted)
l_noret luaG_runerror(lua_State *L, const char *fmt,...)
void luaD_pretailcall(lua_State *L, CallInfo *ci, StkId func, int narg1)
#define checkstackGCp(L, n, p)
#define setsvalue2s(L, o, s)
void luaE_enterCcall(lua_State *L)
#define api_checknelems(L, n)
void luaV_execute(lua_State *L, CallInfo *ci)
int luaD_rawrunprotected(lua_State *L, Pfunc f, void *ud)
static int resume_error(lua_State *L, const char *msg, int narg)
TString * luaS_new(lua_State *L, const char *str)
struct Dyndata::@29 actvar
int luaD_growstack(lua_State *L, int n, int raiseerror)
#define hastocloseCfunc(n)
#define api_check(l, e, msg)
struct CallInfo * previous
static void f_parser(lua_State *L, void *ud)
void(* lua_Hook)(lua_State *L, lua_Debug *ar)
#define condmovestack(L, pre, pos)
#define setobjs2s(L, o1, o2)
#define LUAI_TRY(L, c, a)
const char * luaO_pushfstring(lua_State *L, const char *fmt,...)
void luaV_finishOp(lua_State *L)
static void finishCcall(lua_State *L, int status)
static void correctstack(lua_State *L, StkId oldstack, StkId newstack)
struct UpVal::@22::@23 open
void luaD_tryfuncTM(lua_State *L, StkId func)
l_noret luaD_throw(lua_State *L, int errcode)
struct lua_longjmp * errorJmp
#define setobj2s(L, o1, o2)
struct CallInfo::@30::@32 l
#define adjustresults(L, nres)