lstate.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /*
  2. ** $Id: lstate.h,v 1.3 1997/11/26 20:28:22 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. TObject *functofind; /* auxiliar */
  40. GCnode rootproto; /* list of all prototypes */
  41. GCnode rootcl; /* list of all closures */
  42. GCnode roottable; /* list of all tables */
  43. GCnode rootglobal; /* list of strings with global values */
  44. stringtable *string_root; /* array of hash tables for strings and udata */
  45. struct IM *IMtable; /* table for tag methods */
  46. int IMtable_size; /* size of IMtable */
  47. int last_tag; /* last used tag in IMtable */
  48. struct FuncState *mainState, *currState; /* point to local structs in yacc */
  49. struct LexState *lexstate; /* point to local struct in yacc */
  50. struct ref *refArray; /* locked objects */
  51. int refSize; /* size of refArray */
  52. unsigned long GCthreshold;
  53. unsigned long nblocks; /* number of 'blocks' currently allocated */
  54. char *Mbuffer; /* global buffer, used by luaM_buffer */
  55. unsigned long Mbuffsize; /* size of Mbuffer */
  56. } LState;
  57. extern LState *lua_state;
  58. #define L lua_state
  59. #endif