ldo.h
Go to the documentation of this file.
1 /*
2 ** $Id: ldo.h $
3 ** Stack and Call structure of Lua
4 ** See Copyright Notice in lua.h
5 */
6 
7 #ifndef ldo_h
8 #define ldo_h
9 
10 
11 #include "lobject.h"
12 #include "lstate.h"
13 #include "lzio.h"
14 
15 
16 /*
17 ** Macro to check stack size and grow stack if needed. Parameters
18 ** 'pre'/'pos' allow the macro to preserve a pointer into the
19 ** stack across reallocations, doing the work only when needed.
20 ** It also allows the running of one GC step when the stack is
21 ** reallocated.
22 ** 'condmovestack' is used in heavy tests to force a stack reallocation
23 ** at every check.
24 */
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); }
29 
30 /* In general, 'pre'/'pos' are empty (nothing to save) */
31 #define luaD_checkstack(L,n) luaD_checkstackaux(L,n,(void)0,(void)0)
32 
33 
34 
35 #define savestack(L,p) ((char *)(p) - (char *)L->stack)
36 #define restorestack(L,n) ((StkId)((char *)L->stack + (n)))
37 
38 
39 /* macro to check stack size, preserving 'p' */
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' */
45 
46 
47 /* macro to check stack size and GC */
48 #define checkstackGC(L,fsize) \
49  luaD_checkstackaux(L, (fsize), luaC_checkGC(L), (void)0)
50 
51 
52 /* type of protected functions, to be ran by 'runprotected' */
53 typedef void (*Pfunc) (lua_State *L, void *ud);
54 
55 LUAI_FUNC void luaD_seterrorobj (lua_State *L, int errcode, StkId oldtop);
56 LUAI_FUNC int luaD_protectedparser (lua_State *L, ZIO *z, const char *name,
57  const char *mode);
58 LUAI_FUNC void luaD_hook (lua_State *L, int event, int line,
59  int fTransfer, int nTransfer);
61 LUAI_FUNC void luaD_pretailcall (lua_State *L, CallInfo *ci, StkId func, int n);
62 LUAI_FUNC CallInfo *luaD_precall (lua_State *L, StkId func, int nResults);
63 LUAI_FUNC void luaD_call (lua_State *L, StkId func, int nResults);
64 LUAI_FUNC void luaD_callnoyield (lua_State *L, StkId func, int nResults);
65 LUAI_FUNC void luaD_tryfuncTM (lua_State *L, StkId func);
66 LUAI_FUNC int luaD_closeprotected (lua_State *L, ptrdiff_t level, int status);
67 LUAI_FUNC int luaD_pcall (lua_State *L, Pfunc func, void *u,
68  ptrdiff_t oldtop, ptrdiff_t ef);
69 LUAI_FUNC void luaD_poscall (lua_State *L, CallInfo *ci, int nres);
70 LUAI_FUNC int luaD_reallocstack (lua_State *L, int newsize, int raiseerror);
71 LUAI_FUNC int luaD_growstack (lua_State *L, int n, int raiseerror);
74 
75 LUAI_FUNC l_noret luaD_throw (lua_State *L, int errcode);
76 LUAI_FUNC int luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud);
77 
78 #endif
79 
luaD_hook
LUAI_FUNC void luaD_hook(lua_State *L, int event, int line, int fTransfer, int nTransfer)
Definition: ldo.c:306
LUAI_FUNC
#define LUAI_FUNC
Definition: luaconf.h:312
l_noret
#define l_noret
Definition: llimits.h:162
lstate.h
luaD_hookcall
LUAI_FUNC void luaD_hookcall(lua_State *L, CallInfo *ci)
Definition: ldo.c:347
StackValue
Definition: lobject.h:146
luaD_callnoyield
LUAI_FUNC void luaD_callnoyield(lua_State *L, StkId func, int nResults)
Definition: ldo.c:594
luaD_precall
LUAI_FUNC CallInfo * luaD_precall(lua_State *L, StkId func, int nResults)
Definition: ldo.c:508
Pfunc
void(* Pfunc)(lua_State *L, void *ud)
Definition: ldo.h:53
luaD_shrinkstack
LUAI_FUNC void luaD_shrinkstack(lua_State *L)
Definition: ldo.c:274
mqtt_test_proto.z
z
Definition: mqtt_test_proto.py:36
SParser::name
const char * name
Definition: ldo.c:914
luaD_pcall
LUAI_FUNC int luaD_pcall(lua_State *L, Pfunc func, void *u, ptrdiff_t oldtop, ptrdiff_t ef)
Definition: ldo.c:885
luaD_growstack
LUAI_FUNC int luaD_growstack(lua_State *L, int n, int raiseerror)
Definition: ldo.c:219
SParser::mode
const char * mode
Definition: ldo.c:913
luaD_rawrunprotected
LUAI_FUNC int luaD_rawrunprotected(lua_State *L, Pfunc f, void *ud)
Definition: ldo.c:138
lua_State
Definition: lstate.h:304
nlohmann::detail::void
j template void())
Definition: json.hpp:4061
luaD_pretailcall
LUAI_FUNC void luaD_pretailcall(lua_State *L, CallInfo *ci, StkId func, int n)
Definition: ldo.c:481
lobject.h
luaD_inctop
LUAI_FUNC void luaD_inctop(lua_State *L)
Definition: ldo.c:293
luaD_tryfuncTM
LUAI_FUNC void luaD_tryfuncTM(lua_State *L, StkId func)
Definition: ldo.c:390
luaD_closeprotected
LUAI_FUNC int luaD_closeprotected(lua_State *L, ptrdiff_t level, int status)
Definition: ldo.c:863
luaD_seterrorobj
LUAI_FUNC void luaD_seterrorobj(lua_State *L, int errcode, StkId oldtop)
Definition: ldo.c:91
luaD_call
LUAI_FUNC void luaD_call(lua_State *L, StkId func, int nResults)
Definition: ldo.c:586
luaD_throw
LUAI_FUNC l_noret luaD_throw(lua_State *L, int errcode)
Definition: ldo.c:115
CallInfo
Definition: lstate.h:172
Zio
Definition: lzio.h:55
lzio.h
luaD_protectedparser
LUAI_FUNC int luaD_protectedparser(lua_State *L, ZIO *z, const char *name, const char *mode)
Definition: ldo.c:944
luaD_poscall
LUAI_FUNC void luaD_poscall(lua_State *L, CallInfo *ci, int nres)
Definition: ldo.c:459
luaD_reallocstack
LUAI_FUNC int luaD_reallocstack(lua_State *L, int newsize, int raiseerror)
Definition: ldo.c:191


plotjuggler
Author(s): Davide Faconti
autogenerated on Mon Nov 11 2024 03:23:44