Github User Fetcher 1.0.0
C Application with Server and GUI
Loading...
Searching...
No Matches
ldo.h File Reference
#include "lobject.h"
#include "lstate.h"
#include "lzio.h"

Go to the source code of this file.

Macros

#define luaD_checkstackaux(L, n, pre, pos)
 
#define luaD_checkstack(L, n)   luaD_checkstackaux(L,n,(void)0,(void)0)
 
#define savestack(L, p)   ((char *)(p) - (char *)L->stack)
 
#define restorestack(L, n)   ((StkId)((char *)L->stack + (n)))
 
#define checkstackGCp(L, n, p)
 
#define checkstackGC(L, fsize)    luaD_checkstackaux(L, (fsize), luaC_checkGC(L), (void)0)
 

Typedefs

typedef void(* Pfunc) (lua_State *L, void *ud)
 

Functions

LUAI_FUNC void luaD_seterrorobj (lua_State *L, int errcode, StkId oldtop)
 
LUAI_FUNC int luaD_protectedparser (lua_State *L, ZIO *z, const char *name, const char *mode)
 
LUAI_FUNC void luaD_hook (lua_State *L, int event, int line, int fTransfer, int nTransfer)
 
LUAI_FUNC void luaD_hookcall (lua_State *L, CallInfo *ci)
 
LUAI_FUNC void luaD_pretailcall (lua_State *L, CallInfo *ci, StkId func, int n)
 
LUAI_FUNC CallInfoluaD_precall (lua_State *L, StkId func, int nResults)
 
LUAI_FUNC void luaD_call (lua_State *L, StkId func, int nResults)
 
LUAI_FUNC void luaD_callnoyield (lua_State *L, StkId func, int nResults)
 
LUAI_FUNC void luaD_tryfuncTM (lua_State *L, StkId func)
 
LUAI_FUNC int luaD_closeprotected (lua_State *L, ptrdiff_t level, int status)
 
LUAI_FUNC int luaD_pcall (lua_State *L, Pfunc func, void *u, ptrdiff_t oldtop, ptrdiff_t ef)
 
LUAI_FUNC void luaD_poscall (lua_State *L, CallInfo *ci, int nres)
 
LUAI_FUNC int luaD_reallocstack (lua_State *L, int newsize, int raiseerror)
 
LUAI_FUNC int luaD_growstack (lua_State *L, int n, int raiseerror)
 
LUAI_FUNC void luaD_shrinkstack (lua_State *L)
 
LUAI_FUNC void luaD_inctop (lua_State *L)
 
LUAI_FUNC l_noret luaD_throw (lua_State *L, int errcode)
 
LUAI_FUNC int luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud)
 

Macro Definition Documentation

◆ checkstackGC

#define checkstackGC ( L,
fsize )    luaD_checkstackaux(L, (fsize), luaC_checkGC(L), (void)0)

Definition at line 48 of file lua-5.4.3/src/ldo.h.

48#define checkstackGC(L,fsize) \
49 luaD_checkstackaux(L, (fsize), luaC_checkGC(L), (void)0)

Referenced by luaD_pretailcall().

◆ checkstackGCp

#define checkstackGCp ( L,
n,
p )
Value:
ptrdiff_t t__ = savestack(L, p); /* save 'p' */ \
luaC_checkGC(L), /* stack grow uses memory */ \
p = restorestack(L, t__)) /* 'pos' part: restore 'p' */
#define savestack(L, p)
#define restorestack(L, n)
#define luaD_checkstackaux(L, n, pre, pos)

Definition at line 40 of file lua-5.4.3/src/ldo.h.

40#define checkstackGCp(L,n,p) \
41 luaD_checkstackaux(L, n, \
42 ptrdiff_t t__ = savestack(L, p); /* save 'p' */ \
43 luaC_checkGC(L), /* stack grow uses memory */ \
44 p = restorestack(L, t__)) /* 'pos' part: restore 'p' */

Referenced by luaD_precall(), luaT_getvarargs(), and luaV_execute().

◆ luaD_checkstack

#define luaD_checkstack ( L,
n )   luaD_checkstackaux(L,n,(void)0,(void)0)

Definition at line 31 of file lua-5.4.3/src/ldo.h.

◆ luaD_checkstackaux

