ldo.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /*
  2. ** $Id: $
  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. typedef int StkId; /* index to luaD_stack.stack elements */
  10. #define MULT_RET 255
  11. extern struct Stack {
  12. TObject *last;
  13. TObject *stack;
  14. TObject *top;
  15. } luaD_stack;
  16. extern struct C_Lua_Stack {
  17. StkId base; /* when Lua calls C or C calls Lua, points to */
  18. /* the first slot after the last parameter. */
  19. StkId lua2C; /* points to first element of "array" lua2C */
  20. int num; /* size of "array" lua2C */
  21. } luaD_Cstack;
  22. extern TObject luaD_errorim;
  23. /*
  24. ** macro to increment stack top.
  25. ** There must be always an empty slot at the luaD_stack.top
  26. */
  27. #define incr_top { if (luaD_stack.top >= luaD_stack.last) luaD_checkstack(1); \
  28. luaD_stack.top++; }
  29. /* macros to convert from lua_Object to (TObject *) and back */
  30. #define Address(lo) ((lo)+luaD_stack.stack-1)
  31. #define Ref(st) ((st)-luaD_stack.stack+1)
  32. void luaD_adjusttop (StkId newtop);
  33. void luaD_openstack (int nelems);
  34. void luaD_lineHook (int line);
  35. void luaD_callHook (StkId base, lua_Type type, int isreturn);
  36. void luaD_call (StkId base, int nResults);
  37. void luaD_callTM (TObject *f, int nParams, int nResults);
  38. int luaD_protectedrun (int nResults);
  39. void luaD_gcIM (TObject *o);
  40. void luaD_travstack (int (*fn)(TObject *));
  41. void luaD_checkstack (int n);
  42. #endif