eris: refactoring table API so that table methods can see value being inserted

This commit is contained in:
2021-07-06 19:32:20 -04:00
parent a12133243c
commit 3bf8b1fadb
6 changed files with 40 additions and 56 deletions

View File

@@ -290,7 +290,7 @@ static void freeexp (FuncState *fs, expdesc *e) {
static int addk (FuncState *fs, TValue *key, TValue *v) {
lua_State *L = fs->ls->L;
TValue *idx = luaH_set(L, fs->h, key);
const TValue *idx = luaH_get(fs->h, key);
Proto *f = fs->f;
int k, oldsize;
if (ttisnumber(idx)) {
@@ -306,7 +306,9 @@ static int addk (FuncState *fs, TValue *key, TValue *v) {
k = fs->nk;
/* numerical value does not need GC barrier;
table has no metatable, so it does not need to invalidate cache */
setnvalue(idx, cast_num(k));
TValue kv;
setnvalue(&kv, cast_num(k));
luaH_setvalue (L, fs->h, key, &kv);
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);