lstate.h 2.0 KB

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