From a2f5c28a802ae99f2045ab96585fade2c65b2037 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Fri, 26 Apr 2013 10:08:29 -0300 Subject: new operation '//' (integer division) --- lcode.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'lcode.c') diff --git a/lcode.c b/lcode.c index 8a4b2ba9..8aa18b49 100644 --- a/lcode.c +++ b/lcode.c @@ -1,5 +1,5 @@ /* -** $Id: lcode.c,v 2.64 2013/04/16 18:46:28 roberto Exp roberto $ +** $Id: lcode.c,v 2.65 2013/04/25 19:35:19 roberto Exp $ ** Code generator for Lua ** See Copyright Notice in lua.h */ @@ -732,7 +732,7 @@ void luaK_indexed (FuncState *fs, expdesc *t, expdesc *k) { static int constfolding (OpCode op, expdesc *e1, expdesc *e2) { lua_Number r; if (!isnumeral(e1) || !isnumeral(e2)) return 0; - if ((op == OP_DIV || op == OP_MOD) && e2->u.nval == 0) + if ((op == OP_DIV || op == OP_IDIV || op == OP_MOD) && e2->u.nval == 0) return 0; /* do not attempt to divide by 0 */ r = luaO_arith(op - OP_ADD + LUA_OPADD, e1->u.nval, e2->u.nval); e1->u.nval = r; @@ -816,7 +816,8 @@ void luaK_infix (FuncState *fs, BinOpr op, expdesc *v) { luaK_exp2nextreg(fs, v); /* operand must be on the `stack' */ break; } - case OPR_ADD: case OPR_SUB: case OPR_MUL: case OPR_DIV: + case OPR_ADD: case OPR_SUB: + case OPR_MUL: case OPR_DIV: case OPR_IDIV: case OPR_MOD: case OPR_POW: { if (!isnumeral(v)) luaK_exp2RK(fs, v); break; @@ -861,7 +862,7 @@ void luaK_posfix (FuncState *fs, BinOpr op, break; } case OPR_ADD: case OPR_SUB: case OPR_MUL: case OPR_DIV: - case OPR_MOD: case OPR_POW: { + case OPR_IDIV: case OPR_MOD: case OPR_POW: { codearith(fs, cast(OpCode, op - OPR_ADD + OP_ADD), e1, e2, line); break; } -- cgit v1.2.3-55-g6feb