From 99ac4a260fc1bf958515c1816d866852194493f2 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Thu, 6 Mar 2014 10:58:28 -0300 Subject: [PATCH] 'constfolding' passes a proper Lua state to 'luaO_arith' --- lcode.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lcode.c b/lcode.c index 64f36e69..1e85dde0 100644 --- a/lcode.c +++ b/lcode.c @@ -1,5 +1,5 @@ /* -** $Id: lcode.c,v 2.79 2014/02/06 19:55:55 roberto Exp roberto $ +** $Id: lcode.c,v 2.80 2014/03/06 13:39:05 roberto Exp roberto $ ** Code generator for Lua ** See Copyright Notice in lua.h */ @@ -773,11 +773,11 @@ static int validop (OpCode op, TValue *v1, TValue *v2) { /* ** Try to "constant-fold" an operation; return 1 iff successful */ -static int constfolding (int op, expdesc *e1, expdesc *e2) { +static int constfolding (FuncState *fs, int op, expdesc *e1, expdesc *e2) { TValue v1, v2, res; if (!tonumeral(e1, &v1) || !tonumeral(e2, &v2) || !validop(op, &v1, &v2)) return 0; /* non-numeric operands or not safe to fold */ - luaO_arith(NULL, op, &v1, &v2, &res); + luaO_arith(fs->ls->L, op, &v1, &v2, &res); if (ttisinteger(&res)) { e1->k = VKINT; e1->u.ival = ivalue(&res); @@ -795,7 +795,7 @@ static int constfolding (int op, expdesc *e1, expdesc *e2) { static void codearith (FuncState *fs, OpCode op, expdesc *e1, expdesc *e2, int line) { - if (!constfolding(op - OP_ADD + LUA_OPADD, e1, e2)) { + if (!constfolding(fs, op - OP_ADD + LUA_OPADD, e1, e2)) { int o1, o2; if (op == OP_UNM || op == OP_BNOT || op == OP_LEN) { o2 = 0;