#define luaD_checkstackaux ( L,
n,
pre,
pos )
Value:
if (l_unlikely(L->stack_last - L->top <= (n))) \
{ pre; luaD_growstack(L, n, 1); pos; } \
else { condmovestack(L,pre,pos); }
#define condmovestack(L)
LUAI_FUNC int luaD_growstack(lua_State *L, int n, int raiseerror)

Definition at line 25 of file lua-5.4.3/src/ldo.h.

25#define luaD_checkstackaux(L,n,pre,pos) \
26 if (l_unlikely(L->stack_last - L->top <= (n))) \
27 { pre; luaD_growstack(L, n, 1); pos; } \
28 else { condmovestack(L,pre,pos); }

◆ restorestack

#define restorestack ( L,
n )   ((StkId)((char *)L->stack + (n)))

Definition at line 36 of file lua-5.4.3/src/ldo.h.

◆ savestack

#define savestack ( L,
p )   ((char *)(p) - (char *)L->stack)

Definition at line 35 of file lua-5.4.3/src/ldo.h.

Typedef Documentation

◆ Pfunc

typedef void(* Pfunc) (lua_State *L, void *ud)

Definition at line 53 of file lua-5.4.3/src/ldo.h.

Function Documentation

◆ luaD_call()

LUAI_FUNC void luaD_call ( lua_State * L,
StkId func,
int nResults )

Definition at line 370 of file lua-5.1.5/src/ldo.c.

370 {
371 if (++L->nCcalls >= LUAI_MAXCCALLS) {
372 if (L->nCcalls == LUAI_MAXCCALLS)
373 luaG_runerror(L, "C stack overflow");
374 else if (L->nCcalls >= (LUAI_MAXCCALLS + (LUAI_MAXCCALLS>>3)))
375 luaD_throw(L, LUA_ERRERR); /* error while handing stack error */
376 }
377 if (luaD_precall(L, func, nResults) == PCRLUA) /* is a Lua function? */
378 luaV_execute(L, 1); /* call it */
379 L->nCcalls--;
380 luaC_checkGC(L);
381}
void luaG_runerror(lua_State *L, const char *fmt,...)
int luaD_precall(lua_State *L, StkId func, int nresults)
void luaD_throw(lua_State *L, int errcode)
#define PCRLUA
#define luaC_checkGC(L)
#define LUA_ERRERR
#define LUAI_MAXCCALLS
void luaV_execute(lua_State *L, int nexeccalls)
unsigned short nCcalls

References ccall(), LUA_ERRERR, luaC_checkGC, luaD_precall(), luaD_throw(), luaG_runerror(), LUAI_MAXCCALLS, luaV_execute(), lua_State::nCcalls, PCRLUA, and stackerror().

Referenced by callclosemethod(), callTM(), callTM(), callTMres(), dothecall(), f_call(), f_call(), f_Ccall(), GCTM(), lua_call(), lua_callk(), lua_callk(), lua_pcallk(), lua_pcallk(), luaD_callnoyield(), luaG_errormsg(), luaT_callTM(), luaT_callTM(), luaT_callTMres(), luaV_execute(), luaV_execute(), and luaV_execute().

◆ luaD_callnoyield()

LUAI_FUNC void luaD_callnoyield ( lua_State * L,
StkId func,
int nResults )

Definition at line 507 of file lua-5.3.6/src/ldo.c.

507 {
508 L->nny++;
509 luaD_call(L, func, nResults);
510 L->nny--;
511}
void luaD_call(lua_State *L, StkId func, int nResults)
unsigned short nny

References ccall(), luaD_call(), lua_State::nny, and nyci.

Referenced by callclosemethod(), dothecall(), dothecall(), f_call(), f_call(), lua_callk(), luaG_errormsg(), luaT_callTM(), luaT_callTM(), and luaT_callTMres().

◆ luaD_closeprotected()

LUAI_FUNC int luaD_closeprotected ( lua_State * L,
ptrdiff_t level,
int status )

Definition at line 863 of file lua-5.4.3/src/ldo.c.

863 {
864 CallInfo *old_ci = L->ci;
865 lu_byte old_allowhooks = L->allowhook;
866 for (;;) { /* keep closing upvalues until no more errors */
867 struct CloseP pcl;
868 pcl.level = restorestack(L, level); pcl.status = status;
870 if (l_likely(status == LUA_OK)) /* no more errors? */
871 return pcl.status;
872 else { /* an error occurred; restore saved state and repeat */
873 L->ci = old_ci;
874 L->allowhook = old_allowhooks;
875 }
876 }
877}
#define restorestack(L, n)
unsigned char lu_byte
#define LUA_OK
static void closepaux(lua_State *L, void *ud)
int luaD_rawrunprotected(lua_State *L, Pfunc f, void *ud)

