aboutsummaryrefslogtreecommitdiff
path: root/lcode.c
diff options
context:
space:
mode:
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;