aboutsummaryrefslogtreecommitdiff
path: root/ltable.c
diff options
context:
space:
mode:
Diffstat (limited to 'ltable.c')
-rw-r--r--ltable.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/ltable.c b/ltable.c
index b55201bb..2866ed25 100644
--- a/ltable.c
+++ b/ltable.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ltable.c,v 1.118 2002/08/30 19:09:21 roberto Exp roberto $ 2** $Id: ltable.c,v 1.119 2002/09/02 19:54:49 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*/
@@ -111,7 +111,7 @@ static int arrayindex (const TObject *key) {
111** elements in the array part, then elements in the hash part. The 111** elements in the array part, then elements in the hash part. The
112** beginning and end of a traversal are signalled by -1. 112** beginning and end of a traversal are signalled by -1.
113*/ 113*/
114static int luaH_index (lua_State *L, Table *t, const TObject *key) { 114static int luaH_index (lua_State *L, Table *t, StkId key) {
115 int i; 115 int i;
116 if (ttisnil(key)) return -1; /* first iteration */ 116 if (ttisnil(key)) return -1; /* first iteration */
117 i = arrayindex(key); 117 i = arrayindex(key);
@@ -129,19 +129,19 @@ static int luaH_index (lua_State *L, Table *t, const TObject *key) {
129} 129}
130 130
131 131
132int luaH_next (lua_State *L, Table *t, TObject *key) { 132int luaH_next (lua_State *L, Table *t, StkId key) {
133 int i = luaH_index(L, t, key); /* find original element */ 133 int i = luaH_index(L, t, key); /* find original element */
134 for (i++; i < t->sizearray; i++) { /* try first array part */ 134 for (i++; i < t->sizearray; i++) { /* try first array part */
135 if (!ttisnil(&t->array[i])) { /* a non-nil value? */ 135 if (!ttisnil(&t->array[i])) { /* a non-nil value? */
136 setnvalue(key, i+1); 136 setnvalue(key, i+1);
137 setobj(key+1, &t->array[i]); 137 setobj2s(key+1, &t->array[i]);
138 return 1; 138 return 1;
139 } 139 }
140 } 140 }
141 for (i -= t->sizearray; i < sizenode(t); i++) { /* then hash part */ 141 for (i -= t->sizearray; i < sizenode(t); i++) { /* then hash part */
142 if (!ttisnil(val(node(t, i)))) { /* a non-nil value? */ 142 if (!ttisnil(val(node(t, i)))) { /* a non-nil value? */
143 setobj(key, key(node(t, i))); 143 setobj2s(key, key(node(t, i)));
144 setobj(key+1, val(node(t, i))); 144 setobj2s(key+1, val(node(t, i)));
145 return 1; 145 return 1;
146 } 146 }
147 } 147 }
@@ -270,7 +270,7 @@ static void resize (lua_State *L, Table *t, int nasize, int nhsize) {
270 /* re-insert elements from vanishing slice */ 270 /* re-insert elements from vanishing slice */
271 for (i=nasize; i<oldasize; i++) { 271 for (i=nasize; i<oldasize; i++) {
272 if (!ttisnil(&t->array[i])) 272 if (!ttisnil(&t->array[i]))
273 setobj(luaH_setnum(L, t, i+1), &t->array[i]); 273 setobjt2t(luaH_setnum(L, t, i+1), &t->array[i]);
274 } 274 }
275 /* shrink array */ 275 /* shrink array */
276 luaM_reallocvector(L, t->array, oldasize, nasize, TObject); 276 luaM_reallocvector(L, t->array, oldasize, nasize, TObject);
@@ -279,7 +279,7 @@ static void resize (lua_State *L, Table *t, int nasize, int nhsize) {
279 for (i = twoto(oldhsize) - 1; i >= 0; i--) { 279 for (i = twoto(oldhsize) - 1; i >= 0; i--) {
280 Node *old = nold+i; 280 Node *old = nold+i;
281 if (!ttisnil(val(old))) 281 if (!ttisnil(val(old)))
282 setobj(luaH_set(L, t, key(old)), val(old)); 282 setobjt2t(luaH_set(L, t, key(old)), val(old));
283 } 283 }
284 if (oldhsize) 284 if (oldhsize)
285 luaM_freearray(L, nold, twoto(oldhsize), Node); /* free old array */ 285 luaM_freearray(L, nold, twoto(oldhsize), Node); /* free old array */
@@ -373,7 +373,7 @@ static TObject *newkey (lua_State *L, Table *t, const TObject *key) {
373 mp = n; 373 mp = n;
374 } 374 }
375 } 375 }
376 setobj(key(mp), key); 376 setobj2t(key(mp), key);
377 lua_assert(ttisnil(val(mp))); 377 lua_assert(ttisnil(val(mp)));
378 for (;;) { /* correct `firstfree' */ 378 for (;;) { /* correct `firstfree' */
379 if (ttisnil(key(t->firstfree))) 379 if (ttisnil(key(t->firstfree)))