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

Function luaV_settable

lua/lvm.c:135–171  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

133
134
135void luaV_settable (lua_State *L, const TValue *t, TValue *key, StkId val) {
136 int loop;
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, *foundkey = NULL;
142 oldval = luaH_set_int(L, h, key, &foundkey); /* do a primitive set */
143 if (!ttisnil(oldval) || /* result is no nil? */
144 (tm = fasttm(L, h->metatable, TM_NEWINDEX)) == NULL) { /* or no TM? */
145 if (foundkey) {
146 if (ttype(foundkey) != ttype(key)) {
147 setobj2t(L, foundkey, key);
148 } else if (ttype(foundkey) == LUA_TUSERDATA) {
149 int f = luabb_dbtype_from_tvalue(foundkey);
150 int k = luabb_dbtype_from_tvalue(key);
151 if (f != k) {
152 setobj2t(L, foundkey, key);
153 }
154 }
155 }
156 setobj2t(L, oldval, val);
157 luaC_barriert(L, h, val);
158 return;
159 }
160 /* else will try the tag method */
161 }
162 else if (ttisnil(tm = luaT_gettmbyobj(L, t, TM_NEWINDEX)))
163 luaG_typeerror(L, t, "index");
164 if (ttisfunction(tm)) {
165 callTM(L, tm, t, key, val);
166 return;
167 }
168 t = tm; /* else repeat with `tm' */
169 }
170 luaG_runerror(L, "loop in settable");
171}
172
173
174static 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 6

luaH_set_intFunction · 0.85
luabb_dbtype_from_tvalueFunction · 0.85
luaT_gettmbyobjFunction · 0.85
luaG_typeerrorFunction · 0.85
callTMFunction · 0.85
luaG_runerrorFunction · 0.85

Tested by

no test coverage detected