2
0

lstate.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /*
  2. ** $Id: lstate.h,v 1.30 2000/03/10 18:37:44 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. typedef TObject *StkId; /* index to stack elements */
  13. /*
  14. ** `jmp_buf' may be an array, so it is better to make sure it has an
  15. ** address (and not that it *is* an address...)
  16. */
  17. struct lua_longjmp {
  18. jmp_buf b;
  19. };
  20. /*
  21. ** stack layout for C point of view:
  22. ** [lua2C, lua2C+num) - `array' lua2C
  23. ** [lua2C+num, base) - space for extra lua_Objects (limbo)
  24. ** [base, L->top) - `stack' C2Lua
  25. */
  26. struct C_Lua_Stack {
  27. StkId base;
  28. StkId lua2C;
  29. int num;
  30. };
  31. typedef struct stringtable {
  32. int size;
  33. int nuse; /* number of elements (including EMPTYs) */
  34. TString **hash;
  35. } stringtable;
  36. struct lua_State {
  37. /* thread-specific state */
  38. StkId top; /* first free slot in the stack */
  39. StkId stack; /* stack base */
  40. StkId stack_last; /* last free slot in the stack */
  41. int stacksize;
  42. struct C_Lua_Stack Cstack; /* C2lua struct */
  43. struct lua_longjmp *errorJmp; /* current error recover point */
  44. char *Mbuffer; /* global buffer */
  45. int Mbuffbase; /* current first position of Mbuffer */
  46. int Mbuffsize; /* size of Mbuffer */
  47. int Mbuffnext; /* next position to fill in Mbuffer */
  48. struct C_Lua_Stack *Cblocks;
  49. int numCblocks; /* number of nested Cblocks */
  50. /* global state */
  51. Proto *rootproto; /* list of all prototypes */
  52. Closure *rootcl; /* list of all closures */
  53. Hash *roottable; /* list of all tables */
  54. GlobalVar *rootglobal; /* list of global variables */
  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. int refFree; /* list of free positions in refArray */
  61. unsigned long GCthreshold;
  62. unsigned long nblocks; /* number of `blocks' currently allocated */
  63. int debug;
  64. lua_Hook callhook;
  65. lua_Hook linehook;
  66. int allowhooks;
  67. };
  68. #endif