MCPcopy Create free account
hub / github.com/TASEmulators/fceux / luaV_settable

Function luaV_settable

src/lua/src/lvm.c:134–158  ·  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 for (loop = 0; loop < MAXTAGLOOP; loop++) {
137 const TValue *tm;
138 if (ttistable(t)) { /* `t' is a table? */
139 Table *h = hvalue(t);
140 TValue *oldval = luaH_set(L, h, key); /* do a primitive set */
141 if (!ttisnil(oldval) || /* result is no nil? */
142 (tm = fasttm(L, h->metatable, TM_NEWINDEX)) == NULL) { /* or no TM? */
143 setobj2t(L, oldval, val);
144 luaC_barriert(L, h, val);
145 return;
146 }
147 /* else will try the tag method */
148 }
149 else if (ttisnil(tm = luaT_gettmbyobj(L, t, TM_NEWINDEX)))
150 luaG_typeerror(L, t, "index");
151 if (ttisfunction(tm)) {
152 callTM(L, tm, t, key, val);
153 return;
154 }
155 t = tm; /* else repeat with `tm' */
156 }
157 luaG_runerror(L, "loop in settable");
158}
159
160
161static 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