MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / luaV_settable

Function luaV_settable

deps/lua/src/lvm.c:134–162  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

132
133
134void luaV_settable (lua_State *L, const TValue *t, TValue *key, StkId val) {
135 int loop;
136 TValue temp;
137 for (loop = 0; loop < MAXTAGLOOP; loop++) {
138 const TValue *tm;
139 if (ttistable(t)) { /* `t' is a table? */
140 Table *h = hvalue(t);
141 TValue *oldval = luaH_set(L, h, key); /* do a primitive set */
142 if (!ttisnil(oldval) || /* result is no nil? */
143 (tm = fasttm(L, h->metatable, TM_NEWINDEX)) == NULL) { /* or no TM? */
144 setobj2t(L, oldval, val);
145 h->flags = 0;
146 luaC_barriert(L, h, val);
147 return;
148 }
149 /* else will try the tag method */
150 }
151 else if (ttisnil(tm = luaT_gettmbyobj(L, t, TM_NEWINDEX)))
152 luaG_typeerror(L, t, "index");
153 if (ttisfunction(tm)) {
154 callTM(L, tm, t, key, val);
155 return;
156 }
157 /* else repeat with `tm' */
158 setobj(L, &temp, tm); /* avoid pointing inside table (may rehash) */
159 t = &temp;
160 }
161 luaG_runerror(L, "loop in settable");
162}
163
164
165static int call_binTM (lua_State *L, const TValue *p1, const TValue *p2,

Callers 3

luaV_executeFunction · 0.85
lua_settableFunction · 0.85
lua_setfieldFunction · 0.85

Calls 5

luaH_setFunction · 0.85
luaT_gettmbyobjFunction · 0.85
luaG_typeerrorFunction · 0.85
callTMFunction · 0.85
luaG_runerrorFunction · 0.85

Tested by

no test coverage detected