lstate.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /*
  2. ** $Id: lstate.h,v 1.40 2000/09/29 12:42:13 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. struct TM; /* defined in ltm.h */
  25. typedef struct stringtable {
  26. int size;
  27. lint32 nuse; /* number of elements */
  28. TString **hash;
  29. } stringtable;
  30. struct lua_State {
  31. /* thread-specific state */
  32. StkId top; /* first free slot in the stack */
  33. StkId stack; /* stack base */
  34. StkId stack_last; /* last free slot in the stack */
  35. int stacksize;
  36. StkId Cbase; /* base for current C function */
  37. struct lua_longjmp *errorJmp; /* current error recover point */
  38. char *Mbuffer; /* global buffer */
  39. size_t Mbuffsize; /* size of Mbuffer */
  40. /* global state */
  41. Proto *rootproto; /* list of all prototypes */
  42. Closure *rootcl; /* list of all closures */
  43. Hash *roottable; /* list of all tables */
  44. stringtable strt; /* hash table for strings */
  45. stringtable udt; /* hash table for udata */
  46. Hash *gt; /* table for globals */
  47. struct TM *TMtable; /* table for tag methods */
  48. int last_tag; /* last used tag in TMtable */
  49. struct Ref *refArray; /* locked objects */
  50. int refSize; /* size of refArray */
  51. int refFree; /* list of free positions in refArray */
  52. unsigned long GCthreshold;
  53. unsigned long nblocks; /* number of `bytes' currently allocated */
  54. lua_Hook callhook;
  55. lua_Hook linehook;
  56. int allowhooks;
  57. };
  58. #endif