aboutsummaryrefslogtreecommitdiff
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-99ac4a260fc1bf958515c1816d866852194493f2.tar.gz
lua-99ac4a260fc1bf958515c1816d866852194493f2.tar.bz2
lua-99ac4a260fc1bf958515c1816d866852194493f2.zip
'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 @@
1/* 1/*
2** $Id: lcode.c,v 2.79 2014/02/06 19:55:55 roberto Exp roberto $ 2** $Id: lcode.c,v 2.80 2014/03/06 13:39:05 roberto Exp roberto $
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*/
@@ -773,11 +773,11 @@ static int validop (OpCode op, TValue *v1, TValue *v2) {
773/* 773/*
774** Try to "constant-fold" an operation; return 1 iff successful 774** Try to "constant-fold" an operation; return 1 iff successful
775*/ 775*/
776static int constfolding (int op, expdesc *e1, expdesc *e2) { 776static int constfolding (FuncState *fs, int op, expdesc *e1, expdesc *e2) {
777 TValue v1, v2, res; 777 TValue v1, v2, res;
778 if (!tonumeral(e1, &v1) || !tonumeral(e2, &v2) || !validop(op, &v1, &v2)) 778 if (!tonumeral(e1, &v1) || !tonumeral(e2, &v2) || !validop(op, &v1, &v2))
779 return 0; /* non-numeric operands or not safe to fold */ 779 return 0; /* non-numeric operands or not safe to fold */
780 luaO_arith(NULL, op, &v1, &v2, &res); 780 luaO_arith(fs->ls->L, op, &v1, &v2, &res);
781 if (ttisinteger(&res)) { 781 if (ttisinteger(&res)) {
782 e1->k = VKINT; 782 e1->k = VKINT;
783 e1->u.ival = ivalue(&res); 783 e1->u.ival = ivalue(&res);
@@ -795,7 +795,7 @@ static int constfolding (int op, expdesc *e1, expdesc *e2) {
795 795
796static void codearith (FuncState *fs, OpCode op, 796static void codearith (FuncState *fs, OpCode op,
797 expdesc *e1, expdesc *e2, int line) { 797 expdesc *e1, expdesc *e2, int line) {
798 if (!constfolding(op - OP_ADD + LUA_OPADD, e1, e2)) { 798 if (!constfolding(fs, op - OP_ADD + LUA_OPADD, e1, e2)) {
799 int o1, o2; 799 int o1, o2;
800 if (op == OP_UNM || op == OP_BNOT || op == OP_LEN) { 800 if (op == OP_UNM || op == OP_BNOT || op == OP_LEN) {
801 o2 = 0; 801 o2 = 0;