lstate.h 2.1 KB

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