summaryrefslogtreecommitdiff
path: root/lvm.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2014-03-06 13:15:18 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2014-03-06 13:15:18 -0300
commit5ff1c18a715b842a6146a6a07d99c84f48cac999 (patch)
treeb90579a688fd971f80e7628cba179fdf389a27c8 /lvm.c
parent99ac4a260fc1bf958515c1816d866852194493f2 (diff)
downloadlua-5ff1c18a715b842a6146a6a07d99c84f48cac999.tar.gz
lua-5ff1c18a715b842a6146a6a07d99c84f48cac999.tar.bz2
lua-5ff1c18a715b842a6146a6a07d99c84f48cac999.zip
back with 'L' for macros 'luai_num*', but now with a new macro
'luai_numinvalidop' to protect constant folding
Diffstat (limited to '')
-rw-r--r--lvm.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/lvm.c b/lvm.c
index 835e8e0f..12c68023 100644
--- a/lvm.c
+++ b/lvm.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lvm.c,v 2.185 2014/01/27 13:34:32 roberto Exp roberto $ 2** $Id: lvm.c,v 2.186 2014/02/05 19:14:53 roberto Exp roberto $
3** Lua virtual machine 3** Lua virtual machine
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -633,7 +633,7 @@ void luaV_execute (lua_State *L) {
633 setivalue(ra, intop(+, ib, ic)); 633 setivalue(ra, intop(+, ib, ic));
634 } 634 }
635 else if (tonumber(rb, &nb) && tonumber(rc, &nc)) { 635 else if (tonumber(rb, &nb) && tonumber(rc, &nc)) {
636 setnvalue(ra, luai_numadd(nb, nc)); 636 setnvalue(ra, luai_numadd(L, nb, nc));
637 } 637 }
638 else { Protect(luaT_trybinTM(L, rb, rc, ra, TM_ADD)); } 638 else { Protect(luaT_trybinTM(L, rb, rc, ra, TM_ADD)); }
639 ) 639 )
@@ -646,7 +646,7 @@ void luaV_execute (lua_State *L) {
646 setivalue(ra, intop(-, ib, ic)); 646 setivalue(ra, intop(-, ib, ic));
647 } 647 }
648 else if (tonumber(rb, &nb) && tonumber(rc, &nc)) { 648 else if (tonumber(rb, &nb) && tonumber(rc, &nc)) {
649 setnvalue(ra, luai_numsub(nb, nc)); 649 setnvalue(ra, luai_numsub(L, nb, nc));
650 } 650 }
651 else { Protect(luaT_trybinTM(L, rb, rc, ra, TM_SUB)); } 651 else { Protect(luaT_trybinTM(L, rb, rc, ra, TM_SUB)); }
652 ) 652 )
@@ -659,7 +659,7 @@ void luaV_execute (lua_State *L) {
659 setivalue(ra, intop(*, ib, ic)); 659 setivalue(ra, intop(*, ib, ic));
660 } 660 }
661 else if (tonumber(rb, &nb) && tonumber(rc, &nc)) { 661 else if (tonumber(rb, &nb) && tonumber(rc, &nc)) {
662 setnvalue(ra, luai_nummul(nb, nc)); 662 setnvalue(ra, luai_nummul(L, nb, nc));
663 } 663 }
664 else { Protect(luaT_trybinTM(L, rb, rc, ra, TM_MUL)); } 664 else { Protect(luaT_trybinTM(L, rb, rc, ra, TM_MUL)); }
665 ) 665 )
@@ -668,7 +668,7 @@ void luaV_execute (lua_State *L) {
668 TValue *rc = RKC(i); 668 TValue *rc = RKC(i);
669 lua_Number nb; lua_Number nc; 669 lua_Number nb; lua_Number nc;
670 if (tonumber(rb, &nb) && tonumber(rc, &nc)) { 670 if (tonumber(rb, &nb) && tonumber(rc, &nc)) {
671 setnvalue(ra, luai_numdiv(nb, nc)); 671 setnvalue(ra, luai_numdiv(L, nb, nc));
672 } 672 }
673 else { Protect(luaT_trybinTM(L, rb, rc, ra, TM_DIV)); } 673 else { Protect(luaT_trybinTM(L, rb, rc, ra, TM_DIV)); }
674 ) 674 )
@@ -735,7 +735,7 @@ void luaV_execute (lua_State *L) {
735 setivalue(ra, luaV_mod(L, ib, ic)); 735 setivalue(ra, luaV_mod(L, ib, ic));
736 } 736 }
737 else if (tonumber(rb, &nb) && tonumber(rc, &nc)) { 737 else if (tonumber(rb, &nb) && tonumber(rc, &nc)) {
738 setnvalue(ra, luai_nummod(nb, nc)); 738 setnvalue(ra, luai_nummod(L, nb, nc));
739 } 739 }
740 else { Protect(luaT_trybinTM(L, rb, rc, ra, TM_MOD)); } 740 else { Protect(luaT_trybinTM(L, rb, rc, ra, TM_MOD)); }
741 ) 741 )
@@ -748,7 +748,7 @@ void luaV_execute (lua_State *L) {
748 setivalue(ra, luaV_pow(L, ib, ic)); 748 setivalue(ra, luaV_pow(L, ib, ic));
749 } 749 }
750 else if (tonumber(rb, &nb) && tonumber(rc, &nc)) { 750 else if (tonumber(rb, &nb) && tonumber(rc, &nc)) {
751 setnvalue(ra, luai_numpow(nb, nc)); 751 setnvalue(ra, luai_numpow(L, nb, nc));
752 } 752 }
753 else { Protect(luaT_trybinTM(L, rb, rc, ra, TM_POW)); } 753 else { Protect(luaT_trybinTM(L, rb, rc, ra, TM_POW)); }
754 ) 754 )
@@ -760,7 +760,7 @@ void luaV_execute (lua_State *L) {
760 setivalue(ra, intop(-, 0, ib)); 760 setivalue(ra, intop(-, 0, ib));
761 } 761 }
762 else if (tonumber(rb, &nb)) { 762 else if (tonumber(rb, &nb)) {
763 setnvalue(ra, luai_numunm(nb)); 763 setnvalue(ra, luai_numunm(L, nb));
764 } 764 }
765 else { 765 else {
766 Protect(luaT_trybinTM(L, rb, rb, ra, TM_UNM)); 766 Protect(luaT_trybinTM(L, rb, rb, ra, TM_UNM));
@@ -911,10 +911,10 @@ void luaV_execute (lua_State *L) {
911 } 911 }
912 else { /* floating count */ 912 else { /* floating count */
913 lua_Number step = fltvalue(ra + 2); 913 lua_Number step = fltvalue(ra + 2);
914 lua_Number idx = luai_numadd(fltvalue(ra), step); /* inc. index */ 914 lua_Number idx = luai_numadd(L, fltvalue(ra), step); /* inc. index */
915 lua_Number limit = fltvalue(ra + 1); 915 lua_Number limit = fltvalue(ra + 1);
916 if (luai_numlt(0, step) ? luai_numle(idx, limit) 916 if (luai_numlt(0, step) ? luai_numle(idx, limit)
917 : luai_numle(limit, idx)) { 917 : luai_numle(limit, idx)) {
918 ci->u.l.savedpc += GETARG_sBx(i); /* jump back */ 918 ci->u.l.savedpc += GETARG_sBx(i); /* jump back */
919 setnvalue(ra, idx); /* update internal index... */ 919 setnvalue(ra, idx); /* update internal index... */
920 setnvalue(ra + 3, idx); /* ...and external index */ 920 setnvalue(ra + 3, idx); /* ...and external index */
@@ -938,7 +938,7 @@ void luaV_execute (lua_State *L) {
938 setnvalue(pstep, nstep); 938 setnvalue(pstep, nstep);
939 if (!tonumber(init, &ninit)) 939 if (!tonumber(init, &ninit))
940 luaG_runerror(L, LUA_QL("for") " initial value must be a number"); 940 luaG_runerror(L, LUA_QL("for") " initial value must be a number");
941 setnvalue(ra, luai_numsub(ninit, nstep)); 941 setnvalue(ra, luai_numsub(L, ninit, nstep));
942 } 942 }
943 ci->u.l.savedpc += GETARG_sBx(i); 943 ci->u.l.savedpc += GETARG_sBx(i);
944 ) 944 )