MCPcopy Create free account
hub / github.com/BZFlag-Dev/bzflag / luaV_settable

Function luaV_settable

other_src/lua/src/lvm.cpp:134–164  ·  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 /* oldval is nil=> look for newindex, oldval is not nil => look for usedindex */
143 tm = ttisnil(oldval) ? fasttm(L, h->metatable, TM_NEWINDEX)
144 : fasttm(L, h->metatable, TM_USEDINDEX); /*BZ*/
145 if (tm == NULL) { /* no tag method, set the value */
146 setobj2t(L, oldval, val);
147 luaC_barriert(L, h, val);
148 return;
149 }
150 /* else will try the tag method */
151 }
152 else if (ttisnil(tm = luaT_gettmbyobj(L, t, TM_NEWINDEX))) {
153 luaG_typeerror(L, t, "index");
154 }
155 if (ttisfunction(tm)) {
156 callTM(L, tm, t, key, val);
157 return;
158 }
159 /* else repeat with `tm' */
160 setobj(L, &temp, tm); /* avoid pointing inside table (may rehash) */
161 t = &temp;
162 }
163 luaG_runerror(L, "loop in settable");
164}
165
166
167static int call_binTM (lua_State *L, const TValue *p1, const TValue *p2,

Callers 3

luaV_executeFunction · 0.70
lua_settableFunction · 0.70
lua_setfieldFunction · 0.70

Calls 5

luaH_setFunction · 0.70
luaT_gettmbyobjFunction · 0.70
luaG_typeerrorFunction · 0.70
callTMFunction · 0.70
luaG_runerrorFunction · 0.70

Tested by

no test coverage detected