MCPcopy Create free account
hub / github.com/EmmyLua/EmmyLuaDebugger / luaH_get

Function luaH_get

third-party/lua-5.2.4/src/ltable.c:481–503  ·  view source on GitHub ↗

** main search function */

Source from the content-addressed store, hash-verified

479** main search function
480*/
481const TValue *luaH_get (Table *t, const TValue *key) {
482 switch (ttype(key)) {
483 case LUA_TSHRSTR: return luaH_getstr(t, rawtsvalue(key));
484 case LUA_TNIL: return luaO_nilobject;
485 case LUA_TNUMBER: {
486 int k;
487 lua_Number n = nvalue(key);
488 lua_number2int(k, n);
489 if (luai_numeq(cast_num(k), n)) /* index is int? */
490 return luaH_getint(t, k); /* use specialized version */
491 /* else go through */
492 }
493 default: {
494 Node *n = mainposition(t, key);
495 do { /* check whether `key' is somewhere in the chain */
496 if (luaV_rawequalobj(gkey(n), key))
497 return gval(n); /* that's it */
498 else n = gnext(n);
499 } while (n);
500 return luaO_nilobject;
501 }
502 }
503}
504
505
506/*

Callers 5

luaV_gettableFunction · 0.70
luaV_settableFunction · 0.70
luaH_setFunction · 0.70
lua_rawgetFunction · 0.70
lua_rawgetpFunction · 0.70

Calls 3

luaH_getstrFunction · 0.70
luaH_getintFunction · 0.70
mainpositionFunction · 0.70

Tested by

no test coverage detected