aboutsummaryrefslogtreecommitdiff
path: root/lcode.c
diff options
context:
space:
mode:
Diffstat (limited to 'lcode.c')
-rw-r--r--lcode.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/lcode.c b/lcode.c
index 97e427b2..d8d353fe 100644
--- a/lcode.c
+++ b/lcode.c
@@ -545,11 +545,14 @@ static void freeexps (FuncState *fs, expdesc *e1, expdesc *e2) {
545** and try to reuse constants. Because some values should not be used 545** and try to reuse constants. Because some values should not be used
546** as keys (nil cannot be a key, integer keys can collapse with float 546** as keys (nil cannot be a key, integer keys can collapse with float
547** keys), the caller must provide a useful 'key' for indexing the cache. 547** keys), the caller must provide a useful 'key' for indexing the cache.
548** Note that all functions share the same table, so entering or exiting
549** a function can make some indices wrong.
548*/ 550*/
549static int addk (FuncState *fs, TValue *key, TValue *v) { 551static int addk (FuncState *fs, TValue *key, TValue *v) {
552 TValue val;
550 lua_State *L = fs->ls->L; 553 lua_State *L = fs->ls->L;
551 Proto *f = fs->f; 554 Proto *f = fs->f;
552 TValue *idx = luaH_set(L, fs->ls->h, key); /* index scanner table */ 555 const TValue *idx = luaH_get(fs->ls->h, key); /* query scanner table */
553 int k, oldsize; 556 int k, oldsize;
554 if (ttisinteger(idx)) { /* is there an index there? */ 557 if (ttisinteger(idx)) { /* is there an index there? */
555 k = cast_int(ivalue(idx)); 558 k = cast_int(ivalue(idx));
@@ -563,7 +566,8 @@ static int addk (FuncState *fs, TValue *key, TValue *v) {
563 k = fs->nk; 566 k = fs->nk;
564 /* numerical value does not need GC barrier; 567 /* numerical value does not need GC barrier;
565 table has no metatable, so it does not need to invalidate cache */ 568 table has no metatable, so it does not need to invalidate cache */
566 setivalue(idx, k); 569 setivalue(&val, k);
570 luaH_finishset(L, fs->ls->h, key, idx, &val);
567 luaM_growvector(L, f->k, k, f->sizek, TValue, MAXARG_Ax, "constants"); 571 luaM_growvector(L, f->k, k, f->sizek, TValue, MAXARG_Ax, "constants");
568 while (oldsize < f->sizek) setnilvalue(&f->k[oldsize++]); 572 while (oldsize < f->sizek) setnilvalue(&f->k[oldsize++]);
569 setobj(L, &f->k[k], v); 573 setobj(L, &f->k[k], v);