lstate.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /*
  2. ** $Id: lstate.h,v 1.32 2000/05/08 19:32:53 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 (limbo)
  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. long nuse; /* number of elements */
  34. TString **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. int stacksize;
  42. struct C_Lua_Stack Cstack; /* C2lua struct */
  43. struct lua_longjmp *errorJmp; /* current error recover point */
  44. char *Mbuffer; /* global buffer */
  45. int Mbuffbase; /* current first position of Mbuffer */
  46. int Mbuffsize; /* size of Mbuffer */
  47. int Mbuffnext; /* next position to fill in Mbuffer */
  48. struct C_Lua_Stack *Cblocks;
  49. int numCblocks; /* number of nested Cblocks */
  50. /* global state */
  51. Proto *rootproto; /* list of all prototypes */
  52. Closure *rootcl; /* list of all closures */
  53. Hash *roottable; /* list of all tables */
  54. stringtable strt; /* hash table for strings */
  55. stringtable udt; /* hash table for udata */
  56. Hash *gt; /* table for globals */
  57. struct IM *IMtable; /* table for tag methods */
  58. int last_tag; /* last used tag in IMtable */
  59. struct Ref *refArray; /* locked objects */
  60. int refSize; /* size of refArray */
  61. int refFree; /* list of free positions in refArray */
  62. unsigned long GCthreshold;
  63. unsigned long nblocks; /* number of `blocks' currently allocated */
  64. int debug;
  65. lua_Hook callhook;
  66. lua_Hook linehook;
  67. int allowhooks;
  68. };
  69. #endif