xref: /minix/external/mit/lua/dist/src/ldo.h (revision 0a6a1f1d)
1 /*	$NetBSD: ldo.h,v 1.4 2015/10/08 13:21:00 mbalmer Exp $	*/
2 
3 /*
4 ** Id: ldo.h,v 2.22 2015/05/22 17:48:19 roberto Exp
5 ** Stack and Call structure of Lua
6 ** See Copyright Notice in lua.h
7 */
8 
9 #ifndef ldo_h
10 #define ldo_h
11 
12 
13 #include "lobject.h"
14 #include "lstate.h"
15 #include "lzio.h"
16 
17 
18 #define luaD_checkstack(L,n)	if (L->stack_last - L->top <= (n)) \
19 				    luaD_growstack(L, n); else condmovestack(L);
20 
21 
22 #define incr_top(L) {L->top++; luaD_checkstack(L,0);}
23 
24 #define savestack(L,p)		((char *)(p) - (char *)L->stack)
25 #define restorestack(L,n)	((TValue *)((char *)L->stack + (n)))
26 
27 
28 /* type of protected functions, to be ran by 'runprotected' */
29 typedef void (*Pfunc) (lua_State *L, void *ud);
30 
31 LUAI_FUNC int luaD_protectedparser (lua_State *L, ZIO *z, const char *name,
32                                                   const char *mode);
33 LUAI_FUNC void luaD_hook (lua_State *L, int event, int line);
34 LUAI_FUNC int luaD_precall (lua_State *L, StkId func, int nresults);
35 LUAI_FUNC void luaD_call (lua_State *L, StkId func, int nResults,
36                                         int allowyield);
37 LUAI_FUNC int luaD_pcall (lua_State *L, Pfunc func, void *u,
38                                         ptrdiff_t oldtop, ptrdiff_t ef);
39 LUAI_FUNC int luaD_poscall (lua_State *L, StkId firstResult, int nres);
40 LUAI_FUNC void luaD_reallocstack (lua_State *L, int newsize);
41 LUAI_FUNC void luaD_growstack (lua_State *L, int n);
42 LUAI_FUNC void luaD_shrinkstack (lua_State *L);
43 
44 LUAI_FUNC l_noret luaD_throw (lua_State *L, int errcode);
45 LUAI_FUNC int luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud);
46 
47 #endif
48 
49