References lua_State::allowhook, lua_State::ci, closepaux(), CloseP::level, LUA_OK, luaD_rawrunprotected(), restorestack, and CloseP::status.

Referenced by close_state(), luaD_pcall(), and luaE_resetthread().

◆ luaD_growstack()

LUAI_FUNC int luaD_growstack ( lua_State * L,
int n,
int raiseerror )

Definition at line 219 of file lua-5.4.3/src/ldo.c.

219 {
220 int size = stacksize(L);
221 if (l_unlikely(size > LUAI_MAXSTACK)) {
222 /* if stack is larger than maximum, thread is already using the
223 extra space reserved for errors, that is, thread is handling
224 a stack error; cannot grow further than that. */
226 if (raiseerror)
227 luaD_throw(L, LUA_ERRERR); /* error inside message handler */
228 return 0; /* if not 'raiseerror', just signal it */
229 }
230 else {
231 int newsize = 2 * size; /* tentative new size */
232 int needed = cast_int(L->top - L->stack) + n;
233 if (newsize > LUAI_MAXSTACK) /* cannot cross the limit */
234 newsize = LUAI_MAXSTACK;
235 if (newsize < needed) /* but must respect what was asked for */
236 newsize = needed;
237 if (l_likely(newsize <= LUAI_MAXSTACK))
238 return luaD_reallocstack(L, newsize, raiseerror);
239 else { /* stack overflow */
240 /* add extra size to be able to handle the error message */
241 luaD_reallocstack(L, ERRORSTACKSIZE, raiseerror);
242 if (raiseerror)
243 luaG_runerror(L, "stack overflow");
244 return 0;
245 }
246 }
247}
#define cast_int(i)
#define lua_assert(c)
#define LUAI_MAXSTACK
#define ERRORSTACKSIZE
l_noret luaD_throw(lua_State *L, int errcode)
int luaD_reallocstack(lua_State *L, int newsize, int raiseerror)
#define stacksize(th)

References cast_int, ERRORSTACKSIZE, lua_assert, LUA_ERRERR, luaD_reallocstack(), luaD_throw(), luaG_runerror(), LUAI_MAXSTACK, lua_State::stack, stacksize, and lua_State::top.

◆ luaD_hook()

LUAI_FUNC void luaD_hook ( lua_State * L,
int event,
int line,
int fTransfer,
int nTransfer )

Definition at line 306 of file lua-5.4.3/src/ldo.c.

307 {
308 lua_Hook hook = L->hook;
309 if (hook && L->allowhook) { /* make sure there is a hook */
310 int mask = CIST_HOOKED;
311 CallInfo *ci = L->ci;
312 ptrdiff_t top = savestack(L, L->top); /* preserve original 'top' */
313 ptrdiff_t ci_top = savestack(L, ci->top); /* idem for 'ci->top' */
314 lua_Debug ar;
315 ar.event = event;
316 ar.currentline = line;
317 ar.i_ci = ci;
318 if (ntransfer != 0) {
319 mask |= CIST_TRAN; /* 'ci' has transfer information */
320 ci->u2.transferinfo.ftransfer = ftransfer;
321 ci->u2.transferinfo.ntransfer = ntransfer;
322 }
323 if (isLua(ci) && L->top < ci->top)
324 L->top = ci->top; /* protect entire activation register */
325 luaD_checkstack(L, LUA_MINSTACK); /* ensure minimum stack size */
326 if (ci->top < L->top + LUA_MINSTACK)
327 ci->top = L->top + LUA_MINSTACK;
328 L->allowhook = 0; /* cannot call hooks inside a hook */
329 ci->callstatus |= mask;
330 lua_unlock(L);
331 (*hook)(L, &ar);
332 lua_lock(L);
333 lua_assert(!L->allowhook);
334 L->allowhook = 1;
335 ci->top = restorestack(L, ci_top);
336 L->top = restorestack(L, top);
337 ci->callstatus &= ~mask;
338 }
339}
#define savestack(L, p)
#define luaD_checkstack(L, n)
#define lua_unlock(L)
#define lua_lock(L)
#define isLua(ci)
void(* lua_Hook)(lua_State *L, lua_Debug *ar)
#define LUA_MINSTACK
#define mask(n)
#define CIST_HOOKED
#define CIST_TRAN
struct CallInfo::@95::@98 transferinfo
union CallInfo::@95 u2
unsigned short ntransfer
unsigned short ftransfer

