MCPcopy Create free account
hub / github.com/RomanKubiak/ctrlr / luaV_gettable

Function luaV_gettable

Source/Misc/lua/src/lua.c:14941–14964  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

14939
14940
14941void luaV_gettable (lua_State *L, const TValue *t, TValue *key, StkId val) {
14942int loop;
14943for (loop = 0; loop < MAXTAGLOOP; loop++) {
14944const TValue *tm;
14945if (ttistable(t)) { /* `t' is a table? */
14946Table *h = hvalue(t);
14947const TValue *res = luaH_get(h, key); /* do a primitive get */
14948if (!ttisnil(res) || /* result is no nil? */
14949(tm = fasttm(L, h->metatable, TM_INDEX)) == NULL) { /* or no TM? */
14950setobj2s(L, val, res);
14951return;
14952}
14953/* else will try the tag method */
14954}
14955else if (ttisnil(tm = luaT_gettmbyobj(L, t, TM_INDEX)))
14956luaG_typeerror(L, t, "index");
14957if (ttisfunction(tm)) {
14958callTMres(L, val, tm, t, key);
14959return;
14960}
14961t = tm; /* else repeat with `tm' */
14962}
14963luaG_runerror(L, "loop in gettable");
14964}
14965
14966
14967void luaV_settable (lua_State *L, const TValue *t, TValue *key, StkId val) {

Callers 3

lua_gettableFunction · 0.85
lua_getfieldFunction · 0.85
luaV_executeFunction · 0.85

Calls 5

luaH_getFunction · 0.85
luaT_gettmbyobjFunction · 0.85
luaG_typeerrorFunction · 0.85
callTMresFunction · 0.85
luaG_runerrorFunction · 0.85

Tested by

no test coverage detected