MCPcopy Create free account
hub / github.com/F-Stack/f-stack / addk

Function addk

freebsd/contrib/openzfs/module/lua/lcode.c:289–314  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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