lstate.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /*
  2. ** $Id: lstate.h,v 1.39 2000/09/25 16:22:42 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. typedef TObject *StkId; /* index to stack elements */
  12. /*
  13. ** marks for Reference array
  14. */
  15. #define NONEXT -1 /* to end the free list */
  16. #define HOLD -2
  17. #define COLLECTED -3
  18. #define LOCK -4
  19. struct Ref {
  20. TObject o;
  21. int st; /* can be LOCK, HOLD, COLLECTED, or next (for free list) */
  22. };
  23. struct lua_longjmp; /* defined in ldo.c */
  24. typedef struct stringtable {
  25. int size;
  26. lint32 nuse; /* number of elements */
  27. TString **hash;
  28. } stringtable;
  29. struct lua_State {
  30. /* thread-specific state */
  31. StkId top; /* first free slot in the stack */
  32. StkId stack; /* stack base */
  33. StkId stack_last; /* last free slot in the stack */
  34. int stacksize;
  35. StkId Cbase; /* base for current C function */
  36. struct lua_longjmp *errorJmp; /* current error recover point */
  37. char *Mbuffer; /* global buffer */
  38. size_t Mbuffsize; /* size of Mbuffer */
  39. /* global state */
  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 *gt; /* table for globals */
  46. struct IM *IMtable; /* table for tag methods */
  47. int last_tag; /* last used tag in IMtable */
  48. struct Ref *refArray; /* locked objects */
  49. int refSize; /* size of refArray */
  50. int refFree; /* list of free positions in refArray */
  51. unsigned long GCthreshold;
  52. unsigned long nblocks; /* number of `bytes' currently allocated */
  53. lua_Hook callhook;
  54. lua_Hook linehook;
  55. int allowhooks;
  56. };
  57. #endif