Imported from ../lua-3.2.tar.gz.
[lua.git] / src / lstate.h
blob168257dd6ccbfe213c7ffd7dc4a9c254684693ce
1 /*
2 ** $Id: lstate.h,v 1.19 1999/05/11 20:08:20 roberto Exp $
3 ** Global State
4 ** See Copyright Notice in lua.h
5 */
7 #ifndef lstate_h
8 #define lstate_h
10 #include <setjmp.h>
12 #include "lobject.h"
13 #include "lua.h"
14 #include "luadebug.h"
17 #define GARBAGE_BLOCK 150
20 typedef int StkId; /* index to stack elements */
24 ** "jmp_buf" may be an array, so it is better to make sure it has an
25 ** address (and not that it *is* an address...)
27 struct lua_longjmp {
28 jmp_buf b;
32 struct Stack {
33 TObject *top;
34 TObject *stack;
35 TObject *last;
38 struct C_Lua_Stack {
39 StkId base; /* when Lua calls C or C calls Lua, points to */
40 /* the first slot after the last parameter. */
41 StkId lua2C; /* points to first element of "array" lua2C */
42 int num; /* size of "array" lua2C */
46 typedef struct stringtable {
47 int size;
48 int nuse; /* number of elements (including EMPTYs) */
49 TaggedString **hash;
50 } stringtable;
53 enum Status {LOCK, HOLD, FREE, COLLECTED};
55 struct ref {
56 TObject o;
57 enum Status status;
61 struct lua_State {
62 /* thread-specific state */
63 struct Stack stack; /* Lua stack */
64 struct C_Lua_Stack Cstack; /* C2lua struct */
65 struct lua_longjmp *errorJmp; /* current error recover point */
66 char *Mbuffer; /* global buffer */
67 int Mbuffbase; /* current first position of Mbuffer */
68 int Mbuffsize; /* size of Mbuffer */
69 int Mbuffnext; /* next position to fill in Mbuffer */
70 struct C_Lua_Stack *Cblocks;
71 int numCblocks; /* number of nested Cblocks */
72 int debug;
73 lua_CHFunction callhook;
74 lua_LHFunction linehook;
75 /* global state */
76 GCnode rootproto; /* list of all prototypes */
77 GCnode rootcl; /* list of all closures */
78 GCnode roottable; /* list of all tables */
79 GCnode rootglobal; /* list of strings with global values */
80 stringtable *string_root; /* array of hash tables for strings and udata */
81 struct IM *IMtable; /* table for tag methods */
82 int last_tag; /* last used tag in IMtable */
83 struct ref *refArray; /* locked objects */
84 int refSize; /* size of refArray */
85 unsigned long GCthreshold;
86 unsigned long nblocks; /* number of 'blocks' currently allocated */
90 #define L lua_state
93 #endif