diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2013-04-15 12:43:34 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2013-04-15 12:43:34 -0300 |
commit | 7a543cfae613d7fa5f0cc82ef462310e5d3a4413 (patch) | |
tree | 0bc41f597df62c85c4f2abcdbbe288edb010e644 /lcode.c | |
parent | 24689927f2ef4d5bfe9f0d7deff08504eb31f81e (diff) | |
download | lua-7a543cfae613d7fa5f0cc82ef462310e5d3a4413.tar.gz lua-7a543cfae613d7fa5f0cc82ef462310e5d3a4413.tar.bz2 lua-7a543cfae613d7fa5f0cc82ef462310e5d3a4413.zip |
Diffstat (limited to 'lcode.c')
-rw-r--r-- | lcode.c | 9 |
1 files changed, 4 insertions, 5 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lcode.c,v 2.61 2012/08/14 18:12:34 roberto Exp roberto $ | 2 | ** $Id: lcode.c,v 2.62 2012/08/16 17:34:28 roberto Exp $ |
3 | ** Code generator for Lua | 3 | ** Code generator for Lua |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -293,9 +293,8 @@ static int addk (FuncState *fs, TValue *key, TValue *v) { | |||
293 | TValue *idx = luaH_set(L, fs->h, key); | 293 | TValue *idx = luaH_set(L, fs->h, key); |
294 | Proto *f = fs->f; | 294 | Proto *f = fs->f; |
295 | int k, oldsize; | 295 | int k, oldsize; |
296 | if (ttisnumber(idx)) { | 296 | if (ttisinteger(idx)) { |
297 | lua_Number n = nvalue(idx); | 297 | k = ivalue(idx); |
298 | lua_number2int(k, n); | ||
299 | if (luaV_rawequalobj(&f->k[k], v)) | 298 | if (luaV_rawequalobj(&f->k[k], v)) |
300 | return k; | 299 | return k; |
301 | /* else may be a collision (e.g., between 0.0 and "\0\0\0\0\0\0\0\0"); | 300 | /* else may be a collision (e.g., between 0.0 and "\0\0\0\0\0\0\0\0"); |
@@ -306,7 +305,7 @@ static int addk (FuncState *fs, TValue *key, TValue *v) { | |||
306 | k = fs->nk; | 305 | k = fs->nk; |
307 | /* numerical value does not need GC barrier; | 306 | /* numerical value does not need GC barrier; |
308 | table has no metatable, so it does not need to invalidate cache */ | 307 | table has no metatable, so it does not need to invalidate cache */ |
309 | setnvalue(idx, cast_num(k)); | 308 | setivalue(idx, k); |
310 | luaM_growvector(L, f->k, k, f->sizek, TValue, MAXARG_Ax, "constants"); | 309 | luaM_growvector(L, f->k, k, f->sizek, TValue, MAXARG_Ax, "constants"); |
311 | while (oldsize < f->sizek) setnilvalue(&f->k[oldsize++]); | 310 | while (oldsize < f->sizek) setnilvalue(&f->k[oldsize++]); |
312 | setobj(L, &f->k[k], v); | 311 | setobj(L, &f->k[k], v); |