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

Function luaV_gettable

third-party/lua-5.2.4/src/lvm.c:110–133  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

108
109
110void luaV_gettable (lua_State *L, const TValue *t, TValue *key, StkId val) {
111 int loop;
112 for (loop = 0; loop < MAXTAGLOOP; loop++) {
113 const TValue *tm;
114 if (ttistable(t)) { /* `t' is a table? */
115 Table *h = hvalue(t);
116 const TValue *res = luaH_get(h, key); /* do a primitive get */
117 if (!ttisnil(res) || /* result is not nil? */
118 (tm = fasttm(L, h->metatable, TM_INDEX)) == NULL) { /* or no TM? */
119 setobj2s(L, val, res);
120 return;
121 }
122 /* else will try the tag method */
123 }
124 else if (ttisnil(tm = luaT_gettmbyobj(L, t, TM_INDEX)))
125 luaG_typeerror(L, t, "index");
126 if (ttisfunction(tm)) {
127 callTM(L, tm, t, key, val, 1);
128 return;
129 }
130 t = tm; /* else repeat with 'tm' */
131 }
132 luaG_runerror(L, "loop in gettable");
133}
134
135
136void luaV_settable (lua_State *L, const TValue *t, TValue *key, StkId val) {

Callers 4

luaV_executeFunction · 0.70
lua_getglobalFunction · 0.70
lua_gettableFunction · 0.70
lua_getfieldFunction · 0.70

Calls 5

luaH_getFunction · 0.70
luaT_gettmbyobjFunction · 0.70
luaG_typeerrorFunction · 0.70
callTMFunction · 0.70
luaG_runerrorFunction · 0.70

Tested by

no test coverage detected