lstate.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /*
  2. ** $Id: lstate.h,v 1.23 1999/11/22 13:12:07 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. ** "jmp_buf" may be an array, so it is better to make sure it has an
  15. ** address (and not that it *is* an address...)
  16. */
  17. struct lua_longjmp {
  18. jmp_buf b;
  19. };
  20. /*
  21. ** stack layout for C point of view:
  22. ** [lua2C, lua2C+num) - `array' lua2C
  23. ** [lua2C+num, base) - space for extra lua_Objects
  24. ** [base, L->top) - `stack' C2Lua
  25. */
  26. struct C_Lua_Stack {
  27. StkId base;
  28. StkId lua2C;
  29. int num;
  30. };
  31. typedef struct stringtable {
  32. int size;
  33. int nuse; /* number of elements (including EMPTYs) */
  34. TaggedString **hash;
  35. } stringtable;
  36. struct lua_State {
  37. /* thread-specific state */
  38. StkId top; /* first free slot in the stack */
  39. StkId stack; /* stack base */
  40. StkId stack_last; /* last free slot in the stack */
  41. struct C_Lua_Stack Cstack; /* C2lua struct */
  42. struct lua_longjmp *errorJmp; /* current error recover point */
  43. char *Mbuffer; /* global buffer */
  44. int Mbuffbase; /* current first position of Mbuffer */
  45. int Mbuffsize; /* size of Mbuffer */
  46. int Mbuffnext; /* next position to fill in Mbuffer */
  47. struct C_Lua_Stack *Cblocks;
  48. int numCblocks; /* number of nested Cblocks */
  49. int debug;
  50. lua_CHFunction callhook;
  51. lua_LHFunction linehook;
  52. /* global state */
  53. TProtoFunc *rootproto; /* list of all prototypes */
  54. Closure *rootcl; /* list of all closures */
  55. Hash *roottable; /* list of all tables */
  56. GlobalVar *rootglobal; /* list of global variables */
  57. stringtable *string_root; /* array of hash tables for strings and udata */
  58. struct IM *IMtable; /* table for tag methods */
  59. int last_tag; /* last used tag in IMtable */
  60. struct ref *refArray; /* locked objects */
  61. int refSize; /* size of refArray */
  62. int refFree; /* list of free positions in refArray */
  63. unsigned long GCthreshold;
  64. unsigned long nblocks; /* number of 'blocks' currently allocated */
  65. };
  66. #endif