14 #include "../lua_jailbreak_exception.hpp"
16 #if !defined(__cplusplus)
17 #error "Exception support requires a C++ compiler."
54 #if defined(__cplusplus)
56 #define LUAI_THROW(L,c) throw(c)
57 #define LUAI_TRY(L,c,a) \
61 } catch(const tlua_jailbreak_exception &e) { \
64 } catch(const std::exception &e) { \
65 lua_pushstring(L, e.what()); \
68 } catch (const lua_longjmp *) { \
72 assert(false && "Lua is swallowing an un-named exception... this indicates a programmer error, please derive all exceptions from either std::exception, or tlua_jailbreak_exception (and not with multiple inheritance pathways to either or this exception handler will not work!)"); \
76 if((c)->status == 0) \
79 #define luai_jmpbuf int
82 #elif defined(LUA_USE_ULONGJMP)
84 #define LUAI_THROW(L,c) _longjmp((c)->b, 1)
85 #define LUAI_TRY(L,c,a) if (_setjmp((c)->b) == 0) { a }
86 #define luai_jmpbuf jmp_buf
90 #define LUAI_THROW(L,c) longjmp((c)->b, 1)
91 #define LUAI_TRY(L,c,a) if (setjmp((c)->b) == 0) { a }
92 #define luai_jmpbuf jmp_buf
132 if (
G(L)->mainthread->errorJmp) {
148 unsigned short oldnCcalls = L->
nCcalls;
170 for (ci = L->
ci; ci != NULL; ci = ci->
previous) {
174 ci->
u.
l.base = (ci->
u.
l.base - oldstack) + L->
stack;
180 #define ERRORSTACKSIZE (LUAI_MAXSTACK + 200)
189 for (; lim < newsize; lim++)
203 int newsize = 2 *
size;
205 if (newsize < needed) newsize = needed;
219 for (ci = L->
ci; ci != NULL; ci = ci->
previous) {
221 if (lim < ci->top) lim = ci->
top;
229 int goodsize = inuse + (inuse / 8) + 2*
EXTRA_STACK;
286 fixed = L->
top - actual;
288 for (i=0; i<nfixargs; i++) {
312 #define next_ci(L) (L->ci = (L->ci->next ? L->ci->next : luaE_extendCI(L)))
323 switch (
ttype(func)) {
368 ci->
u.
l.savedpc = p->
code;
390 ptrdiff_t fr =
savestack(L, firstResult);
400 for (i = wanted; i != 0 && firstResult < L->
top; i--)
422 if (!allowyield) L->
nny++;
425 if (!allowyield) L->
nny--;
475 for (ci = L->
ci; ci != NULL; ci = ci->
previous) {
486 if (ci == NULL)
return 0;
526 resume_error(L,
"cannot resume non-suspended coroutine", firstArg);
532 resume_error(L,
"cannot resume dead coroutine", firstArg);
539 if (ci->
u.
c.k != NULL) {
547 firstArg = L->
top -
n;
595 if (L !=
G(L)->mainthread)
596 luaG_runerror(L,
"attempt to yield across a C-call boundary");
598 luaG_runerror(L,
"attempt to yield from outside a coroutine");
603 api_check(L, k == NULL,
"hooks cannot continue after yielding");
606 if ((ci->
u.
c.k = k) != NULL)
608 ci->
func = L->
top - nresults - 1;
618 ptrdiff_t old_top, ptrdiff_t ef) {
622 unsigned short old_nny = L->
nny;
623 ptrdiff_t old_errfunc = L->
errfunc;
654 if (mode && strchr(mode, x[0]) == NULL) {
656 "attempt to load a %s chunk (mode is " LUA_QS ")", x, mode);
676 for (i = 0; i < cl->
l.nupvalues; i++) {
#define luaZ_freebuffer(L, buff)
#define luaZ_initbuffer(L, buff)
l_noret luaG_runerror(lua_State *L, const char *fmt,...)
void luaF_close(lua_State *L, StkId level)
static l_noret resume_error(lua_State *L, const char *msg, StkId firstArg)
#define luaM_freearray(L, b, n)
void luaD_shrinkstack(lua_State *L)
#define LUAI_TRY(L, c, a)
static void finishCcall(lua_State *L)
int luaD_poscall(lua_State *L, StkId firstResult)
struct lua_longjmp * previous
static void resume(lua_State *L, void *ud)
static CallInfo * findpcall(lua_State *L)
void(* lua_Hook)(lua_State *L, lua_Debug *ar)
#define luai_userstateresume(L, n)
Closure * luaU_undump(lua_State *L, ZIO *Z, Mbuffer *buff, const char *name)
static StkId adjust_varargs(lua_State *L, Proto *p, int actual)
#define luai_userstateyield(L, n)
static void callhook(lua_State *L, CallInfo *ci)
TString * luaS_new(lua_State *L, const char *str)
int(* lua_CFunction)(lua_State *L)
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)
int luaD_precall(lua_State *L, StkId func, int nresults)
struct CallInfo::@16::@18 c
LUA_API int lua_yieldk(lua_State *L, int nresults, int ctx, lua_CFunction k)
int luaD_pcall(lua_State *L, Pfunc func, void *u, ptrdiff_t old_top, ptrdiff_t ef)
#define luaD_checkstack(L, n)
void luaD_growstack(lua_State *L, int n)
int luaD_protectedparser(lua_State *L, ZIO *z, const char *name, const char *mode)
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)
void(* Pfunc)(lua_State *L, void *ud)
struct Dyndata::@15 actvar
Closure * luaY_parser(lua_State *L, ZIO *z, Mbuffer *buff, Dyndata *dyd, const char *name, int firstchar)
static void checkmode(lua_State *L, const char *mode, const char *x)
static void msg(const char *act, debug_info &i, const char *to="", const char *result="")
GLint GLint GLint GLint GLint x
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)
GLuint const GLchar * name
void luaV_execute(lua_State *L)
static StkId tryfuncTM(lua_State *L, StkId func)
struct CallInfo::@16::@17 l
UpVal * luaF_newupval(lua_State *L)
#define api_check(l, e, msg)
struct CallInfo * previous
static int recover(lua_State *L, int status)
static int panic(lua_State *L)
void luaD_call(lua_State *L, StkId func, int nResults, int allowyield)
static void unroll(lua_State *L, void *ud)
void luaD_reallocstack(lua_State *L, int newsize)
#define luaC_objbarrier(L, p, o)
const Instruction * oldpc
void luaV_finishOp(lua_State *L)
static void f_parser(lua_State *L, void *ud)
struct lua_longjmp * errorJmp
#define adjustresults(L, nres)