lstate.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /*
  2. ** $Id: lstate.h,v 1.18 1999/05/11 14:19:32 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. #define GARBAGE_BLOCK 150
  13. typedef int StkId; /* index to stack elements */
  14. /*
  15. ** "jmp_buf" may be an array, so it is better to make sure it has an
  16. ** address (and not that it *is* an address...)
  17. */
  18. struct lua_longjmp {
  19. jmp_buf b;
  20. };
  21. struct Stack {
  22. TObject *top;
  23. TObject *stack;
  24. TObject *last;
  25. };
  26. struct C_Lua_Stack {
  27. StkId base; /* when Lua calls C or C calls Lua, points to */
  28. /* the first slot after the last parameter. */
  29. StkId lua2C; /* points to first element of "array" lua2C */
  30. int num; /* size of "array" lua2C */
  31. };
  32. typedef struct stringtable {
  33. int size;
  34. int nuse; /* number of elements (including EMPTYs) */
  35. TaggedString **hash;
  36. } stringtable;
  37. enum Status {LOCK, HOLD, FREE, COLLECTED};
  38. struct ref {
  39. TObject o;
  40. enum Status status;
  41. };
  42. struct lua_State {
  43. /* thread-specific state */
  44. struct Stack stack; /* Lua stack */
  45. struct C_Lua_Stack Cstack; /* C2lua struct */
  46. struct lua_longjmp *errorJmp; /* current error recover point */
  47. char *Mbuffer; /* global buffer */
  48. int Mbuffbase; /* current first position of Mbuffer */
  49. int Mbuffsize; /* size of Mbuffer */
  50. int Mbuffnext; /* next position to fill in Mbuffer */
  51. struct C_Lua_Stack *Cblocks;
  52. int numCblocks; /* number of nested Cblocks */
  53. int debug;
  54. lua_CHFunction callhook;
  55. lua_LHFunction linehook;
  56. /* global state */
  57. GCnode rootproto; /* list of all prototypes */
  58. GCnode rootcl; /* list of all closures */
  59. GCnode roottable; /* list of all tables */
  60. GCnode rootglobal; /* list of strings with global values */
  61. stringtable *string_root; /* array of hash tables for strings and udata */
  62. struct IM *IMtable; /* table for tag methods */
  63. int last_tag; /* last used tag in IMtable */
  64. struct ref *refArray; /* locked objects */
  65. int refSize; /* size of refArray */
  66. unsigned long GCthreshold;
  67. unsigned long nblocks; /* number of 'blocks' currently allocated */
  68. };
  69. #define L lua_state
  70. #endif