diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2017-06-29 12:06:44 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2017-06-29 12:06:44 -0300 |
| commit | f96497397addca22f22a6ba6eeabc906be43f16b (patch) | |
| tree | af8d27b9af36dfe0b0b6e0f765ea90b95b110efc /ltable.c | |
| parent | 5a1c8d8ef343bf0157851a4832c2c937b812b64f (diff) | |
| download | lua-f96497397addca22f22a6ba6eeabc906be43f16b.tar.gz lua-f96497397addca22f22a6ba6eeabc906be43f16b.tar.bz2 lua-f96497397addca22f22a6ba6eeabc906be43f16b.zip | |
new type 'StackValue' for stack elements
(we may want to put extra info there in the future)
Diffstat (limited to 'ltable.c')
| -rw-r--r-- | ltable.c | 12 |
1 files changed, 6 insertions, 6 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: ltable.c,v 2.123 2017/06/09 16:48:44 roberto Exp roberto $ | 2 | ** $Id: ltable.c,v 2.124 2017/06/12 14:21:44 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 | */ |
| @@ -211,7 +211,7 @@ static unsigned int arrayindex (lua_Integer k) { | |||
| 211 | ** elements in the array part, then elements in the hash part. The | 211 | ** elements in the array part, then elements in the hash part. The |
| 212 | ** beginning of a traversal is signaled by 0. | 212 | ** beginning of a traversal is signaled by 0. |
| 213 | */ | 213 | */ |
| 214 | static unsigned int findindex (lua_State *L, Table *t, StkId key) { | 214 | static unsigned int findindex (lua_State *L, Table *t, TValue *key) { |
| 215 | unsigned int i; | 215 | unsigned int i; |
| 216 | if (ttisnil(key)) return 0; /* first iteration */ | 216 | if (ttisnil(key)) return 0; /* first iteration */ |
| 217 | i = ttisinteger(key) ? arrayindex(ivalue(key)) : 0; | 217 | i = ttisinteger(key) ? arrayindex(ivalue(key)) : 0; |
| @@ -229,18 +229,18 @@ static unsigned int findindex (lua_State *L, Table *t, StkId key) { | |||
| 229 | 229 | ||
| 230 | 230 | ||
| 231 | int luaH_next (lua_State *L, Table *t, StkId key) { | 231 | int luaH_next (lua_State *L, Table *t, StkId key) { |
| 232 | unsigned int i = findindex(L, t, key); /* find original element */ | 232 | unsigned int i = findindex(L, t, s2v(key)); /* find original element */ |
| 233 | for (; i < t->sizearray; i++) { /* try first array part */ | 233 | for (; i < t->sizearray; i++) { /* try first array part */ |
| 234 | if (!ttisnil(&t->array[i])) { /* a non-nil value? */ | 234 | if (!ttisnil(&t->array[i])) { /* a non-nil value? */ |
| 235 | setivalue(key, i + 1); | 235 | setivalue(s2v(key), i + 1); |
| 236 | setobj2s(L, key+1, &t->array[i]); | 236 | setobj2s(L, key + 1, &t->array[i]); |
| 237 | return 1; | 237 | return 1; |
| 238 | } | 238 | } |
| 239 | } | 239 | } |
| 240 | for (i -= t->sizearray; cast_int(i) < sizenode(t); i++) { /* hash part */ | 240 | for (i -= t->sizearray; cast_int(i) < sizenode(t); i++) { /* hash part */ |
| 241 | if (!ttisnil(gval(gnode(t, i)))) { /* a non-nil value? */ | 241 | if (!ttisnil(gval(gnode(t, i)))) { /* a non-nil value? */ |
| 242 | Node *n = gnode(t, i); | 242 | Node *n = gnode(t, i); |
| 243 | getnodekey(L, key, n); | 243 | getnodekey(L, s2v(key), n); |
| 244 | setobj2s(L, key + 1, gval(n)); | 244 | setobj2s(L, key + 1, gval(n)); |
| 245 | return 1; | 245 | return 1; |
| 246 | } | 246 | } |
