lstate.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /*
  2. ** $Id: lstate.h,v 1.37 2000/08/28 17:57:04 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 Mbuffsize; /* size of Mbuffer */
  48. /* global state */
  49. Proto *rootproto; /* list of all prototypes */
  50. Closure *rootcl; /* list of all closures */
  51. Hash *roottable; /* list of all tables */
  52. stringtable strt; /* hash table for strings */
  53. stringtable udt; /* hash table for udata */
  54. Hash *gt; /* table for globals */
  55. struct IM *IMtable; /* table for tag methods */
  56. int last_tag; /* last used tag in IMtable */
  57. struct Ref *refArray; /* locked objects */
  58. int refSize; /* size of refArray */
  59. int refFree; /* list of free positions in refArray */
  60. unsigned long GCthreshold;
  61. unsigned long nblocks; /* number of `blocks' currently allocated */
  62. lua_Hook callhook;
  63. lua_Hook linehook;
  64. int allowhooks;
  65. };
  66. #endif