lstate.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /*
  2. ** $Id: lstate.h,v 1.6 1997/12/17 20:48:58 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. GCnode rootproto; /* list of all prototypes */
  38. GCnode rootcl; /* list of all closures */
  39. GCnode roottable; /* list of all tables */
  40. GCnode rootglobal; /* list of strings with global values */
  41. stringtable *string_root; /* array of hash tables for strings and udata */
  42. struct IM *IMtable; /* table for tag methods */
  43. int IMtable_size; /* size of IMtable */
  44. int last_tag; /* last used tag in IMtable */
  45. struct FuncState *mainState, *currState; /* point to local structs in yacc */
  46. struct LexState *lexstate; /* point to local struct in yacc */
  47. struct ref *refArray; /* locked objects */
  48. int refSize; /* size of refArray */
  49. unsigned long GCthreshold;
  50. unsigned long nblocks; /* number of 'blocks' currently allocated */
  51. char *Mbuffer; /* global buffer */
  52. char *Mbuffbase; /* current first position of Mbuffer */
  53. int Mbuffsize; /* size of Mbuffer */
  54. int Mbuffnext; /* next position to fill in Mbuffer */
  55. struct C_Lua_Stack Cblocks[MAX_C_BLOCKS];
  56. int numCblocks; /* number of nested Cblocks */
  57. } LState;
  58. extern LState *lua_state;
  59. #define L lua_state
  60. #endif