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

Function addk

Source/Misc/lua/src/lua.c:3898–3916  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3896
3897
3898static int addk (FuncState *fs, TValue *k, TValue *v) {
3899lua_State *L = fs->L;
3900TValue *idx = luaH_set(L, fs->h, k);
3901Proto *f = fs->f;
3902int oldsize = f->sizek;
3903if (ttisnumber(idx)) {
3904lua_assert(luaO_rawequalObj(&fs->f->k[cast_int(nvalue(idx))], v));
3905return cast_int(nvalue(idx));
3906}
3907else { /* constant not found; create a new entry */
3908setnvalue(idx, cast_num(fs->nk));
3909luaM_growvector(L, f->k, fs->nk, f->sizek, TValue,
3910MAXARG_Bx, "constant table overflow");
3911while (oldsize < f->sizek) setnilvalue(&f->k[oldsize++]);
3912setobj(L, &f->k[fs->nk], v);
3913luaC_barrier(L, f, v);
3914return fs->nk++;
3915}
3916}
3917
3918
3919int luaK_stringK (FuncState *fs, TString *s) {

Callers 4

luaK_stringKFunction · 0.85
luaK_numberKFunction · 0.85
boolKFunction · 0.85
nilKFunction · 0.85

Calls 2

luaH_setFunction · 0.85
luaO_rawequalObjFunction · 0.85

Tested by

no test coverage detected