ldo.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*
  2. ** $Id: ldo.h,v 2.29 2015/12/21 13:02:14 roberto Exp $
  3. ** Stack and Call structure of Lua
  4. ** See Copyright Notice in lua.h
  5. */
  6. #ifndef ldo_h
  7. #define ldo_h
  8. #include "lobject.h"
  9. #include "lstate.h"
  10. #include "lzio.h"
  11. /*
  12. ** Macro to check stack size and grow stack if needed. Parameters
  13. ** 'pre'/'pos' allow the macro to preserve a pointer into the
  14. ** stack across reallocations, doing the work only when needed.
  15. ** 'condmovestack' is used in heavy tests to force a stack reallocation
  16. ** at every check.
  17. */
  18. #define luaD_checkstackaux(L,n,pre,pos) \
  19. if (L->stack_last - L->top <= (n)) \
  20. { pre; luaD_growstack(L, n); pos; } else { condmovestack(L,pre,pos); }
  21. /* In general, 'pre'/'pos' are empty (nothing to save) */
  22. #define luaD_checkstack(L,n) luaD_checkstackaux(L,n,(void)0,(void)0)
  23. #define savestack(L,p) ((char *)(p) - (char *)L->stack)
  24. #define restorestack(L,n) ((TValue *)((char *)L->stack + (n)))
  25. /* type of protected functions, to be ran by 'runprotected' */
  26. typedef void (*Pfunc) (lua_State *L, void *ud);
  27. LUAI_FUNC int luaD_protectedparser (lua_State *L, ZIO *z, const char *name,
  28. const char *mode);
  29. LUAI_FUNC void luaD_hook (lua_State *L, int event, int line);
  30. LUAI_FUNC int luaD_precall (lua_State *L, StkId func, int nresults);
  31. LUAI_FUNC void luaD_call (lua_State *L, StkId func, int nResults);
  32. LUAI_FUNC void luaD_callnoyield (lua_State *L, StkId func, int nResults);
  33. LUAI_FUNC int luaD_pcall (lua_State *L, Pfunc func, void *u,
  34. ptrdiff_t oldtop, ptrdiff_t ef);
  35. LUAI_FUNC int luaD_poscall (lua_State *L, CallInfo *ci, StkId firstResult,
  36. int nres);
  37. LUAI_FUNC void luaD_reallocstack (lua_State *L, int newsize);
  38. LUAI_FUNC void luaD_growstack (lua_State *L, int n);
  39. LUAI_FUNC void luaD_shrinkstack (lua_State *L);
  40. LUAI_FUNC void luaD_inctop (lua_State *L);
  41. LUAI_FUNC l_noret luaD_throw (lua_State *L, int errcode);
  42. LUAI_FUNC int luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud);
  43. #endif