aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lgc.c6
-rw-r--r--ltable.c14
-rw-r--r--ltable.h4
-rw-r--r--ltests.c4
4 files changed, 13 insertions, 15 deletions
diff --git a/lgc.c b/lgc.c
index dd6af6c5..531094f0 100644
--- a/lgc.c
+++ b/lgc.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lgc.c,v 2.98 2010/06/04 13:25:10 roberto Exp roberto $ 2** $Id: lgc.c,v 2.99 2010/06/07 16:55:34 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*/
@@ -371,7 +371,7 @@ static int traverseephemeron (global_State *g, Table *h) {
371 if (ttisnil(gval(n))) /* entry is empty? */ 371 if (ttisnil(gval(n))) /* entry is empty? */
372 removeentry(n); /* remove it */ 372 removeentry(n); /* remove it */
373 else if (valiswhite(gval(n))) { /* value not marked yet? */ 373 else if (valiswhite(gval(n))) { /* value not marked yet? */
374 if (iscleared(key2tval(n), 1)) /* key is not marked (yet)? */ 374 if (iscleared(gkey(n), 1)) /* key is not marked (yet)? */
375 hasclears = 1; /* may have to propagate mark from key to value */ 375 hasclears = 1; /* may have to propagate mark from key to value */
376 else { /* key is marked, so mark value */ 376 else { /* key is marked, so mark value */
377 marked = 1; /* value was not marked */ 377 marked = 1; /* value was not marked */
@@ -574,7 +574,7 @@ static void cleartable (GCObject *l) {
574 } 574 }
575 for (n = gnode(h, 0); n < limit; n++) { 575 for (n = gnode(h, 0); n < limit; n++) {
576 if (!ttisnil(gval(n)) && /* non-empty entry? */ 576 if (!ttisnil(gval(n)) && /* non-empty entry? */
577 (iscleared(key2tval(n), 1) || iscleared(gval(n), 0))) { 577 (iscleared(gkey(n), 1) || iscleared(gval(n), 0))) {
578 setnilvalue(gval(n)); /* remove value ... */ 578 setnilvalue(gval(n)); /* remove value ... */
579 removeentry(n); /* and remove entry from table */ 579 removeentry(n); /* and remove entry from table */
580 } 580 }
diff --git a/ltable.c b/ltable.c
index 7a909b27..f9967661 100644
--- a/ltable.c
+++ b/ltable.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ltable.c,v 2.50 2010/04/18 13:22:48 roberto Exp roberto $ 2** $Id: ltable.c,v 2.51 2010/06/04 13:05:29 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*/
@@ -148,7 +148,7 @@ static int findindex (lua_State *L, Table *t, StkId key) {
148 Node *n = mainposition(t, key); 148 Node *n = mainposition(t, key);
149 do { /* check whether `key' is somewhere in the chain */ 149 do { /* check whether `key' is somewhere in the chain */
150 /* key may be dead already, but it is ok to use it in `next' */ 150 /* key may be dead already, but it is ok to use it in `next' */
151 if (luaO_rawequalObj(key2tval(n), key) || 151 if (luaO_rawequalObj(gkey(n), key) ||
152 (ttype(gkey(n)) == LUA_TDEADKEY && iscollectable(key) && 152 (ttype(gkey(n)) == LUA_TDEADKEY && iscollectable(key) &&
153 gcvalue(gkey(n)) == gcvalue(key))) { 153 gcvalue(gkey(n)) == gcvalue(key))) {
154 i = cast_int(n - gnode(t, 0)); /* key index in hash table */ 154 i = cast_int(n - gnode(t, 0)); /* key index in hash table */
@@ -174,7 +174,7 @@ int luaH_next (lua_State *L, Table *t, StkId key) {
174 } 174 }
175 for (i -= t->sizearray; i < sizenode(t); i++) { /* then hash part */ 175 for (i -= t->sizearray; i < sizenode(t); i++) { /* then hash part */
176 if (!ttisnil(gval(gnode(t, i)))) { /* a non-nil value? */ 176 if (!ttisnil(gval(gnode(t, i)))) { /* a non-nil value? */
177 setobj2s(L, key, key2tval(gnode(t, i))); 177 setobj2s(L, key, gkey(gnode(t, i)));
178 setobj2s(L, key+1, gval(gnode(t, i))); 178 setobj2s(L, key+1, gval(gnode(t, i)));
179 return 1; 179 return 1;
180 } 180 }
@@ -255,7 +255,7 @@ static int numusehash (const Table *t, int *nums, int *pnasize) {
255 while (i--) { 255 while (i--) {
256 Node *n = &t->node[i]; 256 Node *n = &t->node[i];
257 if (!ttisnil(gval(n))) { 257 if (!ttisnil(gval(n))) {
258 ause += countint(key2tval(n), nums); 258 ause += countint(gkey(n), nums);
259 totaluse++; 259 totaluse++;
260 } 260 }
261 } 261 }
@@ -321,7 +321,7 @@ void luaH_resize (lua_State *L, Table *t, int nasize, int nhsize) {
321 for (i = twoto(oldhsize) - 1; i >= 0; i--) { 321 for (i = twoto(oldhsize) - 1; i >= 0; i--) {
322 Node *old = nold+i; 322 Node *old = nold+i;
323 if (!ttisnil(gval(old))) 323 if (!ttisnil(gval(old)))
324 setobjt2t(L, luaH_set(L, t, key2tval(old)), gval(old)); 324 setobjt2t(L, luaH_set(L, t, gkey(old)), gval(old));
325 } 325 }
326 if (!isdummy(nold)) 326 if (!isdummy(nold))
327 luaM_freearray(L, nold, twoto(oldhsize)); /* free old array */ 327 luaM_freearray(L, nold, twoto(oldhsize)); /* free old array */
@@ -406,7 +406,7 @@ static TValue *newkey (lua_State *L, Table *t, const TValue *key) {
406 return luaH_set(L, t, key); /* re-insert key into grown table */ 406 return luaH_set(L, t, key); /* re-insert key into grown table */
407 } 407 }
408 lua_assert(!isdummy(n)); 408 lua_assert(!isdummy(n));
409 othern = mainposition(t, key2tval(mp)); 409 othern = mainposition(t, gkey(mp));
410 if (othern != mp) { /* is colliding node out of its main position? */ 410 if (othern != mp) { /* is colliding node out of its main position? */
411 /* yes; move colliding node into free position */ 411 /* yes; move colliding node into free position */
412 while (gnext(othern) != mp) othern = gnext(othern); /* find previous */ 412 while (gnext(othern) != mp) othern = gnext(othern); /* find previous */
@@ -481,7 +481,7 @@ const TValue *luaH_get (Table *t, const TValue *key) {
481 default: { 481 default: {
482 Node *n = mainposition(t, key); 482 Node *n = mainposition(t, key);
483 do { /* check whether `key' is somewhere in the chain */ 483 do { /* check whether `key' is somewhere in the chain */
484 if (luaO_rawequalObj(key2tval(n), key)) 484 if (luaO_rawequalObj(gkey(n), key))
485 return gval(n); /* that's it */ 485 return gval(n); /* that's it */
486 else n = gnext(n); 486 else n = gnext(n);
487 } while (n); 487 } while (n);
diff --git a/ltable.h b/ltable.h
index 751e7d64..823940b4 100644
--- a/ltable.h
+++ b/ltable.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ltable.h,v 2.12 2009/08/07 16:17:41 roberto Exp roberto $ 2** $Id: ltable.h,v 2.13 2009/11/06 17:07:48 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*/
@@ -15,8 +15,6 @@
15#define gval(n) (&(n)->i_val) 15#define gval(n) (&(n)->i_val)
16#define gnext(n) ((n)->i_key.nk.next) 16#define gnext(n) ((n)->i_key.nk.next)
17 17
18#define key2tval(n) (&(n)->i_key.tvk)
19
20 18
21LUAI_FUNC const TValue *luaH_getint (Table *t, int key); 19LUAI_FUNC const TValue *luaH_getint (Table *t, int key);
22LUAI_FUNC TValue *luaH_setint (lua_State *L, Table *t, int key); 20LUAI_FUNC TValue *luaH_setint (lua_State *L, Table *t, int key);
diff --git a/ltests.c b/ltests.c
index 2b38b5e0..7bafe829 100644
--- a/ltests.c
+++ b/ltests.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ltests.c,v 2.108 2010/05/17 20:10:17 roberto Exp roberto $ 2** $Id: ltests.c,v 2.109 2010/06/10 21:29:47 roberto Exp roberto $
3** Internal Module for Debugging of the Lua Implementation 3** Internal Module for Debugging of the Lua Implementation
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -689,7 +689,7 @@ static int table_query (lua_State *L) {
689 if (!ttisnil(gval(gnode(t, i))) || 689 if (!ttisnil(gval(gnode(t, i))) ||
690 ttisnil(gkey(gnode(t, i))) || 690 ttisnil(gkey(gnode(t, i))) ||
691 ttisnumber(gkey(gnode(t, i)))) { 691 ttisnumber(gkey(gnode(t, i)))) {
692 pushobject(L, key2tval(gnode(t, i))); 692 pushobject(L, gkey(gnode(t, i)));
693 } 693 }
694 else 694 else
695 lua_pushliteral(L, "<undef>"); 695 lua_pushliteral(L, "<undef>");