diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2002-10-22 14:58:14 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2002-10-22 14:58:14 -0300 |
commit | 81bc5711a8b71ced34eef8750deb0ce4475d5cd5 (patch) | |
tree | 452e7c82585045989f041cb78c0fcdb7cdd5f724 /lstate.h | |
parent | 6a77a6b73f0f06c4396e9b60d44b064b999cb06a (diff) | |
download | lua-81bc5711a8b71ced34eef8750deb0ce4475d5cd5.tar.gz lua-81bc5711a8b71ced34eef8750deb0ce4475d5cd5.tar.bz2 lua-81bc5711a8b71ced34eef8750deb0ce4475d5cd5.zip |
only one instance of registry and default metatable per global state
Diffstat (limited to 'lstate.h')
-rw-r--r-- | lstate.h | 19 |
1 files changed, 7 insertions, 12 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lstate.h,v 1.96 2002/09/19 13:03:53 roberto Exp roberto $ | 2 | ** $Id: lstate.h,v 1.97 2002/10/08 18:46:08 roberto Exp roberto $ |
3 | ** Global State | 3 | ** Global State |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -48,21 +48,14 @@ | |||
48 | struct lua_longjmp; /* defined in ldo.c */ | 48 | struct lua_longjmp; /* defined in ldo.c */ |
49 | 49 | ||
50 | 50 | ||
51 | |||
52 | /* | ||
53 | ** array of `global' objects | ||
54 | */ | ||
55 | |||
56 | #define NUMGLOBS 3 | ||
57 | |||
58 | /* default meta table (both for tables and udata) */ | 51 | /* default meta table (both for tables and udata) */ |
59 | #define defaultmeta(L) (L->globs) | 52 | #define defaultmeta(L) (&G(L)->_defaultmeta) |
60 | 53 | ||
61 | /* table of globals */ | 54 | /* table of globals */ |
62 | #define gt(L) (L->globs + 1) | 55 | #define gt(L) (&L->_gt) |
63 | 56 | ||
64 | /* registry */ | 57 | /* registry */ |
65 | #define registry(L) (L->globs + 2) | 58 | #define registry(L) (&G(L)->_registry) |
66 | 59 | ||
67 | 60 | ||
68 | /* extra stack space to handle TM calls and some other extras */ | 61 | /* extra stack space to handle TM calls and some other extras */ |
@@ -129,6 +122,8 @@ typedef struct global_State { | |||
129 | lu_mem GCthreshold; | 122 | lu_mem GCthreshold; |
130 | lu_mem nblocks; /* number of `bytes' currently allocated */ | 123 | lu_mem nblocks; /* number of `bytes' currently allocated */ |
131 | lua_CFunction panic; /* to be called in unprotected errors */ | 124 | lua_CFunction panic; /* to be called in unprotected errors */ |
125 | TObject _registry; | ||
126 | TObject _defaultmeta; | ||
132 | Node dummynode[1]; /* common node array for all empty tables */ | 127 | Node dummynode[1]; /* common node array for all empty tables */ |
133 | TString *tmname[TM_N]; /* array with tag-method names */ | 128 | TString *tmname[TM_N]; /* array with tag-method names */ |
134 | } global_State; | 129 | } global_State; |
@@ -151,12 +146,12 @@ struct lua_State { | |||
151 | unsigned long hookmask; | 146 | unsigned long hookmask; |
152 | ls_count hookcount; | 147 | ls_count hookcount; |
153 | lua_Hook hook; | 148 | lua_Hook hook; |
149 | TObject _gt; /* table of globals */ | ||
154 | GCObject *openupval; /* list of open upvalues in this stack */ | 150 | GCObject *openupval; /* list of open upvalues in this stack */ |
155 | struct lua_longjmp *errorJmp; /* current error recover point */ | 151 | struct lua_longjmp *errorJmp; /* current error recover point */ |
156 | ptrdiff_t errfunc; /* current error handling function (stack index) */ | 152 | ptrdiff_t errfunc; /* current error handling function (stack index) */ |
157 | lua_State *next; /* circular double linked list of states */ | 153 | lua_State *next; /* circular double linked list of states */ |
158 | lua_State *previous; | 154 | lua_State *previous; |
159 | TObject globs[NUMGLOBS]; /* registry, table of globals, etc. */ | ||
160 | }; | 155 | }; |
161 | 156 | ||
162 | 157 | ||