MCPcopy Create free account
hub / github.com/bloomberg/comdb2 / luaV_gettable

Function luaV_gettable

lua/lvm.c:109–132  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 3

luaV_executeFunction · 0.85
lua_gettableFunction · 0.85
lua_getfieldFunction · 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