diff options
Diffstat (limited to 'lcode.c')
-rw-r--r-- | lcode.c | 9 |
1 files changed, 5 insertions, 4 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lcode.c,v 2.64 2013/04/16 18:46:28 roberto Exp roberto $ | 2 | ** $Id: lcode.c,v 2.65 2013/04/25 19:35:19 roberto Exp $ |
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 | */ |
@@ -732,7 +732,7 @@ void luaK_indexed (FuncState *fs, expdesc *t, expdesc *k) { | |||
732 | static int constfolding (OpCode op, expdesc *e1, expdesc *e2) { | 732 | static int constfolding (OpCode op, expdesc *e1, expdesc *e2) { |
733 | lua_Number r; | 733 | lua_Number r; |
734 | if (!isnumeral(e1) || !isnumeral(e2)) return 0; | 734 | if (!isnumeral(e1) || !isnumeral(e2)) return 0; |
735 | if ((op == OP_DIV || op == OP_MOD) && e2->u.nval == 0) | 735 | if ((op == OP_DIV || op == OP_IDIV || op == OP_MOD) && e2->u.nval == 0) |
736 | return 0; /* do not attempt to divide by 0 */ | 736 | return 0; /* do not attempt to divide by 0 */ |
737 | r = luaO_arith(op - OP_ADD + LUA_OPADD, e1->u.nval, e2->u.nval); | 737 | r = luaO_arith(op - OP_ADD + LUA_OPADD, e1->u.nval, e2->u.nval); |
738 | e1->u.nval = r; | 738 | e1->u.nval = r; |
@@ -816,7 +816,8 @@ void luaK_infix (FuncState *fs, BinOpr op, expdesc *v) { | |||
816 | luaK_exp2nextreg(fs, v); /* operand must be on the `stack' */ | 816 | luaK_exp2nextreg(fs, v); /* operand must be on the `stack' */ |
817 | break; | 817 | break; |
818 | } | 818 | } |
819 | case OPR_ADD: case OPR_SUB: case OPR_MUL: case OPR_DIV: | 819 | case OPR_ADD: case OPR_SUB: |
820 | case OPR_MUL: case OPR_DIV: case OPR_IDIV: | ||
820 | case OPR_MOD: case OPR_POW: { | 821 | case OPR_MOD: case OPR_POW: { |
821 | if (!isnumeral(v)) luaK_exp2RK(fs, v); | 822 | if (!isnumeral(v)) luaK_exp2RK(fs, v); |
822 | break; | 823 | break; |
@@ -861,7 +862,7 @@ void luaK_posfix (FuncState *fs, BinOpr op, | |||
861 | break; | 862 | break; |
862 | } | 863 | } |
863 | case OPR_ADD: case OPR_SUB: case OPR_MUL: case OPR_DIV: | 864 | case OPR_ADD: case OPR_SUB: case OPR_MUL: case OPR_DIV: |
864 | case OPR_MOD: case OPR_POW: { | 865 | case OPR_IDIV: case OPR_MOD: case OPR_POW: { |
865 | codearith(fs, cast(OpCode, op - OPR_ADD + OP_ADD), e1, e2, line); | 866 | codearith(fs, cast(OpCode, op - OPR_ADD + OP_ADD), e1, e2, line); |
866 | break; | 867 | break; |
867 | } | 868 | } |