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 166 if (oldstack == newstack)
168 L->
top = (L->
top - oldstack) + newstack;
171 for (ci = L->
ci; ci != NULL; ci = ci->
previous) {
172 ci->
top = (ci->
top - oldstack) + newstack;
173 ci->
func = (ci->
func - oldstack) + newstack;
181 #define ERRORSTACKSIZE (LUAI_MAXSTACK + 200) 194 for (; lim < newsize; lim++)
219 int newsize = 2 *
size;
223 if (newsize < needed)
242 for (ci = L->
ci; ci != NULL; ci = ci->
previous) {
243 if (lim < ci->top) lim = ci->
top;
264 int nsize = inuse * 2;
295 int ftransfer,
int ntransfer) {
306 if (ntransfer != 0) {
359 ftransfer =
cast(
unsigned short, firstres - ci->
func);
379 for (p = L->
top; p > func; p--)
420 firstresult = L->
top - nres;
422 for (i = 0; i < nres && i < wanted; i++)
424 for (; i < wanted; i++)
426 L->
top = res + wanted;
444 #define next_ci(L) (L->ci->next ? L->ci->next : luaE_extendCI(L)) 457 for (i = 0; i < narg1; i++)
461 for (; narg1 <= nfixparams; narg1++)
463 ci->
top = func + 1 + fsize;
465 ci->
u.
l.savedpc = p->
code;
467 L->
top = func + narg1;
518 ci->
u.
l.savedpc = p->
code;
519 ci->
top = func + 1 + fsize;
522 for (; narg < nfixparams; narg++)
558 ccall(L, func, nResults, 1);
589 n = (*ci->
u.
c.k)(L, status, ci->
u.
c.ctx);
625 for (ci = L->
ci; ci != NULL; ci = ci->
previous) {
641 if (ci == NULL)
return 0;
677 int n = *(
cast(
int*, ud));
689 if (ci->
u.
c.k != NULL) {
707 return resume_error(L,
"cannot resume non-suspended coroutine", nargs);
708 else if (L->
top - (L->
ci->
func + 1) == nargs)
709 return resume_error(L,
"cannot resume dead coroutine", nargs);
712 return resume_error(L,
"cannot resume dead coroutine", nargs);
749 if (L !=
G(L)->mainthread)
750 luaG_runerror(L,
"attempt to yield across a C-call boundary");
752 luaG_runerror(L,
"attempt to yield from outside a coroutine");
757 api_check(L, k == NULL,
"hooks cannot continue after yielding");
761 if ((ci->
u.
c.k = k) != NULL)
778 ptrdiff_t old_top, ptrdiff_t ef) {
782 ptrdiff_t old_errfunc = L->
errfunc;
813 if (mode && strchr(mode, x[0]) == NULL) {
815 "attempt to load a %s chunk (mode is '%s')", x, mode);
unsigned short callstatus
#define luaZ_freebuffer(L, buff)
#define luaZ_initbuffer(L, buff)
l_noret luaG_runerror(lua_State *L, const char *fmt,...)
struct CallInfo::@13::@16 c
void luaE_shrinkCI(lua_State *L)
int luaD_reallocstack(lua_State *L, int newsize, int raiseerror)
void luaD_hook(lua_State *L, int event, int line, int ftransfer, int ntransfer)
LUA_KCONTEXT lua_KContext
#define luaM_freearray(L, b, n)
void luaD_shrinkstack(lua_State *L)
#define LUAI_TRY(L, c, a)
void luaV_execute(lua_State *L, CallInfo *ci)
struct lua_longjmp * previous
void luaD_hookcall(lua_State *L, CallInfo *ci)
static int resume_error(lua_State *L, const char *msg, int narg)
int luaD_growstack(lua_State *L, int n, int raiseerror)
void luaD_poscall(lua_State *L, CallInfo *ci, int nres)
static void resume(lua_State *L, void *ud)
static CallInfo * findpcall(lua_State *L)
#define luai_userstateresume(L, n)
struct Dyndata::@12 actvar
static void msg(const char *act, debug_info &i, const char *to="", const char *result="")
#define luai_userstateyield(L, n)
#define checkstackGC(L, fsize)
TString * luaS_new(lua_State *L, const char *str)
l_noret luaG_typeerror(lua_State *L, const TValue *o, const char *op)
#define luaM_reallocvector(L, v, oldn, n, t)
#define luaS_newliteral(L, s)
#define restorestack(L, n)
static void ccall(lua_State *L, StkId func, int nResults, int inc)
std::size_t size(const std::string &str)
Length in characters of a UTF-8 string.
static StkId rethook(lua_State *L, CallInfo *ci, StkId firstres, int nres)
int(* lua_CFunction)(lua_State *L)
static void moveresults(lua_State *L, StkId res, int nres, int wanted)
struct lua_State * mainthread
void luaD_seterrorobj(lua_State *L, int errcode, StkId oldtop)
int luaD_pcall(lua_State *L, Pfunc func, void *u, ptrdiff_t old_top, ptrdiff_t ef)
LClosure * luaU_undump(lua_State *L, ZIO *Z, const char *name)
void luaE_checkcstack(lua_State *L)
#define luaD_checkstack(L, n)
int(* lua_KFunction)(lua_State *L, int status, lua_KContext ctx)
int luaD_protectedparser(lua_State *L, ZIO *z, const char *name, const char *mode)
volatile l_signalT hookmask
void(* Pfunc)(lua_State *L, void *ud)
void luaD_tryfuncTM(lua_State *L, StkId func)
static int stackinuse(lua_State *L)
#define checkstackGCp(L, n, p)
LUA_API int lua_resume(lua_State *L, lua_State *from, int nargs, int *nresults)
#define setsvalue2s(L, o, s)
#define api_checknelems(L, n)
l_noret luaD_throw(lua_State *L, int errcode)
const TValue * luaT_gettmbyobj(lua_State *L, const TValue *o, TMS event)
static void correctstack(lua_State *L, StkId oldstack, StkId newstack)
int luaF_close(lua_State *L, StkId level, int status)
static void checkmode(lua_State *L, const char *mode, const char *x)
void luaD_pretailcall(lua_State *L, CallInfo *ci, StkId func, int narg1)
void luaD_call(lua_State *L, StkId func, int nResults)
CallInfo * luaD_precall(lua_State *L, StkId func, int nresults)
struct CallInfo::@13::@15 l
const char * luaO_pushfstring(lua_State *L, const char *fmt,...)
int luaD_rawrunprotected(lua_State *L, Pfunc f, void *ud)
LUA_API int lua_isyieldable(lua_State *L)
void luaD_callnoyield(lua_State *L, StkId func, int nResults)
void luaF_initupvals(lua_State *L, LClosure *cl)
struct UpVal::@5::@6 open
#define hastocloseCfunc(n)
LUA_API int lua_yieldk(lua_State *L, int nresults, lua_KContext ctx, lua_KFunction k)
#define api_check(l, e, msg)
struct CallInfo * previous
static int recover(lua_State *L, int status)
void(* lua_Hook)(lua_State *L, lua_Debug *ar)
#define condmovestack(L, pre, pos)
static void finishCcall(lua_State *L, int status)
#define setobjs2s(L, o1, o2)
static void unroll(lua_State *L, void *ud)
LUAI_FUNC void luaE_incCstack(lua_State *L)
void luaD_inctop(lua_State *L)
void luaV_finishOp(lua_State *L)
static map_location::DIRECTION n
LClosure * luaY_parser(lua_State *L, ZIO *z, Mbuffer *buff, Dyndata *dyd, const char *name, int firstchar)
static void f_parser(lua_State *L, void *ud)
struct lua_longjmp * errorJmp
#define setobj2s(L, o1, o2)
struct CallInfo::@14::@17 transferinfo
#define adjustresults(L, nres)