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 137 unsigned short oldnCcalls = L->
nCcalls;
163 up->
v = (up->
v - oldstack) + L->
stack;
164 for (ci = L->
ci; ci != NULL; ci = ci->
previous) {
168 ci->
u.
l.base = (ci->
u.
l.base - oldstack) + L->
stack;
174 #define ERRORSTACKSIZE (LUAI_MAXSTACK + 200) 183 for (; lim < newsize; lim++)
197 int newsize = 2 *
size;
199 if (newsize < needed) newsize = needed;
213 for (ci = L->
ci; ci != NULL; ci = ci->
previous) {
214 if (lim < ci->top) lim = ci->
top;
223 int goodsize = inuse + (inuse / 8) + 2*
EXTRA_STACK;
233 goodsize < L->stacksize)
298 fixed = L->
top - actual;
300 for (i = 0; i < nfixargs && i < actual; i++) {
304 for (; i < nfixargs; i++)
321 for (p = L->
top; p > func; p--)
335 int nres,
int wanted) {
346 for (i = 0; i < nres; i++)
353 if (wanted <= nres) {
354 for (i = 0; i < wanted; i++)
358 for (i = 0; i < nres; i++)
360 for (; i < wanted; i++)
366 L->
top = res + wanted;
381 ptrdiff_t fr =
savestack(L, firstResult);
390 return moveresults(L, firstResult, res, nres, wanted);
395 #define next_ci(L) (L->ci = (L->ci->next ? L->ci->next : luaE_extendCI(L))) 399 #define checkstackp(L,n,p) \ 400 luaD_checkstackaux(L, n, \ 401 ptrdiff_t t__ = savestack(L, p); \ 403 p = restorestack(L, t__)) 416 switch (
ttype(func)) {
457 L->
top = ci->
top = base + fsize;
459 ci->
u.
l.savedpc = p->
code;
533 n = (*ci->
u.
c.k)(L, status, ci->
u.
c.ctx);
568 for (ci = L->
ci; ci != NULL; ci = ci->
previous) {
584 if (ci == NULL)
return 0;
620 int n = *(
cast(
int*, ud));
634 if (ci->
u.
c.k != NULL) {
639 firstArg = L->
top -
n;
650 unsigned short oldnny = L->
nny;
654 return resume_error(L,
"cannot resume non-suspended coroutine", nargs);
657 return resume_error(L,
"cannot resume dead coroutine", nargs);
688 return (L->
nny == 0);
699 if (L !=
G(L)->mainthread)
700 luaG_runerror(L,
"attempt to yield across a C-call boundary");
702 luaG_runerror(L,
"attempt to yield from outside a coroutine");
707 api_check(L, k == NULL,
"hooks cannot continue after yielding");
710 if ((ci->
u.
c.k = k) != NULL)
712 ci->
func = L->
top - nresults - 1;
722 ptrdiff_t old_top, ptrdiff_t ef) {
726 unsigned short old_nny = L->
nny;
727 ptrdiff_t old_errfunc = L->
errfunc;
758 if (mode && strchr(mode, x[0]) == NULL) {
760 "attempt to load a %s chunk (mode is '%s')", x, mode);
unsigned short callstatus
struct UpVal::@2::@3 open
#define luaZ_freebuffer(L, buff)
struct CallInfo::@10::@12 c
#define luaZ_initbuffer(L, buff)
l_noret luaG_runerror(lua_State *L, const char *fmt,...)
void luaF_close(lua_State *L, StkId level)
void luaE_shrinkCI(lua_State *L)
LUA_KCONTEXT lua_KContext
#define luaM_freearray(L, b, n)
void luaD_shrinkstack(lua_State *L)
#define LUAI_TRY(L, c, a)
struct lua_longjmp * previous
static int resume_error(lua_State *L, const char *msg, int narg)
static void resume(lua_State *L, void *ud)
static void tryfuncTM(lua_State *L, StkId func)
static CallInfo * findpcall(lua_State *L)
#define luai_userstateresume(L, n)
static StkId adjust_varargs(lua_State *L, Proto *p, int actual)
static void msg(const char *act, debug_info &i, const char *to="", const char *result="")
#define luai_userstateyield(L, n)
void luaE_freeCI(lua_State *L)
static void callhook(lua_State *L, CallInfo *ci)
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)
std::size_t size(const std::string &str)
Length in characters of a UTF-8 string.
int luaD_precall(lua_State *L, StkId func, int nresults)
struct CallInfo::@10::@11 l
int(* lua_CFunction)(lua_State *L)
struct lua_State * mainthread
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)
#define luaD_checkstack(L, n)
int(* lua_KFunction)(lua_State *L, int status, lua_KContext ctx)
void luaD_growstack(lua_State *L, int n)
int luaD_protectedparser(lua_State *L, ZIO *z, const char *name, const char *mode)
void(* Pfunc)(lua_State *L, void *ud)
static int moveresults(lua_State *L, const TValue *firstResult, StkId res, int nres, int wanted)
static int stackinuse(lua_State *L)
void luaD_hook(lua_State *L, int event, int line)
static void correctstack(lua_State *L, TValue *oldstack)
static void seterrorobj(lua_State *L, int errcode, StkId oldtop)
#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 checkmode(lua_State *L, const char *mode, const char *x)
#define checkstackp(L, n, p)
void luaD_call(lua_State *L, StkId func, int nResults)
LUA_API int lua_resume(lua_State *L, lua_State *from, int nargs)
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 luaV_execute(lua_State *L)
void luaF_initupvals(lua_State *L, LClosure *cl)
LUA_API int lua_yieldk(lua_State *L, int nresults, lua_KContext ctx, lua_KFunction k)
int luaD_poscall(lua_State *L, CallInfo *ci, StkId firstResult, int nres)
#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)
static void unroll(lua_State *L, void *ud)
static void stackerror(lua_State *L)
void luaD_reallocstack(lua_State *L, int newsize)
void luaD_inctop(lua_State *L)
const Instruction * oldpc
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
struct Dyndata::@9 actvar
#define adjustresults(L, nres)