lstate.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /*
  2. ** $Id: lstate.h,v 1.15 1999/02/25 15:17:01 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 last_tag; /* last used tag in IMtable */
  58. struct ref *refArray; /* locked objects */
  59. int refSize; /* size of refArray */
  60. unsigned long GCthreshold;
  61. unsigned long nblocks; /* number of 'blocks' currently allocated */
  62. };
  63. #define L lua_state
  64. #endif