lstate.h 2.0 KB

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