summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2003-03-18 09:50:04 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2003-03-18 09:50:04 -0300
commitab9e062928f7b9201fd5366a34a4fc855d13bc46 (patch)
tree37224175e0dd89badfccc6d745bdb5c850fd34c4
parent81cdbabf095e23bf9fb5cef842967acb499b7bcc (diff)
downloadlua-ab9e062928f7b9201fd5366a34a4fc855d13bc46.tar.gz
lua-ab9e062928f7b9201fd5366a34a4fc855d13bc46.tar.bz2
lua-ab9e062928f7b9201fd5366a34a4fc855d13bc46.zip
name changes to avoid name collision between macros and variables
-rw-r--r--ldebug.c8
-rw-r--r--lfunc.c6
-rw-r--r--lfunc.h4
-rw-r--r--lgc.c46
-rw-r--r--lobject.h3
-rw-r--r--lstate.c6
-rw-r--r--ltable.c72
-rw-r--r--ltable.h8
8 files changed, 76 insertions, 77 deletions
diff --git a/ldebug.c b/ldebug.c
index c7279db6..be96e666 100644
--- a/ldebug.c
+++ b/ldebug.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ldebug.c,v 1.147 2003/02/27 12:32:30 roberto Exp roberto $ 2** $Id: ldebug.c,v 1.148 2003/03/18 12:24:38 roberto Exp roberto $
3** Debug Interface 3** Debug Interface
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -178,9 +178,9 @@ static const char *travglobals (lua_State *L, const TObject *o) {
178 Table *g = hvalue(gt(L)); 178 Table *g = hvalue(gt(L));
179 int i = sizenode(g); 179 int i = sizenode(g);
180 while (i--) { 180 while (i--) {
181 Node *n = node(g, i); 181 Node *n = gnode(g, i);
182 if (luaO_rawequalObj(o, val(n)) && ttisstring(key(n))) 182 if (luaO_rawequalObj(o, gval(n)) && ttisstring(gkey(n)))
183 return getstr(tsvalue(key(n))); 183 return getstr(tsvalue(gkey(n)));
184 } 184 }
185 return NULL; 185 return NULL;
186} 186}
diff --git a/lfunc.c b/lfunc.c
index 2ce2f047..0d15aa3b 100644
--- a/lfunc.c
+++ b/lfunc.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lfunc.c,v 1.65 2002/12/19 11:11:55 roberto Exp roberto $ 2** $Id: lfunc.c,v 1.66 2003/02/11 10:46:24 roberto Exp roberto $
3** Auxiliary functions to manipulate prototypes and closures 3** Auxiliary functions to manipulate prototypes and closures
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -35,11 +35,11 @@ Closure *luaF_newCclosure (lua_State *L, int nelems) {
35} 35}
36 36
37 37
38Closure *luaF_newLclosure (lua_State *L, int nelems, TObject *gt) { 38Closure *luaF_newLclosure (lua_State *L, int nelems, TObject *e) {
39 Closure *c = cast(Closure *, luaM_malloc(L, sizeLclosure(nelems))); 39 Closure *c = cast(Closure *, luaM_malloc(L, sizeLclosure(nelems)));
40 luaC_link(L, valtogco(c), LUA_TFUNCTION); 40 luaC_link(L, valtogco(c), LUA_TFUNCTION);
41 c->l.isC = 0; 41 c->l.isC = 0;
42 c->l.g = *gt; 42 c->l.g = *e;
43 c->l.nupvalues = cast(lu_byte, nelems); 43 c->l.nupvalues = cast(lu_byte, nelems);
44 return c; 44 return c;
45} 45}
diff --git a/lfunc.h b/lfunc.h
index 9daf115c..34aa9d1a 100644
--- a/lfunc.h
+++ b/lfunc.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lfunc.h,v 1.19 2001/11/29 20:22:22 roberto Exp roberto $ 2** $Id: lfunc.h,v 1.20 2002/06/20 20:41:46 roberto Exp roberto $
3** Auxiliary functions to manipulate prototypes and closures 3** Auxiliary functions to manipulate prototypes and closures
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -13,7 +13,7 @@
13 13
14Proto *luaF_newproto (lua_State *L); 14Proto *luaF_newproto (lua_State *L);
15Closure *luaF_newCclosure (lua_State *L, int nelems); 15Closure *luaF_newCclosure (lua_State *L, int nelems);
16Closure *luaF_newLclosure (lua_State *L, int nelems, TObject *gt); 16Closure *luaF_newLclosure (lua_State *L, int nelems, TObject *e);
17UpVal *luaF_findupval (lua_State *L, StkId level); 17UpVal *luaF_findupval (lua_State *L, StkId level);
18void luaF_close (lua_State *L, StkId level); 18void luaF_close (lua_State *L, StkId level);
19void luaF_freeproto (lua_State *L, Proto *f); 19void luaF_freeproto (lua_State *L, Proto *f);
diff --git a/lgc.c b/lgc.c
index 01e8032f..71cacd1d 100644
--- a/lgc.c
+++ b/lgc.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lgc.c,v 1.168 2003/02/10 17:32:50 roberto Exp roberto $ 2** $Id: lgc.c,v 1.169 2003/02/11 10:46:24 roberto Exp roberto $
3** Garbage Collector 3** Garbage Collector
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -27,7 +27,7 @@ typedef struct GCState {
27 GCObject *wk; /* list of traversed key-weak tables (to be cleared) */ 27 GCObject *wk; /* list of traversed key-weak tables (to be cleared) */
28 GCObject *wv; /* list of traversed value-weak tables */ 28 GCObject *wv; /* list of traversed value-weak tables */
29 GCObject *wkv; /* list of traversed key-value weak tables */ 29 GCObject *wkv; /* list of traversed key-value weak tables */
30 global_State *G; 30 global_State *g;
31} GCState; 31} GCState;
32 32
33 33
@@ -102,7 +102,7 @@ static void reallymarkobject (GCState *st, GCObject *o) {
102 102
103static void marktmu (GCState *st) { 103static void marktmu (GCState *st) {
104 GCObject *u; 104 GCObject *u;
105 for (u = st->G->tmudata; u; u = u->gch.next) { 105 for (u = st->g->tmudata; u; u = u->gch.next) {
106 unmark(u); /* may be marked, if left from previous GC */ 106 unmark(u); /* may be marked, if left from previous GC */
107 reallymarkobject(st, u); 107 reallymarkobject(st, u);
108 } 108 }
@@ -138,9 +138,9 @@ void luaC_separateudata (lua_State *L) {
138 138
139 139
140static void removekey (Node *n) { 140static void removekey (Node *n) {
141 setnilvalue(val(n)); /* remove corresponding value ... */ 141 setnilvalue(gval(n)); /* remove corresponding value ... */
142 if (iscollectable(key(n))) 142 if (iscollectable(gkey(n)))
143 setttype(key(n), LUA_TNONE); /* dead key; remove it */ 143 setttype(gkey(n), LUA_TNONE); /* dead key; remove it */
144} 144}
145 145
146 146
@@ -150,8 +150,8 @@ static void traversetable (GCState *st, Table *h) {
150 int weakvalue = 0; 150 int weakvalue = 0;
151 const TObject *mode; 151 const TObject *mode;
152 markvalue(st, h->metatable); 152 markvalue(st, h->metatable);
153 lua_assert(h->lsizenode || h->node == st->G->dummynode); 153 lua_assert(h->lsizenode || h->node == st->g->dummynode);
154 mode = gfasttm(st->G, h->metatable, TM_MODE); 154 mode = gfasttm(st->g, h->metatable, TM_MODE);
155 if (mode && ttisstring(mode)) { /* is there a weak mode? */ 155 if (mode && ttisstring(mode)) { /* is there a weak mode? */
156 weakkey = (strchr(svalue(mode), 'k') != NULL); 156 weakkey = (strchr(svalue(mode), 'k') != NULL);
157 weakvalue = (strchr(svalue(mode), 'v') != NULL); 157 weakvalue = (strchr(svalue(mode), 'v') != NULL);
@@ -167,17 +167,17 @@ static void traversetable (GCState *st, Table *h) {
167 } 167 }
168 } 168 }
169 if (!weakvalue) { 169 if (!weakvalue) {
170 i = sizearray(h); 170 i = h->sizearray;
171 while (i--) 171 while (i--)
172 markobject(st, &h->array[i]); 172 markobject(st, &h->array[i]);
173 } 173 }
174 i = sizenode(h); 174 i = sizenode(h);
175 while (i--) { 175 while (i--) {
176 Node *n = node(h, i); 176 Node *n = gnode(h, i);
177 if (!ttisnil(val(n))) { 177 if (!ttisnil(gval(n))) {
178 lua_assert(!ttisnil(key(n))); 178 lua_assert(!ttisnil(gkey(n)));
179 condmarkobject(st, key(n), !weakkey); 179 condmarkobject(st, gkey(n), !weakkey);
180 condmarkobject(st, val(n), !weakvalue); 180 condmarkobject(st, gval(n), !weakvalue);
181 } 181 }
182 } 182 }
183} 183}
@@ -303,8 +303,8 @@ static void cleartablekeys (GCObject *l) {
303 int i = sizenode(h); 303 int i = sizenode(h);
304 lua_assert(h->marked & KEYWEAK); 304 lua_assert(h->marked & KEYWEAK);
305 while (i--) { 305 while (i--) {
306 Node *n = node(h, i); 306 Node *n = gnode(h, i);
307 if (!valismarked(key(n))) /* key was collected? */ 307 if (!valismarked(gkey(n))) /* key was collected? */
308 removekey(n); /* remove entry from table */ 308 removekey(n); /* remove entry from table */
309 } 309 }
310 l = h->gclist; 310 l = h->gclist;
@@ -318,7 +318,7 @@ static void cleartablekeys (GCObject *l) {
318static void cleartablevalues (GCObject *l) { 318static void cleartablevalues (GCObject *l) {
319 while (l) { 319 while (l) {
320 Table *h = gcotoh(l); 320 Table *h = gcotoh(l);
321 int i = sizearray(h); 321 int i = h->sizearray;
322 lua_assert(h->marked & VALUEWEAK); 322 lua_assert(h->marked & VALUEWEAK);
323 while (i--) { 323 while (i--) {
324 TObject *o = &h->array[i]; 324 TObject *o = &h->array[i];
@@ -327,8 +327,8 @@ static void cleartablevalues (GCObject *l) {
327 } 327 }
328 i = sizenode(h); 328 i = sizenode(h);
329 while (i--) { 329 while (i--) {
330 Node *n = node(h, i); 330 Node *n = gnode(h, i);
331 if (!valismarked(val(n))) /* value was collected? */ 331 if (!valismarked(gval(n))) /* value was collected? */
332 removekey(n); /* remove entry from table */ 332 removekey(n); /* remove entry from table */
333 } 333 }
334 l = h->gclist; 334 l = h->gclist;
@@ -441,11 +441,11 @@ void luaC_sweep (lua_State *L, int all) {
441 441
442/* mark root set */ 442/* mark root set */
443static void markroot (GCState *st, lua_State *L) { 443static void markroot (GCState *st, lua_State *L) {
444 global_State *G = st->G; 444 global_State *g = st->g;
445 markobject(st, defaultmeta(L)); 445 markobject(st, defaultmeta(L));
446 markobject(st, registry(L)); 446 markobject(st, registry(L));
447 traversestack(st, G->mainthread); 447 traversestack(st, g->mainthread);
448 if (L != G->mainthread) /* another thread is running? */ 448 if (L != g->mainthread) /* another thread is running? */
449 markvalue(st, L); /* cannot collect it */ 449 markvalue(st, L); /* cannot collect it */
450} 450}
451 451
@@ -453,7 +453,7 @@ static void markroot (GCState *st, lua_State *L) {
453static void mark (lua_State *L) { 453static void mark (lua_State *L) {
454 GCState st; 454 GCState st;
455 GCObject *wkv; 455 GCObject *wkv;
456 st.G = G(L); 456 st.g = G(L);
457 st.tmark = NULL; 457 st.tmark = NULL;
458 st.wkv = st.wk = st.wv = NULL; 458 st.wkv = st.wk = st.wv = NULL;
459 markroot(&st, L); 459 markroot(&st, L);
diff --git a/lobject.h b/lobject.h
index 420eb6a9..1263f583 100644
--- a/lobject.h
+++ b/lobject.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lobject.h,v 1.157 2003/02/11 10:46:24 roberto Exp roberto $ 2** $Id: lobject.h,v 1.158 2003/02/18 16:02:56 roberto Exp roberto $
3** Type definitions for Lua objects 3** Type definitions for Lua objects
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -316,7 +316,6 @@ typedef struct Table {
316 316
317#define twoto(x) (1<<(x)) 317#define twoto(x) (1<<(x))
318#define sizenode(t) (twoto((t)->lsizenode)) 318#define sizenode(t) (twoto((t)->lsizenode))
319#define sizearray(t) ((t)->sizearray)
320 319
321 320
322 321
diff --git a/lstate.c b/lstate.c
index 150eb14d..63bbb497 100644
--- a/lstate.c
+++ b/lstate.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lstate.c,v 1.120 2003/02/13 16:07:57 roberto Exp roberto $ 2** $Id: lstate.c,v 1.121 2003/02/28 19:45:15 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*/
@@ -104,8 +104,8 @@ static void f_luaopen (lua_State *L, void *ud) {
104 g->rootgc = NULL; 104 g->rootgc = NULL;
105 g->rootudata = NULL; 105 g->rootudata = NULL;
106 g->tmudata = NULL; 106 g->tmudata = NULL;
107 setnilvalue(key(g->dummynode)); 107 setnilvalue(gkey(g->dummynode));
108 setnilvalue(val(g->dummynode)); 108 setnilvalue(gval(g->dummynode));
109 g->dummynode->next = NULL; 109 g->dummynode->next = NULL;
110 g->nblocks = sizeof(lua_State) + sizeof(global_State); 110 g->nblocks = sizeof(lua_State) + sizeof(global_State);
111 stack_init(L, L); /* init stack */ 111 stack_init(L, L); /* init stack */
diff --git a/ltable.c b/ltable.c
index 28634cc5..50f33719 100644
--- a/ltable.c
+++ b/ltable.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ltable.c,v 1.127 2003/02/13 16:08:32 roberto Exp roberto $ 2** $Id: ltable.c,v 1.128 2003/02/20 20:12:39 roberto Exp roberto $
3** Lua tables (hash) 3** Lua tables (hash)
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -56,15 +56,15 @@
56 56
57 57
58#define hashnum(t,n) \ 58#define hashnum(t,n) \
59 (node(t, lmod(cast(lu_hash, cast(ls_hash, n)), sizenode(t)))) 59 (gnode(t, lmod(cast(lu_hash, cast(ls_hash, n)), sizenode(t))))
60#define hashstr(t,str) (node(t, lmod((str)->tsv.hash, sizenode(t)))) 60#define hashstr(t,str) (gnode(t, lmod((str)->tsv.hash, sizenode(t))))
61#define hashboolean(t,p) (node(t, lmod(p, sizenode(t)))) 61#define hashboolean(t,p) (gnode(t, lmod(p, sizenode(t))))
62 62
63/* 63/*
64** avoid modulus by power of 2 for pointers, as they tend to have many 64** avoid modulus by power of 2 for pointers, as they tend to have many
65** 2 factors. 65** 2 factors.
66*/ 66*/
67#define hashpointer(t,p) (node(t, (IntPoint(p) % ((sizenode(t)-1)|1)))) 67#define hashpointer(t,p) (gnode(t, (IntPoint(p) % ((sizenode(t)-1)|1))))
68 68
69 69
70/* 70/*
@@ -122,7 +122,7 @@ static int luaH_index (lua_State *L, Table *t, StkId key) {
122 if (v == &luaO_nilobject) 122 if (v == &luaO_nilobject)
123 luaG_runerror(L, "invalid key for `next'"); 123 luaG_runerror(L, "invalid key for `next'");
124 i = cast(int, (cast(const lu_byte *, v) - 124 i = cast(int, (cast(const lu_byte *, v) -
125 cast(const lu_byte *, val(node(t, 0)))) / sizeof(Node)); 125 cast(const lu_byte *, gval(gnode(t, 0)))) / sizeof(Node));
126 return i + t->sizearray; /* hash elements are numbered after array ones */ 126 return i + t->sizearray; /* hash elements are numbered after array ones */
127 } 127 }
128} 128}
@@ -138,9 +138,9 @@ int luaH_next (lua_State *L, Table *t, StkId key) {
138 } 138 }
139 } 139 }
140 for (i -= t->sizearray; i < sizenode(t); i++) { /* then hash part */ 140 for (i -= t->sizearray; i < sizenode(t); i++) { /* then hash part */
141 if (!ttisnil(val(node(t, i)))) { /* a non-nil value? */ 141 if (!ttisnil(gval(gnode(t, i)))) { /* a non-nil value? */
142 setobj2s(key, key(node(t, i))); 142 setobj2s(key, gkey(gnode(t, i)));
143 setobj2s(key+1, val(node(t, i))); 143 setobj2s(key+1, gval(gnode(t, i)));
144 return 1; 144 return 1;
145 } 145 }
146 } 146 }
@@ -201,8 +201,8 @@ static void numuse (const Table *t, int *narray, int *nhash) {
201 i = sizenode(t); 201 i = sizenode(t);
202 while (i--) { 202 while (i--) {
203 Node *n = &t->node[i]; 203 Node *n = &t->node[i];
204 if (!ttisnil(val(n))) { 204 if (!ttisnil(gval(n))) {
205 int k = arrayindex(key(n)); 205 int k = arrayindex(gkey(n));
206 if (k >= 0) { /* is `key' an appropriate array index? */ 206 if (k >= 0) { /* is `key' an appropriate array index? */
207 nums[luaO_log2(k-1)+1]++; /* count as such */ 207 nums[luaO_log2(k-1)+1]++; /* count as such */
208 (*narray)++; 208 (*narray)++;
@@ -230,20 +230,20 @@ static void setnodevector (lua_State *L, Table *t, int lsize) {
230 luaG_runerror(L, "table overflow"); 230 luaG_runerror(L, "table overflow");
231 if (lsize == 0) { /* no elements to hash part? */ 231 if (lsize == 0) { /* no elements to hash part? */
232 t->node = G(L)->dummynode; /* use common `dummynode' */ 232 t->node = G(L)->dummynode; /* use common `dummynode' */
233 lua_assert(ttisnil(key(t->node))); /* assert invariants: */ 233 lua_assert(ttisnil(gkey(t->node))); /* assert invariants: */
234 lua_assert(ttisnil(val(t->node))); 234 lua_assert(ttisnil(gval(t->node)));
235 lua_assert(t->node->next == NULL); /* (`dummynode' must be empty) */ 235 lua_assert(t->node->next == NULL); /* (`dummynode' must be empty) */
236 } 236 }
237 else { 237 else {
238 t->node = luaM_newvector(L, size, Node); 238 t->node = luaM_newvector(L, size, Node);
239 for (i=0; i<size; i++) { 239 for (i=0; i<size; i++) {
240 t->node[i].next = NULL; 240 t->node[i].next = NULL;
241 setnilvalue(key(node(t, i))); 241 setnilvalue(gkey(gnode(t, i)));
242 setnilvalue(val(node(t, i))); 242 setnilvalue(gval(gnode(t, i)));
243 } 243 }
244 } 244 }
245 t->lsizenode = cast(lu_byte, lsize); 245 t->lsizenode = cast(lu_byte, lsize);
246 t->firstfree = node(t, size-1); /* first free position to be used */ 246 t->firstfree = gnode(t, size-1); /* first free position to be used */
247} 247}
248 248
249 249
@@ -259,8 +259,8 @@ static void resize (lua_State *L, Table *t, int nasize, int nhsize) {
259 lua_assert(t->node == G(L)->dummynode); 259 lua_assert(t->node == G(L)->dummynode);
260 temp[0] = t->node[0]; /* copy it to `temp' */ 260 temp[0] = t->node[0]; /* copy it to `temp' */
261 nold = temp; 261 nold = temp;
262 setnilvalue(key(G(L)->dummynode)); /* restate invariant */ 262 setnilvalue(gkey(G(L)->dummynode)); /* restate invariant */
263 setnilvalue(val(G(L)->dummynode)); 263 setnilvalue(gval(G(L)->dummynode));
264 lua_assert(G(L)->dummynode->next == NULL); 264 lua_assert(G(L)->dummynode->next == NULL);
265 } 265 }
266 if (nasize > oldasize) /* array part must grow? */ 266 if (nasize > oldasize) /* array part must grow? */
@@ -281,8 +281,8 @@ static void resize (lua_State *L, Table *t, int nasize, int nhsize) {
281 /* re-insert elements in hash part */ 281 /* re-insert elements in hash part */
282 for (i = twoto(oldhsize) - 1; i >= 0; i--) { 282 for (i = twoto(oldhsize) - 1; i >= 0; i--) {
283 Node *old = nold+i; 283 Node *old = nold+i;
284 if (!ttisnil(val(old))) 284 if (!ttisnil(gval(old)))
285 setobjt2t(luaH_set(L, t, key(old)), val(old)); 285 setobjt2t(luaH_set(L, t, gkey(old)), gval(old));
286 } 286 }
287 if (oldhsize) 287 if (oldhsize)
288 luaM_freearray(L, nold, twoto(oldhsize), Node); /* free old array */ 288 luaM_freearray(L, nold, twoto(oldhsize), Node); /* free old array */
@@ -332,7 +332,7 @@ void luaH_free (lua_State *L, Table *t) {
332** (because gc can call `remove' during a table traversal) 332** (because gc can call `remove' during a table traversal)
333*/ 333*/
334void luaH_remove (Table *t, Node *e) { 334void luaH_remove (Table *t, Node *e) {
335 Node *mp = luaH_mainposition(t, key(e)); 335 Node *mp = luaH_mainposition(t, gkey(e));
336 if (e != mp) { /* element not in its main position? */ 336 if (e != mp) { /* element not in its main position? */
337 while (mp->next != e) mp = mp->next; /* find previous */ 337 while (mp->next != e) mp = mp->next; /* find previous */
338 mp->next = e->next; /* remove `e' from its list */ 338 mp->next = e->next; /* remove `e' from its list */
@@ -340,8 +340,8 @@ void luaH_remove (Table *t, Node *e) {
340 else { 340 else {
341 if (e->next != NULL) ?? 341 if (e->next != NULL) ??
342 } 342 }
343 lua_assert(ttisnil(val(node))); 343 lua_assert(ttisnil(gval(node)));
344 setnilvalue(key(e)); /* clear node `e' */ 344 setnilvalue(gkey(e)); /* clear node `e' */
345 e->next = NULL; 345 e->next = NULL;
346} 346}
347#endif 347#endif
@@ -357,8 +357,8 @@ void luaH_remove (Table *t, Node *e) {
357static TObject *newkey (lua_State *L, Table *t, const TObject *key) { 357static TObject *newkey (lua_State *L, Table *t, const TObject *key) {
358 TObject *val; 358 TObject *val;
359 Node *mp = luaH_mainposition(t, key); 359 Node *mp = luaH_mainposition(t, key);
360 if (!ttisnil(val(mp))) { /* main position is not free? */ 360 if (!ttisnil(gval(mp))) { /* main position is not free? */
361 Node *othern = luaH_mainposition(t, key(mp)); /* `mp' of colliding node */ 361 Node *othern = luaH_mainposition(t, gkey(mp)); /* `mp' of colliding node */
362 Node *n = t->firstfree; /* get a free place */ 362 Node *n = t->firstfree; /* get a free place */
363 if (othern != mp) { /* is colliding node out of its main position? */ 363 if (othern != mp) { /* is colliding node out of its main position? */
364 /* yes; move colliding node into free position */ 364 /* yes; move colliding node into free position */
@@ -366,7 +366,7 @@ static TObject *newkey (lua_State *L, Table *t, const TObject *key) {
366 othern->next = n; /* redo the chain with `n' in place of `mp' */ 366 othern->next = n; /* redo the chain with `n' in place of `mp' */
367 *n = *mp; /* copy colliding node into free pos. (mp->next also goes) */ 367 *n = *mp; /* copy colliding node into free pos. (mp->next also goes) */
368 mp->next = NULL; /* now `mp' is free */ 368 mp->next = NULL; /* now `mp' is free */
369 setnilvalue(val(mp)); 369 setnilvalue(gval(mp));
370 } 370 }
371 else { /* colliding node is in its own main position */ 371 else { /* colliding node is in its own main position */
372 /* new node will go into free position */ 372 /* new node will go into free position */
@@ -375,16 +375,16 @@ static TObject *newkey (lua_State *L, Table *t, const TObject *key) {
375 mp = n; 375 mp = n;
376 } 376 }
377 } 377 }
378 setobj2t(key(mp), key); /* write barrier */ 378 setobj2t(gkey(mp), key); /* write barrier */
379 lua_assert(ttisnil(val(mp))); 379 lua_assert(ttisnil(gval(mp)));
380 for (;;) { /* correct `firstfree' */ 380 for (;;) { /* correct `firstfree' */
381 if (ttisnil(key(t->firstfree))) 381 if (ttisnil(gkey(t->firstfree)))
382 return val(mp); /* OK; table still has a free place */ 382 return gval(mp); /* OK; table still has a free place */
383 else if (t->firstfree == t->node) break; /* cannot decrement from here */ 383 else if (t->firstfree == t->node) break; /* cannot decrement from here */
384 else (t->firstfree)--; 384 else (t->firstfree)--;
385 } 385 }
386 /* no more free places; must create one */ 386 /* no more free places; must create one */
387 setbvalue(val(mp), 0); /* avoid new key being removed */ 387 setbvalue(gval(mp), 0); /* avoid new key being removed */
388 rehash(L, t); /* grow table */ 388 rehash(L, t); /* grow table */
389 val = cast(TObject *, luaH_get(t, key)); /* get new position */ 389 val = cast(TObject *, luaH_get(t, key)); /* get new position */
390 lua_assert(ttisboolean(val)); 390 lua_assert(ttisboolean(val));
@@ -401,7 +401,7 @@ static const TObject *luaH_getany (Table *t, const TObject *key) {
401 else { 401 else {
402 Node *n = luaH_mainposition(t, key); 402 Node *n = luaH_mainposition(t, key);
403 do { /* check whether `key' is somewhere in the chain */ 403 do { /* check whether `key' is somewhere in the chain */
404 if (luaO_rawequalObj(key(n), key)) return val(n); /* that's it */ 404 if (luaO_rawequalObj(gkey(n), key)) return gval(n); /* that's it */
405 else n = n->next; 405 else n = n->next;
406 } while (n); 406 } while (n);
407 return &luaO_nilobject; 407 return &luaO_nilobject;
@@ -418,8 +418,8 @@ const TObject *luaH_getnum (Table *t, int key) {
418 else { 418 else {
419 Node *n = hashnum(t, key); 419 Node *n = hashnum(t, key);
420 do { /* check whether `key' is somewhere in the chain */ 420 do { /* check whether `key' is somewhere in the chain */
421 if (ttisnumber(key(n)) && nvalue(key(n)) == (lua_Number)key) 421 if (ttisnumber(gkey(n)) && nvalue(gkey(n)) == (lua_Number)key)
422 return val(n); /* that's it */ 422 return gval(n); /* that's it */
423 else n = n->next; 423 else n = n->next;
424 } while (n); 424 } while (n);
425 return &luaO_nilobject; 425 return &luaO_nilobject;
@@ -433,8 +433,8 @@ const TObject *luaH_getnum (Table *t, int key) {
433const TObject *luaH_getstr (Table *t, TString *key) { 433const TObject *luaH_getstr (Table *t, TString *key) {
434 Node *n = hashstr(t, key); 434 Node *n = hashstr(t, key);
435 do { /* check whether `key' is somewhere in the chain */ 435 do { /* check whether `key' is somewhere in the chain */
436 if (ttisstring(key(n)) && tsvalue(key(n)) == key) 436 if (ttisstring(gkey(n)) && tsvalue(gkey(n)) == key)
437 return val(n); /* that's it */ 437 return gval(n); /* that's it */
438 else n = n->next; 438 else n = n->next;
439 } while (n); 439 } while (n);
440 return &luaO_nilobject; 440 return &luaO_nilobject;
diff --git a/ltable.h b/ltable.h
index 2f865453..3218b69b 100644
--- a/ltable.h
+++ b/ltable.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ltable.h,v 1.42 2002/05/27 20:35:40 roberto Exp roberto $ 2** $Id: ltable.h,v 1.43 2002/11/07 16:03:33 roberto Exp roberto $
3** Lua tables (hash) 3** Lua tables (hash)
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -10,9 +10,9 @@
10#include "lobject.h" 10#include "lobject.h"
11 11
12 12
13#define node(t,i) (&(t)->node[i]) 13#define gnode(t,i) (&(t)->node[i])
14#define key(n) (&(n)->i_key) 14#define gkey(n) (&(n)->i_key)
15#define val(n) (&(n)->i_val) 15#define gval(n) (&(n)->i_val)
16 16
17 17
18const TObject *luaH_getnum (Table *t, int key); 18const TObject *luaH_getnum (Table *t, int key);