lstate.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /*
  2. ** $Id: lstate.h,v 1.55 2001/03/07 18:09:25 roberto Exp roberto $
  3. ** Global State
  4. ** See Copyright Notice in lua.h
  5. */
  6. #ifndef lstate_h
  7. #define lstate_h
  8. #include "lobject.h"
  9. #include "lua.h"
  10. #include "luadebug.h"
  11. /*
  12. ** macros that control all entries and exits from Lua core machine
  13. ** (mainly for thread syncronization)
  14. */
  15. #ifndef lua_lock
  16. #define lua_lock(L) ((void) 0)
  17. #endif
  18. #ifndef lua_unlock
  19. #define lua_unlock(L) ((void) 0)
  20. #endif
  21. /*
  22. ** macro to allow the inclusion of user information in Lua state
  23. */
  24. #ifndef LUA_USERSTATE
  25. #define LUA_USERSTATE
  26. #endif
  27. struct lua_longjmp; /* defined in ldo.c */
  28. struct TM; /* defined in ltm.h */
  29. typedef struct stringtable {
  30. int size;
  31. ls_nstr nuse; /* number of elements */
  32. TString **hash;
  33. } stringtable;
  34. /*
  35. ** `global state', shared by all threads of this state
  36. */
  37. typedef struct global_State {
  38. void *Mbuffer; /* global buffer */
  39. size_t Mbuffsize; /* size of Mbuffer */
  40. Proto *rootproto; /* list of all prototypes */
  41. Closure *rootcl; /* list of all closures */
  42. Hash *roottable; /* list of all tables */
  43. stringtable strt; /* hash table for strings */
  44. stringtable udt; /* hash table for udata */
  45. Hash *type2tag; /* hash table from type names to tags */
  46. Hash *registry; /* (strong) registry table */
  47. Hash *weakregistry; /* weakregistry table */
  48. struct TM *TMtable; /* table for tag methods */
  49. int sizeTM; /* size of TMtable */
  50. int ntag; /* number of tags in TMtable */
  51. lu_mem GCthreshold;
  52. lu_mem nblocks; /* number of `bytes' currently allocated */
  53. } global_State;
  54. /*
  55. ** `per thread' state
  56. */
  57. struct lua_State {
  58. LUA_USERSTATE
  59. StkId top; /* first free slot in the stack */
  60. CallInfo *ci; /* call info for current function */
  61. StkId stack_last; /* last free slot in the stack */
  62. Hash *gt; /* table for globals */
  63. global_State *G;
  64. StkId stack; /* stack base */
  65. int stacksize;
  66. lua_Hook callhook;
  67. lua_Hook linehook;
  68. int allowhooks;
  69. struct lua_longjmp *errorJmp; /* current error recover point */
  70. lua_State *next; /* circular double linked list of states */
  71. lua_State *previous;
  72. CallInfo basefunc;
  73. };
  74. #define G(L) (L->G)
  75. #endif