| 289 | |
| 290 | |
| 291 | static 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 | |
| 319 | int luaK_stringK (FuncState *fs, TString *s) { |
no test coverage detected