References lua_State::allowhook, CallInfo::callstatus, lua_State::ci, CIST_HOOKED, CIST_TRAN, lua_Debug::currentline, lua_Debug::event, CallInfo::ftransfer, lua_State::hook, lua_Debug::i_ci, isLua, lua_assert, lua_lock, LUA_MINSTACK, lua_unlock, luaD_checkstack, mask, CallInfo::ntransfer, restorestack, savestack, CallInfo::top, lua_State::top, CallInfo::transferinfo, and CallInfo::u2.

Referenced by luaD_hookcall(), luaD_precall(), and rethook().

◆ luaD_hookcall()

LUAI_FUNC void luaD_hookcall ( lua_State * L,
CallInfo * ci )

Definition at line 347 of file lua-5.4.3/src/ldo.c.

347 {
348 L->oldpc = 0; /* set 'oldpc' for new function */
349 if (L->hookmask & LUA_MASKCALL) { /* is call hook on? */
350 int event = (ci->callstatus & CIST_TAIL) ? LUA_HOOKTAILCALL
351 : LUA_HOOKCALL;
352 Proto *p = ci_func(ci)->p;
353 ci->u.l.savedpc++; /* hooks assume 'pc' is already incremented */
354 luaD_hook(L, event, -1, 1, p->numparams);
355 ci->u.l.savedpc--; /* correct 'pc' */
356 }
357}
#define ci_func(ci)
#define LUA_MASKCALL
#define LUA_HOOKCALL
#define CIST_TAIL
#define LUA_HOOKTAILCALL
void luaD_hook(lua_State *L, int event, int line, int ftransfer, int ntransfer)
struct CallInfo::@64::@65 l
const Instruction * savedpc
union CallInfo::@64 u
struct Proto ** p
const Instruction * oldpc

References CallInfo::callstatus, ci_func, CIST_TAIL, lua_State::hookmask, CallInfo::l, LUA_HOOKCALL, LUA_HOOKTAILCALL, LUA_MASKCALL, luaD_hook(), Proto::numparams, lua_State::oldpc, Proto::p, CallInfo::savedpc, and CallInfo::u.

Referenced by luaV_execute().

◆ luaD_inctop()

LUAI_FUNC void luaD_inctop ( lua_State * L)

Definition at line 240 of file lua-5.3.6/src/ldo.c.

240 {
241 luaD_checkstack(L, 1);
242 L->top++;
243}

References luaD_checkstack, and lua_State::top.

Referenced by LoadString(), loadStringN(), luaO_pushvfstring(), luaU_undump(), luaY_parser(), and pushstr().

◆ luaD_pcall()

LUAI_FUNC int luaD_pcall ( lua_State * L,
Pfunc func,
void * u,
ptrdiff_t oldtop,
ptrdiff_t ef )

Definition at line 456 of file lua-5.1.5/src/ldo.c.

457 {
458 int status;
459 unsigned short oldnCcalls = L->nCcalls;
460 ptrdiff_t old_ci = saveci(L, L->ci);
461 lu_byte old_allowhooks = L->allowhook;
462 ptrdiff_t old_errfunc = L->errfunc;
463 L->errfunc = ef;
464 status = luaD_rawrunprotected(L, func, u);
465 if (status != 0) { /* an error occurred? */
466 StkId oldtop = restorestack(L, old_top);
467 luaF_close(L, oldtop); /* close eventual pending closures */
468 luaD_seterrorobj(L, status, oldtop);
469 L->nCcalls = oldnCcalls;
470 L->ci = restoreci(L, old_ci);
471 L->base = L->ci->base;
472 L->savedpc = L->ci->savedpc;
473 L->allowhook = old_allowhooks;
475 }
476 L->errfunc = old_errfunc;
477 return status;
478}
void luaD_seterrorobj(lua_State *L, int errcode, StkId oldtop)
static void restore_stack_limit(lua_State *L)
int luaD_rawrunprotected(lua_State *L, Pfunc f, void *ud)
#define saveci(L, p)
#define restoreci(L, n)
void luaF_close(lua_State *L, StkId level)
const Instruction * savedpc

