lstate.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /*
  2. ** $Id: lstate.h,v 1.36 2000/08/08 20:42: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. ** marks for Reference array
  15. */
  16. #define NONEXT -1 /* to end the free list */
  17. #define HOLD -2
  18. #define COLLECTED -3
  19. #define LOCK -4
  20. struct Ref {
  21. TObject o;
  22. int st; /* can be LOCK, HOLD, COLLECTED, or next (for free list) */
  23. };
  24. /*
  25. ** chain list of long jumps
  26. */
  27. struct lua_longjmp {
  28. jmp_buf b;
  29. struct lua_longjmp *previous;
  30. volatile int status; /* error code */
  31. StkId base;
  32. };
  33. typedef struct stringtable {
  34. int size;
  35. lint32 nuse; /* number of elements */
  36. TString **hash;
  37. } stringtable;
  38. struct lua_State {
  39. /* thread-specific state */
  40. StkId top; /* first free slot in the stack */
  41. StkId stack; /* stack base */
  42. StkId stack_last; /* last free slot in the stack */
  43. int stacksize;
  44. StkId Cbase; /* base for current C function */
  45. struct lua_longjmp *errorJmp; /* current error recover point */
  46. char *Mbuffer; /* global buffer */
  47. size_t Mbuffbase; /* current first position of Mbuffer */
  48. size_t Mbuffsize; /* size of Mbuffer */
  49. size_t Mbuffnext; /* next position to fill in Mbuffer */
  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. lua_Hook callhook;
  65. lua_Hook linehook;
  66. int allowhooks;
  67. };
  68. #endif