[1803] | 1 | /* |
---|
| 2 | ** $Id: ldo.h,v 1.56 2002/12/04 17:29:32 roberto Exp $ |
---|
| 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 control inclusion of some hard tests on stack reallocation |
---|
| 18 | */ |
---|
| 19 | #ifndef HARDSTACKTESTS |
---|
| 20 | #define condhardstacktests(x) { /* empty */ } |
---|
| 21 | #else |
---|
| 22 | #define condhardstacktests(x) x |
---|
| 23 | #endif |
---|
| 24 | |
---|
| 25 | |
---|
| 26 | #define luaD_checkstack(L,n) \ |
---|
| 27 | if ((char *)L->stack_last - (char *)L->top <= (n)*(int)sizeof(TObject)) \ |
---|
| 28 | luaD_growstack(L, n); \ |
---|
| 29 | else condhardstacktests(luaD_reallocstack(L, L->stacksize)); |
---|
| 30 | |
---|
| 31 | |
---|
| 32 | #define incr_top(L) {luaD_checkstack(L,1); L->top++;} |
---|
| 33 | |
---|
| 34 | #define savestack(L,p) ((char *)(p) - (char *)L->stack) |
---|
| 35 | #define restorestack(L,n) ((TObject *)((char *)L->stack + (n))) |
---|
| 36 | |
---|
| 37 | #define saveci(L,p) ((char *)(p) - (char *)L->base_ci) |
---|
| 38 | #define restoreci(L,n) ((CallInfo *)((char *)L->base_ci + (n))) |
---|
| 39 | |
---|
| 40 | |
---|
| 41 | /* type of protected functions, to be ran by `runprotected' */ |
---|
| 42 | typedef void (*Pfunc) (lua_State *L, void *ud); |
---|
| 43 | |
---|
| 44 | void luaD_resetprotection (lua_State *L); |
---|
| 45 | int luaD_protectedparser (lua_State *L, ZIO *z, int bin); |
---|
| 46 | void luaD_callhook (lua_State *L, int event, int line); |
---|
| 47 | StkId luaD_precall (lua_State *L, StkId func); |
---|
| 48 | void luaD_call (lua_State *L, StkId func, int nResults); |
---|
| 49 | int luaD_pcall (lua_State *L, Pfunc func, void *u, |
---|
| 50 | ptrdiff_t oldtop, ptrdiff_t ef); |
---|
| 51 | void luaD_poscall (lua_State *L, int wanted, StkId firstResult); |
---|
| 52 | void luaD_reallocCI (lua_State *L, int newsize); |
---|
| 53 | void luaD_reallocstack (lua_State *L, int newsize); |
---|
| 54 | void luaD_growstack (lua_State *L, int n); |
---|
| 55 | |
---|
| 56 | void luaD_throw (lua_State *L, int errcode); |
---|
| 57 | int luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud); |
---|
| 58 | |
---|
| 59 | |
---|
| 60 | #endif |
---|