/* Add constant 'v' to prototype's list of constants (field 'k'). Use scanner's table to cache position of constants in constant list and try to reuse constants. Because some values should not be used as keys (nil cannot be a key, integer keys can collapse with float keys), the caller must provide a useful 'key' for indexing the cache.  */
static int addk(FuncState *fs, TValue *key, TValue *v)
/* Add constant 'v' to prototype's list of constants (field 'k'). Use scanner's table to cache position of constants in constant list and try to reuse constants. Because some values should not be used as keys (nil cannot be a key, integer keys can collapse with float keys), the caller must provide a useful 'key' for indexing the cache.  */
static int addk(FuncState *fs, TValue *key, TValue *v)
{
    k = cast_int(ivalue(idx));
    if (k < fs->nk && ttype(&f->k[k]) == ttype(v) &&
                      luaV_rawequalobj(&f->k[k], v))
      return k;
  }
  oldsize = f->sizek;
  k = fs->nk;
  setivalue(idx, k);
  luaM_growvector(L, f->k, k, f->sizek, TValue, MAXARG_Ax, "constants");
  while (oldsize < f->sizek) setnilvalue(&f->k[oldsize++]);
  setobj(L, &f->k[k], v);
  fs->nk++;
  luaC_barrier(L, f, v);
  return k;
}