lstate.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /*
  2. ** $Id: lstate.h,v 1.35 2000/08/07 18:39:16 roberto Exp roberto $
  3. ** Global State
  4. ** See Copyright Notice in lua.h
  5. */
  6. #ifndef lstate_h
  7. #define lstate_h
  8. #include <setjmp.h>
  9. #include "lobject.h"
  10. #include "lua.h"
  11. #include "luadebug.h"
  12. typedef TObject *StkId; /* index to stack elements */
  13. /*
  14. ** chain list of long jumps
  15. */
  16. struct lua_longjmp {
  17. jmp_buf b;
  18. struct lua_longjmp *previous;
  19. volatile int status; /* error code */
  20. StkId base;
  21. int numCblocks;
  22. };
  23. /*
  24. ** stack layout for C point of view:
  25. ** [lua2C, lua2C+num) - `array' lua2C
  26. ** [lua2C+num, base) - space for extra lua_Objects (limbo)
  27. ** [base, L->top) - `stack' C2Lua
  28. */
  29. struct C_Lua_Stack {
  30. StkId base;
  31. StkId lua2C;
  32. int num;
  33. };
  34. typedef struct stringtable {
  35. int size;
  36. lint32 nuse; /* number of elements */
  37. TString **hash;
  38. } stringtable;
  39. struct lua_State {
  40. /* thread-specific state */
  41. StkId top; /* first free slot in the stack */
  42. StkId stack; /* stack base */
  43. StkId stack_last; /* last free slot in the stack */
  44. int stacksize;
  45. struct C_Lua_Stack Cstack; /* C2lua struct */
  46. struct lua_longjmp *errorJmp; /* current error recover point */
  47. char *Mbuffer; /* global buffer */
  48. size_t Mbuffbase; /* current first position of Mbuffer */
  49. size_t Mbuffsize; /* size of Mbuffer */
  50. size_t Mbuffnext; /* next position to fill in Mbuffer */
  51. struct C_Lua_Stack *Cblocks;
  52. int numCblocks; /* number of nested Cblocks */
  53. /* global state */
  54. Proto *rootproto; /* list of all prototypes */
  55. Closure *rootcl; /* list of all closures */
  56. Hash *roottable; /* list of all tables */
  57. stringtable strt; /* hash table for strings */
  58. stringtable udt; /* hash table for udata */
  59. Hash *gt; /* table for globals */
  60. struct IM *IMtable; /* table for tag methods */
  61. int last_tag; /* last used tag in IMtable */
  62. struct Ref *refArray; /* locked objects */
  63. int refSize; /* size of refArray */
  64. int refFree; /* list of free positions in refArray */
  65. unsigned long GCthreshold;
  66. unsigned long nblocks; /* number of `blocks' currently allocated */
  67. lua_Hook callhook;
  68. lua_Hook linehook;
  69. int allowhooks;
  70. };
  71. #endif