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 @@
11 /*
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 $
33 ** Code generator for Lua
44 ** See Copyright Notice in lua.h
55 */
@@ -46,7 +46,7 @@ static int tonumeral(expdesc *e, TValue *v) { · 40 unmodified lines
4646 if (v) setivalue(v, e->u.ival);
4747 return 1;
4848 case VKFLT:
49− if (v) setnvalue(v, e->u.nval);
49+ if (v) setfltvalue(v, e->u.nval);
5050 return 1;
5151 default: return 0;
5252 }
@@ -195,7 +195,7 @@ void luaK_patchlist (FuncState *fs, int list, int target) { · 142 unmodified lines
195195 }
196196
197197
198−LUAI_FUNC void luaK_patchclose (FuncState *fs, int list, int level) {
198+void luaK_patchclose (FuncState *fs, int list, int level) {
199199 level++; /* argument is +1 to reserve 0 as non-op */
200200 while (list != NO_JUMP) {
201201 int next = getjump(fs, list);
@@ -317,7 +317,7 @@ static int addk (FuncState *fs, TValue *key, TValue *v) { · 115 unmodified lines
317317 TValue *idx = luaH_set(L, fs->ls->h, key); /* index scanner table */
318318 int k, oldsize;
319319 if (ttisinteger(idx)) { /* is there an index there? */
320− k = ivalue(idx);
320+ k = cast_int(ivalue(idx));
321321 /* correct value? (warning: must distinguish floats from integers!) */
322322 if (k < fs->nk && ttype(&f->k[k]) == ttype(v) &&
323323 luaV_rawequalobj(&f->k[k], v))
@@ -346,8 +346,9 @@ int luaK_stringK (FuncState *fs, TString *s) { · 22 unmodified lines
346346
347347
348348 /*
349−** use userdata as key to avoid collision with float with same value;
350−** conversion to 'void*' used only for hash, no "precision" problems
349+** Integers use userdata as keys to avoid collision with floats with same
350+** value; conversion to 'void*' used only for hashing, no "precision"
351+** problems
351352 */
352353 int luaK_intK (FuncState *fs, lua_Integer n) {
353354 TValue k, o;
@@ -359,13 +360,13 @@ int luaK_intK (FuncState *fs, lua_Integer n) { · 5 unmodified lines
359360
360361 /*
361362 ** 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−** -0.0 collides with +0.0.)
363+** problems with the hashing. (NaN is not a valid key, -0.0 collides
364+** with +0.0.)
364365 */
365366 static int luaK_numberK (FuncState *fs, lua_Number r) {
366367 TValue o;
367368 lua_assert(!luai_numisnan(r) && !isminuszero(r));
368− setnvalue(&o, r);
369+ setfltvalue(&o, r);
369370 return addk(fs, &o, &o);
370371 }
371372
@@ -768,8 +769,6 @@ static int validop (int op, TValue *v1, TValue *v2) { · 396 unmodified lines
768769 return (tointeger(v1, &i) && tointeger(v2, &i));
769770 case LUA_OPMOD: /* integer module by 0 */
770771 return !(ttisinteger(v1) && ttisinteger(v2) && ivalue(v2) == 0);
771− case LUA_OPPOW: /* negative integer exponentiation */
772− return !(ttisinteger(v1) && ttisinteger(v2) && ivalue(v2) < 0);
773772 default: return 1; /* everything else is valid */
774773 }
775774 }