MCPcopy Create free account
hub / github.com/EmmyLua/EmmyLuaDebugger / addk

Function addk

third-party/lua-5.2.4/src/lcode.c:291–316  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

289
290
291static int addk (FuncState *fs, TValue *key, TValue *v) {
292 lua_State *L = fs->ls->L;
293 TValue *idx = luaH_set(L, fs->h, key);
294 Proto *f = fs->f;
295 int k, oldsize;
296 if (ttisnumber(idx)) {
297 lua_Number n = nvalue(idx);
298 lua_number2int(k, n);
299 if (luaV_rawequalobj(&f->k[k], v))
300 return k;
301 /* else may be a collision (e.g., between 0.0 and "\0\0\0\0\0\0\0\0");
302 go through and create a new entry for this value */
303 }
304 /* constant not found; create a new entry */
305 oldsize = f->sizek;
306 k = fs->nk;
307 /* numerical value does not need GC barrier;
308 table has no metatable, so it does not need to invalidate cache */
309 setnvalue(idx, cast_num(k));
310 luaM_growvector(L, f->k, k, f->sizek, TValue, MAXARG_Ax, "constants");
311 while (oldsize < f->sizek) setnilvalue(&f->k[oldsize++]);
312 setobj(L, &f->k[k], v);
313 fs->nk++;
314 luaC_barrier(L, f, v);
315 return k;
316}
317
318
319int luaK_stringK (FuncState *fs, TString *s) {

Callers 4

luaK_stringKFunction · 0.70
luaK_numberKFunction · 0.70
boolKFunction · 0.70
nilKFunction · 0.70

Calls 1

luaH_setFunction · 0.70

Tested by

no test coverage detected