Showing the changes to src/lcode.c (1 of 45 files). Show all
Unified · Split
| @@ -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 | 3 | ** Code generator for Lua |
| 4 | 4 | ** See Copyright Notice in lua.h |
| 5 | 5 | */ |
| @@ -46,7 +46,7 @@ static int tonumeral(expdesc *e, TValue *v) { · 40 unmodified lines | ||
| 46 | 46 | if (v) setivalue(v, e->u.ival); |
| 47 | 47 | return 1; |
| 48 | 48 | case VKFLT: |
| 49 | − if (v) setnvalue(v, e->u.nval); | |
| 49 | + if (v) setfltvalue(v, e->u.nval); | |
| 50 | 50 | return 1; |
| 51 | 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 | |
| 198 | −LUAI_FUNC void luaK_patchclose (FuncState *fs, int list, int level) { | |
| 198 | +void luaK_patchclose (FuncState *fs, int list, int level) { | |
| 199 | 199 | level++; /* argument is +1 to reserve 0 as non-op */ |
| 200 | 200 | while (list != NO_JUMP) { |
| 201 | 201 | int next = getjump(fs, list); |
| @@ -317,7 +317,7 @@ static int addk (FuncState *fs, TValue *key, TValue *v) { · 115 unmodified lines | ||
| 317 | 317 | TValue *idx = luaH_set(L, fs->ls->h, key); /* index scanner table */ |
| 318 | 318 | int k, oldsize; |
| 319 | 319 | if (ttisinteger(idx)) { /* is there an index there? */ |
| 320 | − k = ivalue(idx); | |
| 320 | + k = cast_int(ivalue(idx)); | |
| 321 | 321 | /* correct value? (warning: must distinguish floats from integers!) */ |
| 322 | 322 | if (k < fs->nk && ttype(&f->k[k]) == ttype(v) && |
| 323 | 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; | |
| 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 | |
| 351 | 352 | */ |
| 352 | 353 | int luaK_intK (FuncState *fs, lua_Integer n) { |
| 353 | 354 | TValue k, o; |
| @@ -359,13 +360,13 @@ int luaK_intK (FuncState *fs, lua_Integer n) { · 5 unmodified lines | ||
| 359 | 360 | |
| 360 | 361 | /* |
| 361 | 362 | ** 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.) | |
| 364 | 365 | */ |
| 365 | 366 | static int luaK_numberK (FuncState *fs, lua_Number r) { |
| 366 | 367 | TValue o; |
| 367 | 368 | lua_assert(!luai_numisnan(r) && !isminuszero(r)); |
| 368 | − setnvalue(&o, r); | |
| 369 | + setfltvalue(&o, r); | |
| 369 | 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 | 769 | return (tointeger(v1, &i) && tointeger(v2, &i)); |
| 769 | 770 | case LUA_OPMOD: /* integer module by 0 */ |
| 770 | 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 | 772 | default: return 1; /* everything else is valid */ |
| 774 | 773 | } |
| 775 | 774 | } |