References lua_State::allowhook, CallInfo::base, lua_State::base, lua_State::ci, lua_State::errfunc, LUA_OK, luaD_closeprotected(), luaD_rawrunprotected(), luaD_seterrorobj(), luaD_shrinkstack(), luaF_close(), lua_State::nCcalls, lua_State::nny, restore_stack_limit(), restoreci, restorestack, saveci, CallInfo::savedpc, lua_State::savedpc, seterrorobj(), seterrorobj(), lua_longjmp::status, and CloseP::status.

Referenced by GCTM(), GCTM(), GCTM(), lua_cpcall(), lua_pcall(), lua_pcallk(), lua_pcallk(), luaD_protectedparser(), and luaD_protectedparser().

◆ luaD_poscall()

LUAI_FUNC void luaD_poscall ( lua_State * L,
CallInfo * ci,
int nres )

Definition at line 459 of file lua-5.4.3/src/ldo.c.

459 {
460 int wanted = ci->nresults;
461 if (l_unlikely(L->hookmask && !hastocloseCfunc(wanted)))
462 rethook(L, ci, nres);
463 /* move results to proper place */
464 moveresults(L, ci->func, nres, wanted);
465 /* function cannot be in any of these cases when returning */
466 lua_assert(!(ci->callstatus &
468 L->ci = ci->previous; /* back to caller (after closing variables) */
469}
#define CIST_YPCALL
#define CIST_FIN
#define hastocloseCfunc(n)
static void rethook(lua_State *L, CallInfo *ci, int nres)
static void moveresults(lua_State *L, StkId res, int nres, int wanted)
#define CIST_CLSRET
struct CallInfo * previous

References CallInfo::callstatus, lua_State::ci, CIST_CLSRET, CIST_FIN, CIST_HOOKED, CIST_TRAN, CIST_YPCALL, CallInfo::func, hastocloseCfunc, lua_State::hookmask, lua_assert, moveresults(), CallInfo::nresults, CallInfo::previous, and rethook().

Referenced by finishCcall(), luaD_precall(), and resume().

◆ luaD_precall()

LUAI_FUNC CallInfo * luaD_precall ( lua_State * L,
StkId func,
int nResults )

Definition at line 265 of file lua-5.1.5/src/ldo.c.

265 {
266 LClosure *cl;
267 ptrdiff_t funcr;
268 if (!ttisfunction(func)) /* `func' is not a function? */
269 func = tryfuncTM(L, func); /* check the `function' tag method */
270 funcr = savestack(L, func);
271 cl = &clvalue(func)->l;
272 L->ci->savedpc = L->savedpc;
273 if (!cl->isC) { /* Lua function? prepare its call */
274 CallInfo *ci;
275 StkId st, base;
276 Proto *p = cl->p;
278 func = restorestack(L, funcr);
279 if (!p->is_vararg) { /* no varargs? */
280 base = func + 1;
281 if (L->top > base + p->numparams)
282 L->top = base + p->numparams;
283 }
284 else { /* vararg function */
285 int nargs = cast_int(L->top - func) - 1;
286 base = adjust_varargs(L, p, nargs);
287 func = restorestack(L, funcr); /* previous call may change the stack */
288 }
289 ci = inc_ci(L); /* now `enter' new function */
290 ci->func = func;
291 L->base = ci->base = base;
292 ci->top = L->base + p->maxstacksize;
293 lua_assert(ci->top <= L->stack_last);
294 L->savedpc = p->code; /* starting point */
295 ci->tailcalls = 0;
296 ci->nresults = nresults;
297 for (st = L->top; st < ci->top; st++)
298 setnilvalue(st);
299 L->top = ci->top;
300 if (L->hookmask & LUA_MASKCALL) {
301 L->savedpc++; /* hooks assume 'pc' is already incremented */
303 L->savedpc--; /* correct 'pc' */
304 }
305 return PCRLUA;
306 }
307 else { /* if is a C function, call it */
308 CallInfo *ci;
309 int n;
310 luaD_checkstack(L, LUA_MINSTACK); /* ensure minimum stack size */
311 ci = inc_ci(L); /* now `enter' new function */
312 ci->func = restorestack(L, funcr);
313 L->base = ci->base = ci->func + 1;
314 ci->top = L->top + LUA_MINSTACK;
315 lua_assert(ci->top <= L->stack_last);
316 ci->nresults = nresults;
317 if (L->hookmask & LUA_MASKCALL)
319 lua_unlock(L);
320 n = (*curr_func(L)->c.f)(L); /* do the actual call */
321 lua_lock(L);
322 if (n < 0) /* yielding? */
323 return PCRYIELD;
324 else {
325 luaD_poscall(L, L->top - n);
326 return PCRC;
327 }
328 }
329}
static StkId adjust_varargs(lua_State *L, Proto *p, int actual)
static StkId tryfuncTM(lua_State *L, StkId func)
int luaD_poscall(lua_State *L, StkId firstResult)
void luaD_callhook(lua_State *L, int event, int line)
#define inc_ci(L)
#define PCRYIELD
#define PCRC
#define ttisfunction(o)
#define clvalue(o)
#define setnilvalue(obj)
#define curr_func(L)
struct Proto * p
Instruction * code
lu_byte maxstacksize

References adjust_varargs(), adjust_varargs(), adjust_varargs(), api_checknelems, CallInfo::base, lua_State::base, callhook(), callhook(), CallInfo::callstatus, cast_int, checkstackGCp, checkstackp, lua_State::ci, CIST_C, CIST_LUA, clCvalue, clLvalue, clvalue, Proto::code, curr_func, CallInfo::func, fvalue, lua_State::hookmask, inc_ci, Proto::is_vararg, CallInfo::l, lua_assert, LUA_HOOKCALL, lua_lock, LUA_MASKCALL, LUA_MINSTACK, LUA_TCCL, LUA_TLCF, LUA_TLCL, lua_unlock, LUA_VCCL, LUA_VLCF, LUA_VLCL, luaC_checkGC, luaD_callhook(), luaD_checkstack, luaD_hook(), luaD_hook(), luaD_poscall(), luaD_poscall(), luaD_poscall(), luaD_precall(), luaD_tryfuncTM(), Proto::maxstacksize, next_ci, CallInfo::nresults, NULL, Proto::numparams, Proto::p, LClosure::p, PCRC, PCRLUA, PCRYIELD, restorestack, s2v, CallInfo::savedpc, lua_State::savedpc, savestack, setnilvalue, lua_State::stack_last, CallInfo::tailcalls, CallInfo::top, lua_State::top, tryfuncTM(), tryfuncTM(), tryfuncTM(), ttisfunction, ttype, ttypetag, and CallInfo::u.

Referenced by ccall(), luaD_call(), luaD_call(), luaD_precall(), luaV_execute(), luaV_execute(), luaV_execute(), resume(), resume(), and resume().

◆ luaD_pretailcall()

LUAI_FUNC void luaD_pretailcall ( lua_State * L,
CallInfo * ci,
StkId func,
int n )

Definition at line 481 of file lua-5.4.3/src/ldo.c.

481 {
482 Proto *p = clLvalue(s2v(func))->p;
483 int fsize = p->maxstacksize; /* frame size */
484 int nfixparams = p->numparams;
485 int i;
486 for (i = 0; i < narg1; i++) /* move down function and arguments */
487 setobjs2s(L, ci->func + i, func + i);
488 checkstackGC(L, fsize);
489 func = ci->func; /* moved-down function */
490 for (; narg1 <= nfixparams; narg1++)
491 setnilvalue(s2v(func + narg1)); /* complete missing arguments */
492 ci->top = func + 1 + fsize; /* top for new function */
493 lua_assert(ci->top <= L->stack_last);
494 ci->u.l.savedpc = p->code; /* starting point */
495 ci->callstatus |= CIST_TAIL;
496 L->top = func + narg1; /* set top */
497}
#define setobjs2s
#define clLvalue(o)
#define checkstackGC(L, fsize)
#define s2v(o)

References CallInfo::callstatus, checkstackGC, CIST_TAIL, clLvalue, Proto::code, CallInfo::func, CallInfo::l, lua_assert, Proto::maxstacksize, Proto::numparams, Proto::p, s2v, CallInfo::savedpc, setnilvalue, setobjs2s, lua_State::stack_last, CallInfo::top, lua_State::top, and CallInfo::u.

Referenced by luaV_execute().

◆ luaD_protectedparser()

LUAI_FUNC int luaD_protectedparser ( lua_State * L,
ZIO * z,
const char * name,
const char * mode )

Definition at line 662 of file lua-5.2.4/src/ldo.c.

663 {
664 struct SParser p;
665 int status;
666 L->nny++; /* cannot yield during parsing */
667 p.z = z; p.name = name; p.mode = mode;
668 p.dyd.actvar.arr = NULL; p.dyd.actvar.size = 0;
669 p.dyd.gt.arr = NULL; p.dyd.gt.size = 0;
670 p.dyd.label.arr = NULL; p.dyd.label.size = 0;
671 luaZ_initbuffer(L, &p.buff);
672 status = luaD_pcall(L, f_parser, &p, savestack(L, L->top), L->errfunc);
673 luaZ_freebuffer(L, &p.buff);
674 luaM_freearray(L, p.dyd.actvar.arr, p.dyd.actvar.size);
675 luaM_freearray(L, p.dyd.gt.arr, p.dyd.gt.size);
676 luaM_freearray(L, p.dyd.label.arr, p.dyd.label.size);
677 L->nny--;
678 return status;
679}
#define NULL
Definition gmacros.h:924
const char * name
Definition lsqlite3.c:2154
#define luaM_freearray(L, b, n, t)
#define luaZ_initbuffer(L, buff)
#define luaZ_freebuffer(L, buff)
static void f_parser(lua_State *L, void *ud)
int luaD_pcall(lua_State *L, Pfunc func, void *u, ptrdiff_t old_top, ptrdiff_t ef)
const char * mode

References Dyndata::actvar, Labellist::arr, Dyndata::arr, SParser::buff, decnny, SParser::dyd, lua_State::errfunc, f_parser(), f_parser(), f_parser(), Dyndata::gt, incnny, Dyndata::label, luaD_pcall(), luaM_freearray, luaZ_freebuffer, luaZ_initbuffer, SParser::mode, name, SParser::name, lua_State::nny, NULL, savestack, Labellist::size, Dyndata::size, lua_State::top, and SParser::z.

◆ luaD_rawrunprotected()

LUAI_FUNC int luaD_rawrunprotected ( lua_State * L,
Pfunc f,
void * ud )

Definition at line 111 of file lua-5.1.5/src/ldo.c.

111 {
112 struct lua_longjmp lj;
113 lj.status = 0;
114 lj.previous = L->errorJmp; /* chain new error handler */
115 L->errorJmp = &lj;
116 LUAI_TRY(L, &lj,
117 (*f)(L, ud);
118 );
119 L->errorJmp = lj.previous; /* restore old error handler */
120 return lj.status;
121}
#define LUAI_TRY(L, c, a)
struct lua_longjmp * errorJmp
struct lua_longjmp * previous
volatile int status

References lua_State::errorJmp, LUA_OK, LUAI_TRY, lua_State::nCcalls, lua_longjmp::previous, and lua_longjmp::status.

Referenced by lua_checkstack(), lua_checkstack(), lua_close(), lua_newstate(), lua_resume(), lua_resume(), lua_resume(), luaD_closeprotected(), luaD_pcall(), luaH_resize(), and precover().

◆ luaD_reallocstack()

LUAI_FUNC int luaD_reallocstack ( lua_State * L,
int newsize,
int raiseerror )

Definition at line 191 of file lua-5.4.3/src/ldo.c.

191 {
192 int oldsize = stacksize(L);
193 int i;
194 StkId newstack = luaM_reallocvector(L, NULL, 0,
195 newsize + EXTRA_STACK, StackValue);
196 lua_assert(newsize <= LUAI_MAXSTACK || newsize == ERRORSTACKSIZE);
197 if (l_unlikely(newstack == NULL)) { /* reallocation failed? */
198 if (raiseerror)
199 luaM_error(L);
200 else return 0; /* do not raise an error */
201 }
202 /* number of elements to be copied to the new stack */
203 i = ((oldsize <= newsize) ? oldsize : newsize) + EXTRA_STACK;
204 memcpy(newstack, L->stack, i * sizeof(StackValue));
205 for (; i < newsize + EXTRA_STACK; i++)
206 setnilvalue(s2v(newstack + i)); /* erase new segment */
207 correctstack(L, L->stack, newstack);
208 luaM_freearray(L, L->stack, oldsize + EXTRA_STACK);
209 L->stack = newstack;
210 L->stack_last = L->stack + newsize;
211 return 1;
212}
#define luaM_reallocvector(L, v, oldn, n, t)
#define EXTRA_STACK
static void correctstack(lua_State *L, StkId oldstack, StkId newstack)
#define luaM_error(L)

References correctstack(), ERRORSTACKSIZE, EXTRA_STACK, lua_assert, LUAI_MAXSTACK, luaM_error, luaM_freearray, luaM_reallocvector, NULL, s2v, setnilvalue, lua_State::stack, lua_State::stack_last, and stacksize.

Referenced by luaD_growstack(), and luaD_shrinkstack().

◆ luaD_seterrorobj()

LUAI_FUNC void luaD_seterrorobj ( lua_State * L,
int errcode,
StkId oldtop )

Definition at line 51 of file lua-5.1.5/src/ldo.c.

51 {
52 switch (errcode) {
53 case LUA_ERRMEM: {
55 break;
56 }
57 case LUA_ERRERR: {
58 setsvalue2s(L, oldtop, luaS_newliteral(L, "error in error handling"));
59 break;
60 }
61 case LUA_ERRSYNTAX:
62 case LUA_ERRRUN: {
63 setobjs2s(L, oldtop, L->top - 1); /* error message on current top */
64 break;
65 }
66 }
67 L->top = oldtop + 1;
68}
#define MEMERRMSG
#define setsvalue2s
#define luaS_newliteral(L, s)
#define LUA_ERRSYNTAX
#define LUA_ERRMEM
#define LUA_ERRRUN

References errorstatus, G, lua_assert, LUA_ERRERR, LUA_ERRMEM, LUA_ERRRUN, LUA_ERRSYNTAX, LUA_OK, luaS_newliteral, MEMERRMSG, s2v, setnilvalue, setobjs2s, setsvalue2s, and lua_State::top.

Referenced by finishpcallk(), lua_resume(), lua_resume(), luaD_pcall(), luaE_resetthread(), prepcallclosemth(), and resetstack().

◆ luaD_shrinkstack()

LUAI_FUNC void luaD_shrinkstack ( lua_State * L)

Definition at line 205 of file lua-5.2.4/src/ldo.c.

205 {
206 int inuse = stackinuse(L);
207 int goodsize = inuse + (inuse / 8) + 2*EXTRA_STACK;
208 if (goodsize > LUAI_MAXSTACK) goodsize = LUAI_MAXSTACK;
209 if (inuse > LUAI_MAXSTACK || /* handling stack overflow? */
210 goodsize >= L->stacksize) /* would grow instead of shrink? */
211 condmovestack(L); /* don't change stack (change only for debugging) */
212 else
213 luaD_reallocstack(L, goodsize); /* shrink it */
214}
static int stackinuse(lua_State *L)
void luaD_reallocstack(lua_State *L, int newsize)

References condmovestack, EXTRA_STACK, luaD_reallocstack(), luaD_reallocstack(), luaE_freeCI(), luaE_shrinkCI(), LUAI_MAXSTACK, stackinuse(), stackinuse(), stackinuse(), lua_State::stacksize, and stacksize.

Referenced by finishpcallk(), luaD_pcall(), recover(), recover(), sweepthread(), traversethread(), and traversethread().

◆ luaD_throw()

LUAI_FUNC l_noret luaD_throw ( lua_State * L,
int errcode )

◆ luaD_tryfuncTM()

LUAI_FUNC void luaD_tryfuncTM ( lua_State * L,
StkId func )

Definition at line 390 of file lua-5.4.3/src/ldo.c.

390 {
391 const TValue *tm = luaT_gettmbyobj(L, s2v(func), TM_CALL);
392 StkId p;
393 if (l_unlikely(ttisnil(tm)))
394 luaG_callerror(L, s2v(func)); /* nothing to call */
395 for (p = L->top; p > func; p--) /* open space for metamethod */
396 setobjs2s(L, p, p-1);
397 L->top++; /* stack space pre-allocated by the caller */
398 setobj2s(L, func, tm); /* metamethod is the new function to be called */
399}
#define setobj2s
#define ttisnil(o)
const TValue * luaT_gettmbyobj(lua_State *L, const TValue *o, TMS event)
@ TM_CALL
l_noret luaG_callerror(lua_State *L, const TValue *o)

References luaG_callerror(), luaT_gettmbyobj(), s2v, setobj2s, setobjs2s, TM_CALL, lua_State::top, and ttisnil.

Referenced by luaD_precall(), and luaV_execute().