function luaK.addk(A,Z,w,z)local M=Z.L local S=Z.h[w.value]local I=Z.f if A:ttisnumber(S)then return A:nvalue(S)else S={}A:setnvalue(S,Z.nk)Z.h[w.value]=S luaY:growvector(M,I.k,Z.nk,I.sizek,nil,luaP.MAXARG_Bx,"\099\111\110\115\116\097\110\116 \116\097\098\108\101 \111\118\101\114\102\108\111\119")I.k[Z.nk]=z local v=Z.nk Z.nk=Z.nk+1 return v end end
------------------------------------------------------------------------
-- * TODO NOTE implementation is not 100% correct, since the assert fails
-- * luaH_set, setobj deleted; direct table access used instead
-- * used in luaK:stringK(), luaK:numberK(), luaK:boolK(), luaK:nilK()
------------------------------------------------------------------------
function luaK:addk(fs, k, v)
	local L = fs.L
	local idx = fs.h[k.value]
	--TValue *idx = luaH_set(L, fs->h, k); /* C */
	local f = fs.f
	if self:ttisnumber(idx) then
		--TODO this assert currently FAILS (last tested for 5.0.2)
		--assert(fs.f.k[self:nvalue(idx)] == v)
		--assert(luaO_rawequalObj(&fs->f->k[cast_int(nvalue(idx))], v)); /* C */
		return self:nvalue(idx)
	else -- constant not found; create a new entry
		idx = {}
		self:setnvalue(idx, fs.nk)
		fs.h[k.value] = idx
		-- setnvalue(idx, cast_num(fs->nk)); /* C */
		luaY:growvector(L, f.k, fs.nk, f.sizek, nil, luaP.MAXARG_Bx, "constant table overflow")
		-- loop to initialize empty f.k positions not required
		f.k[fs.nk] = v
		-- setobj(L, &f->k[fs->nk], v); /* C */
		-- luaC_barrier(L, f, v); /* GC */
		local nk = fs.nk
		fs.nk = fs.nk + 1
		return nk
	end
end
