aboutsummaryrefslogtreecommitdiff
path: root/lcode.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2007-05-04 15:41:49 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2007-05-04 15:41:49 -0300
commit81fc3c4f45c0e2175dc96fc061e600bafb02bdc7 (patch)
tree9e2263e63c8a412572e22bdaf087c1fd1eb3a475 /lcode.c
parente7fb0d8a6f10338fe62e869115dfe9f3a73e2552 (diff)
downloadlua-81fc3c4f45c0e2175dc96fc061e600bafb02bdc7.tar.gz
lua-81fc3c4f45c0e2175dc96fc061e600bafb02bdc7.tar.bz2
lua-81fc3c4f45c0e2175dc96fc061e600bafb02bdc7.zip
bug: code generated for "-nil", "-true", and "-false" is wrong
Diffstat (limited to 'lcode.c')
-rw-r--r--lcode.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/lcode.c b/lcode.c
index ca94ca43..853cffe2 100644
--- a/lcode.c
+++ b/lcode.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lcode.c,v 2.32 2007/03/09 18:50:56 roberto Exp roberto $ 2** $Id: lcode.c,v 2.33 2007/03/27 14:11:38 roberto Exp roberto $
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*/
@@ -647,8 +647,6 @@ static int constfolding (OpCode op, expdesc *e1, expdesc *e2) {
647 if (v2 == 0) return 0; /* do not attempt to divide by 0 */ 647 if (v2 == 0) return 0; /* do not attempt to divide by 0 */
648 r = luai_nummod(NULL, v1, v2); break; 648 r = luai_nummod(NULL, v1, v2); break;
649 case OP_POW: r = luai_numpow(NULL, v1, v2); break; 649 case OP_POW: r = luai_numpow(NULL, v1, v2); break;
650 case OP_UNM: r = luai_numunm(NULL, v1); break;
651 case OP_LEN: return 0; /* no constant folding for 'len' */
652 default: lua_assert(0); r = 0; break; 650 default: lua_assert(0); r = 0; break;
653 } 651 }
654 if (luai_numisnan(NULL, r)) return 0; /* do not attempt to produce NaN */ 652 if (luai_numisnan(NULL, r)) return 0; /* do not attempt to produce NaN */
@@ -698,9 +696,12 @@ void luaK_prefix (FuncState *fs, UnOpr op, expdesc *e) {
698 e2.t = e2.f = NO_JUMP; e2.k = VKNUM; e2.u.nval = 0; 696 e2.t = e2.f = NO_JUMP; e2.k = VKNUM; e2.u.nval = 0;
699 switch (op) { 697 switch (op) {
700 case OPR_MINUS: { 698 case OPR_MINUS: {
701 if (e->k == VK) 699 if (isnumeral(e)) /* -constant? */
702 luaK_exp2anyreg(fs, e); /* cannot operate on non-numeric constants */ 700 e->u.nval = luai_numunm(NULL, e->u.nval);
703 codearith(fs, OP_UNM, e, &e2); 701 else {
702 luaK_exp2anyreg(fs, e);
703 codearith(fs, OP_UNM, e, &e2);
704 }
704 break; 705 break;
705 } 706 }
706 case OPR_NOT: codenot(fs, e); break; 707 case OPR_NOT: codenot(fs, e); break;