lstate.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /*
  2. ** $Id: lstate.h,v 1.9 1998/06/02 20:37: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 "lobject.h"
  9. #include "lua.h"
  10. #define MAX_C_BLOCKS 10
  11. #define GARBAGE_BLOCK 150
  12. typedef int StkId; /* index to stack elements */
  13. struct Stack {
  14. TObject *top;
  15. TObject *stack;
  16. TObject *last;
  17. };
  18. struct C_Lua_Stack {
  19. StkId base; /* when Lua calls C or C calls Lua, points to */
  20. /* the first slot after the last parameter. */
  21. StkId lua2C; /* points to first element of "array" lua2C */
  22. int num; /* size of "array" lua2C */
  23. };
  24. typedef struct {
  25. int size;
  26. int nuse; /* number of elements (including EMPTYs) */
  27. TaggedString **hash;
  28. } stringtable;
  29. struct ref {
  30. TObject o;
  31. enum {LOCK, HOLD, FREE, COLLECTED} status;
  32. };
  33. struct lua_State {
  34. /* thread-specific state */
  35. struct Stack stack; /* Lua stack */
  36. struct C_Lua_Stack Cstack; /* C2lua struct */
  37. void *errorJmp; /* current error recover point */
  38. char *Mbuffer; /* global buffer */
  39. char *Mbuffbase; /* current first position of Mbuffer */
  40. int Mbuffsize; /* size of Mbuffer */
  41. int Mbuffnext; /* next position to fill in Mbuffer */
  42. struct C_Lua_Stack Cblocks[MAX_C_BLOCKS];
  43. int numCblocks; /* number of nested Cblocks */
  44. /* global state */
  45. TObject errorim; /* error tag method */
  46. GCnode rootproto; /* list of all prototypes */
  47. GCnode rootcl; /* list of all closures */
  48. GCnode roottable; /* list of all tables */
  49. GCnode rootglobal; /* list of strings with global values */
  50. stringtable *string_root; /* array of hash tables for strings and udata */
  51. struct IM *IMtable; /* table for tag methods */
  52. int IMtable_size; /* size of IMtable */
  53. int last_tag; /* last used tag in IMtable */
  54. struct ref *refArray; /* locked objects */
  55. int refSize; /* size of refArray */
  56. unsigned long GCthreshold;
  57. unsigned long nblocks; /* number of 'blocks' currently allocated */
  58. };
  59. extern lua_State *lua_state;
  60. #define L lua_state
  61. #endif