1 /*
2 ** $Id: lstate.h,v 1.1 2002/02/14 10:46:59 jcatki Exp $
3 ** Global State
4 ** See Copyright Notice in lua.h
5 */
6 
7 #ifndef lstate_h
8 #define lstate_h
9 
10 #include "lobject.h"
11 #include "lua.h"
12 #include "luadebug.h"
13 
14 
15 
16 typedef TObject *StkId;  /* index to stack elements */
17 
18 
19 /*
20 ** marks for Reference array
21 */
22 #define NONEXT          -1      /* to end the free list */
23 #define HOLD            -2
24 #define COLLECTED       -3
25 #define LOCK            -4
26 
27 
28 struct Ref {
29   TObject o;
30   int st;  /* can be LOCK, HOLD, COLLECTED, or next (for free list) */
31 };
32 
33 
34 struct lua_longjmp;  /* defined in ldo.c */
35 struct TM;  /* defined in ltm.h */
36 
37 
38 typedef struct stringtable {
39   int size;
40   lint32 nuse;  /* number of elements */
41   TString **hash;
42 } stringtable;
43 
44 
45 
46 struct lua_State {
47   /* thread-specific state */
48   StkId top;  /* first free slot in the stack */
49   StkId stack;  /* stack base */
50   StkId stack_last;  /* last free slot in the stack */
51   int stacksize;
52   StkId Cbase;  /* base for current C function */
53   struct lua_longjmp *errorJmp;  /* current error recover point */
54   char *Mbuffer;  /* global buffer */
55   size_t Mbuffsize;  /* size of Mbuffer */
56   /* global state */
57   Proto *rootproto;  /* list of all prototypes */
58   Closure *rootcl;  /* list of all closures */
59   Hash *roottable;  /* list of all tables */
60   stringtable strt;  /* hash table for strings */
61   stringtable udt;   /* hash table for udata */
62   Hash *gt;  /* table for globals */
63   struct TM *TMtable;  /* table for tag methods */
64   int last_tag;  /* last used tag in TMtable */
65   struct Ref *refArray;  /* locked objects */
66   int refSize;  /* size of refArray */
67   int refFree;  /* list of free positions in refArray */
68   unsigned long GCthreshold;
69   unsigned long nblocks;  /* number of `bytes' currently allocated */
70   lua_Hook callhook;
71   lua_Hook linehook;
72   int allowhooks;
73 };
74 
75 
76 #endif
77 
78