Imported from ../lua-3.1.tar.gz.
[lua.git] / src / lstate.h
blob71d956fa897041510922b3b034f90ca1d0f56574
1 /*
2 ** $Id: lstate.h,v 1.11 1998/06/24 13:33:00 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"
16 #define MAX_C_BLOCKS 10
18 #define GARBAGE_BLOCK 150
21 typedef int StkId; /* index to stack elements */
23 struct Stack {
24 TObject *top;
25 TObject *stack;
26 TObject *last;
29 struct C_Lua_Stack {
30 StkId base; /* when Lua calls C or C calls Lua, points to */
31 /* the first slot after the last parameter. */
32 StkId lua2C; /* points to first element of "array" lua2C */
33 int num; /* size of "array" lua2C */
37 typedef struct {
38 int size;
39 int nuse; /* number of elements (including EMPTYs) */
40 TaggedString **hash;
41 } stringtable;
44 enum Status {LOCK, HOLD, FREE, COLLECTED};
46 struct ref {
47 TObject o;
48 enum Status status;
52 struct lua_State {
53 /* thread-specific state */
54 struct Stack stack; /* Lua stack */
55 struct C_Lua_Stack Cstack; /* C2lua struct */
56 jmp_buf *errorJmp; /* current error recover point */
57 char *Mbuffer; /* global buffer */
58 char *Mbuffbase; /* current first position of Mbuffer */
59 int Mbuffsize; /* size of Mbuffer */
60 int Mbuffnext; /* next position to fill in Mbuffer */
61 struct C_Lua_Stack Cblocks[MAX_C_BLOCKS];
62 int numCblocks; /* number of nested Cblocks */
63 /* global state */
64 TObject errorim; /* error tag method */
65 GCnode rootproto; /* list of all prototypes */
66 GCnode rootcl; /* list of all closures */
67 GCnode roottable; /* list of all tables */
68 GCnode rootglobal; /* list of strings with global values */
69 stringtable *string_root; /* array of hash tables for strings and udata */
70 struct IM *IMtable; /* table for tag methods */
71 int IMtable_size; /* size of IMtable */
72 int last_tag; /* last used tag in IMtable */
73 struct ref *refArray; /* locked objects */
74 int refSize; /* size of refArray */
75 unsigned long GCthreshold;
76 unsigned long nblocks; /* number of 'blocks' currently allocated */
80 extern lua_State *lua_state;
83 #define L lua_state
86 #endif