History

Lua 5.3.0-work3

Lua Team committed 12 years ago

Commit f8a66271 parent ad386d945 files · +2323 −1590Browse files

Showing the changes to src/lcode.c (1 of 45 files). Show all

Unified · Split

src/lcode.c+10−11
@@ -1,5 +1,5 @@
1/*1/*
2** $Id: lcode.c,v 2.85 2014/03/21 13:52:33 roberto Exp $2** $Id: lcode.c,v 2.90 2014/05/08 18:58:46 roberto Exp $
3** Code generator for Lua3** Code generator for Lua
4** See Copyright Notice in lua.h4** See Copyright Notice in lua.h
5*/5*/
@@ -46,7 +46,7 @@ static int tonumeral(expdesc *e, TValue *v) { · 40 unmodified lines
46 if (v) setivalue(v, e->u.ival);46 if (v) setivalue(v, e->u.ival);
47 return 1;47 return 1;
48 case VKFLT:48 case VKFLT:
49 if (v) setnvalue(v, e->u.nval);49 if (v) setfltvalue(v, e->u.nval);
50 return 1;50 return 1;
51 default: return 0;51 default: return 0;
52 }52 }
@@ -195,7 +195,7 @@ void luaK_patchlist (FuncState *fs, int list, int target) { · 142 unmodified lines
195}195}
196 196
197 197
198LUAI_FUNC void luaK_patchclose (FuncState *fs, int list, int level) {198void luaK_patchclose (FuncState *fs, int list, int level) {
199 level++; /* argument is +1 to reserve 0 as non-op */199 level++; /* argument is +1 to reserve 0 as non-op */
200 while (list != NO_JUMP) {200 while (list != NO_JUMP) {
201 int next = getjump(fs, list);201 int next = getjump(fs, list);
@@ -317,7 +317,7 @@ static int addk (FuncState *fs, TValue *key, TValue *v) { · 115 unmodified lines
317 TValue *idx = luaH_set(L, fs->ls->h, key); /* index scanner table */317 TValue *idx = luaH_set(L, fs->ls->h, key); /* index scanner table */
318 int k, oldsize;318 int k, oldsize;
319 if (ttisinteger(idx)) { /* is there an index there? */319 if (ttisinteger(idx)) { /* is there an index there? */
320 k = ivalue(idx);320 k = cast_int(ivalue(idx));
321 /* correct value? (warning: must distinguish floats from integers!) */321 /* correct value? (warning: must distinguish floats from integers!) */
322 if (k < fs->nk && ttype(&f->k[k]) == ttype(v) &&322 if (k < fs->nk && ttype(&f->k[k]) == ttype(v) &&
323 luaV_rawequalobj(&f->k[k], v))323 luaV_rawequalobj(&f->k[k], v))
@@ -346,8 +346,9 @@ int luaK_stringK (FuncState *fs, TString *s) { · 22 unmodified lines
346 346
347 347
348/*348/*
349** use userdata as key to avoid collision with float with same value;349** Integers use userdata as keys to avoid collision with floats with same
350** conversion to 'void*' used only for hash, no "precision" problems350** value; conversion to 'void*' used only for hashing, no "precision"
351** problems
351*/352*/
352int luaK_intK (FuncState *fs, lua_Integer n) {353int luaK_intK (FuncState *fs, lua_Integer n) {
353 TValue k, o;354 TValue k, o;
@@ -359,13 +360,13 @@ int luaK_intK (FuncState *fs, lua_Integer n) { · 5 unmodified lines
359 360
360/*361/*
361** Both NaN and -0.0 should not go to the constant table, as they have362** Both NaN and -0.0 should not go to the constant table, as they have
362** problems with the hashing. (NaN is not ** a valid key,363** problems with the hashing. (NaN is not a valid key, -0.0 collides
363** -0.0 collides with +0.0.)364** with +0.0.)
364*/ 365*/
365static int luaK_numberK (FuncState *fs, lua_Number r) {366static int luaK_numberK (FuncState *fs, lua_Number r) {
366 TValue o;367 TValue o;
367 lua_assert(!luai_numisnan(r) && !isminuszero(r));368 lua_assert(!luai_numisnan(r) && !isminuszero(r));
368 setnvalue(&o, r);369 setfltvalue(&o, r);
369 return addk(fs, &o, &o);370 return addk(fs, &o, &o);
370}371}
371 372
@@ -768,8 +769,6 @@ static int validop (int op, TValue *v1, TValue *v2) { · 396 unmodified lines
768 return (tointeger(v1, &i) && tointeger(v2, &i));769 return (tointeger(v1, &i) && tointeger(v2, &i));
769 case LUA_OPMOD: /* integer module by 0 */770 case LUA_OPMOD: /* integer module by 0 */
770 return !(ttisinteger(v1) && ttisinteger(v2) && ivalue(v2) == 0);771 return !(ttisinteger(v1) && ttisinteger(v2) && ivalue(v2) == 0);
771 case LUA_OPPOW: /* negative integer exponentiation */
772 return !(ttisinteger(v1) && ttisinteger(v2) && ivalue(v2) < 0);
773 default: return 1; /* everything else is valid */772 default: return 1; /* everything else is valid */
774 }773 }
775}774}