summaryrefslogtreecommitdiff
path: root/lcode.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2014-03-06 10:58:28 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2014-03-06 10:58:28 -0300
commit99ac4a260fc1bf958515c1816d866852194493f2 (patch)
tree8c56830198b0953c5b6657898a54162571385a5d /lcode.c
parentfa7e77fd38e49f1da179f2811df3ac17c3e2ccfe (diff)
downloadlua-github-99ac4a260fc1bf958515c1816d866852194493f2.tar.gz
'constfolding' passes a proper Lua state to 'luaO_arith'
Diffstat (limited to 'lcode.c')
-rw-r--r--lcode.c8
1 files 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;