MCPcopy Create free account
hub / github.com/RomanKubiak/ctrlr / luaV_settable

Function luaV_settable

Source/Misc/lua/src/lua.c:14967–14991  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

14965
14966
14967void luaV_settable (lua_State *L, const TValue *t, TValue *key, StkId val) {
14968int loop;
14969for (loop = 0; loop < MAXTAGLOOP; loop++) {
14970const TValue *tm;
14971if (ttistable(t)) { /* `t' is a table? */
14972Table *h = hvalue(t);
14973TValue *oldval = luaH_set(L, h, key); /* do a primitive set */
14974if (!ttisnil(oldval) || /* result is no nil? */
14975(tm = fasttm(L, h->metatable, TM_NEWINDEX)) == NULL) { /* or no TM? */
14976setobj2t(L, oldval, val);
14977luaC_barriert(L, h, val);
14978return;
14979}
14980/* else will try the tag method */
14981}
14982else if (ttisnil(tm = luaT_gettmbyobj(L, t, TM_NEWINDEX)))
14983luaG_typeerror(L, t, "index");
14984if (ttisfunction(tm)) {
14985callTM(L, tm, t, key, val);
14986return;
14987}
14988t = tm; /* else repeat with `tm' */
14989}
14990luaG_runerror(L, "loop in settable");
14991}
14992
14993
14994static int call_binTM (lua_State *L, const TValue *p1, const TValue *p2,

Callers 3

lua_settableFunction · 0.85
lua_setfieldFunction · 0.85
luaV_executeFunction · 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