** main search function */
| 538 | ** main search function |
| 539 | */ |
| 540 | const TValue *luaH_get (Table *t, const TValue *key) { |
| 541 | switch (ttype(key)) { |
| 542 | case LUA_TSHRSTR: return luaH_getstr(t, tsvalue(key)); |
| 543 | case LUA_TNUMINT: return luaH_getint(t, ivalue(key)); |
| 544 | case LUA_TNIL: return luaO_nilobject; |
| 545 | case LUA_TNUMFLT: { |
| 546 | lua_Integer k; |
| 547 | if (numisinteger(fltvalue(key), &k)) /* index is int? */ |
| 548 | return luaH_getint(t, k); /* use specialized version */ |
| 549 | /* else go through */ |
| 550 | } |
| 551 | default: { |
| 552 | Node *n = mainposition(t, key); |
| 553 | for (;;) { /* check whether 'key' is somewhere in the chain */ |
| 554 | if (luaV_rawequalobj(gkey(n), key)) |
| 555 | return gval(n); /* that's it */ |
| 556 | else { |
| 557 | int nx = gnext(n); |
| 558 | if (nx == 0) break; |
| 559 | n += nx; |
| 560 | } |
| 561 | }; |
| 562 | return luaO_nilobject; |
| 563 | } |
| 564 | } |
| 565 | } |
| 566 | |
| 567 | |
| 568 | /* |
no test coverage detected