| 991 | |
| 992 | |
| 993 | static int table_query (lua_State *L) { |
| 994 | const Table *t; |
| 995 | int i = cast_int(luaL_optinteger(L, 2, -1)); |
| 996 | unsigned int asize; |
| 997 | luaL_checktype(L, 1, LUA_TTABLE); |
| 998 | t = hvalue(obj_at(L, 1)); |
| 999 | asize = luaH_realasize(t); |
| 1000 | if (i == -1) { |
| 1001 | lua_pushinteger(L, asize); |
| 1002 | lua_pushinteger(L, allocsizenode(t)); |
| 1003 | lua_pushinteger(L, isdummy(t) ? 0 : t->lastfree - t->node); |
| 1004 | lua_pushinteger(L, t->alimit); |
| 1005 | return 4; |
| 1006 | } |
| 1007 | else if ((unsigned int)i < asize) { |
| 1008 | lua_pushinteger(L, i); |
| 1009 | pushobject(L, &t->array[i]); |
| 1010 | lua_pushnil(L); |
| 1011 | } |
| 1012 | else if ((i -= asize) < sizenode(t)) { |
| 1013 | TValue k; |
| 1014 | getnodekey(L, &k, gnode(t, i)); |
| 1015 | if (!isempty(gval(gnode(t, i))) || |
| 1016 | ttisnil(&k) || |
| 1017 | ttisnumber(&k)) { |
| 1018 | pushobject(L, &k); |
| 1019 | } |
| 1020 | else |
| 1021 | lua_pushliteral(L, "<undef>"); |
| 1022 | pushobject(L, gval(gnode(t, i))); |
| 1023 | if (gnext(&t->node[i]) != 0) |
| 1024 | lua_pushinteger(L, gnext(&t->node[i])); |
| 1025 | else |
| 1026 | lua_pushnil(L); |
| 1027 | } |
| 1028 | return 3; |
| 1029 | } |
| 1030 | |
| 1031 | |
| 1032 | static int string_query (lua_State *L) { |
nothing calls this directly
no test coverage detected