MCPcopy Create free account
hub / github.com/F-Stack/f-stack / luaV_gettable

Function luaV_gettable

freebsd/contrib/openzfs/module/lua/lvm.c:111–134  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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