** returns the 'main' position of an element in a table (that is, ** the index of its hash value). */
| 149 | ** the index of its hash value). |
| 150 | */ |
| 151 | static Node *mainpositionTV (const Table *t, const TValue *key) { |
| 152 | switch (ttypetag(key)) { |
| 153 | case LUA_VNUMINT: { |
| 154 | lua_Integer i = ivalue(key); |
| 155 | return hashint(t, i); |
| 156 | } |
| 157 | case LUA_VNUMFLT: { |
| 158 | lua_Number n = fltvalue(key); |
| 159 | return hashmod(t, l_hashfloat(n)); |
| 160 | } |
| 161 | case LUA_VSHRSTR: { |
| 162 | TString *ts = tsvalue(key); |
| 163 | return hashstr(t, ts); |
| 164 | } |
| 165 | case LUA_VLNGSTR: { |
| 166 | TString *ts = tsvalue(key); |
| 167 | return hashpow2(t, luaS_hashlongstr(ts)); |
| 168 | } |
| 169 | case LUA_VFALSE: |
| 170 | return hashboolean(t, 0); |
| 171 | case LUA_VTRUE: |
| 172 | return hashboolean(t, 1); |
| 173 | case LUA_VLIGHTUSERDATA: { |
| 174 | void *p = pvalue(key); |
| 175 | return hashpointer(t, p); |
| 176 | } |
| 177 | case LUA_VLCF: { |
| 178 | lua_CFunction f = fvalue(key); |
| 179 | return hashpointer(t, f); |
| 180 | } |
| 181 | default: { |
| 182 | GCObject *o = gcvalue(key); |
| 183 | return hashpointer(t, o); |
| 184 | } |
| 185 | } |
| 186 | } |
| 187 | |
| 188 | |
| 189 | l_sinline Node *mainpositionfromnode (const Table *t, Node *nd) { |
no test coverage detected