aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lcode.c3
-rw-r--r--lcode.h6
-rw-r--r--lopcodes.c10
-rw-r--r--lopcodes.h6
-rw-r--r--lparser.c20
-rw-r--r--ltests.c4
-rw-r--r--ltm.c7
-rw-r--r--ltm.h8
-rw-r--r--lua.h12
9 files changed, 41 insertions, 35 deletions
diff --git a/lcode.c b/lcode.c
index 34dadd1f..149114cf 100644
--- a/lcode.c
+++ b/lcode.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lcode.c,v 2.72 2013/08/30 16:01:37 roberto Exp roberto $ 2** $Id: lcode.c,v 2.73 2013/12/16 14:30:22 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*/
@@ -762,6 +762,7 @@ static int constfolding (OpCode op, expdesc *e1, expdesc *e2) {
762 ((op == OP_MOD && ivalue(&v2) == 0) || /* ...avoid module by 0... */ 762 ((op == OP_MOD && ivalue(&v2) == 0) || /* ...avoid module by 0... */
763 (op == OP_POW && ivalue(&v2) < 0))) /* ...and negative exponents */ 763 (op == OP_POW && ivalue(&v2) < 0))) /* ...and negative exponents */
764 return 0; 764 return 0;
765 lua_assert(OP_IDIV - OP_ADD + LUA_OPADD == LUA_OPIDIV);
765 luaO_arith(NULL, op - OP_ADD + LUA_OPADD, &v1, &v2, &res); 766 luaO_arith(NULL, op - OP_ADD + LUA_OPADD, &v1, &v2, &res);
766 if (ttisinteger(&res)) { 767 if (ttisinteger(&res)) {
767 e1->k = VKINT; 768 e1->k = VKINT;
diff --git a/lcode.h b/lcode.h
index ddf4094c..65416637 100644
--- a/lcode.h
+++ b/lcode.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lcode.h,v 1.59 2013/04/25 19:35:19 roberto Exp roberto $ 2** $Id: lcode.h,v 1.60 2013/04/26 13:07:53 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*/
@@ -24,7 +24,9 @@
24** grep "ORDER OPR" if you change these enums (ORDER OP) 24** grep "ORDER OPR" if you change these enums (ORDER OP)
25*/ 25*/
26typedef enum BinOpr { 26typedef enum BinOpr {
27 OPR_ADD, OPR_SUB, OPR_MUL, OPR_DIV, OPR_IDIV, OPR_MOD, OPR_POW, 27 OPR_ADD, OPR_SUB, OPR_MUL, OPR_MOD, OPR_POW,
28 OPR_DIV,
29 OPR_IDIV,
28 OPR_CONCAT, 30 OPR_CONCAT,
29 OPR_EQ, OPR_LT, OPR_LE, 31 OPR_EQ, OPR_LT, OPR_LE,
30 OPR_NE, OPR_GT, OPR_GE, 32 OPR_NE, OPR_GT, OPR_GE,
diff --git a/lopcodes.c b/lopcodes.c
index 64a637b8..fd2261fb 100644
--- a/lopcodes.c
+++ b/lopcodes.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lopcodes.c,v 1.49 2012/05/14 13:34:18 roberto Exp roberto $ 2** $Id: lopcodes.c,v 1.50 2013/04/26 13:07:53 roberto Exp roberto $
3** Opcodes for Lua virtual machine 3** Opcodes for Lua virtual machine
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -31,10 +31,10 @@ LUAI_DDEF const char *const luaP_opnames[NUM_OPCODES+1] = {
31 "ADD", 31 "ADD",
32 "SUB", 32 "SUB",
33 "MUL", 33 "MUL",
34 "DIV",
35 "IDIV",
36 "MOD", 34 "MOD",
37 "POW", 35 "POW",
36 "DIV",
37 "IDIV",
38 "UNM", 38 "UNM",
39 "NOT", 39 "NOT",
40 "LEN", 40 "LEN",
@@ -80,10 +80,10 @@ LUAI_DDEF const lu_byte luaP_opmodes[NUM_OPCODES] = {
80 ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_ADD */ 80 ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_ADD */
81 ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_SUB */ 81 ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_SUB */
82 ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_MUL */ 82 ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_MUL */
83 ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_DIV */
84 ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_IDIV */
85 ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_MOD */ 83 ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_MOD */
86 ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_POW */ 84 ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_POW */
85 ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_DIV */
86 ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_IDIV */
87 ,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_UNM */ 87 ,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_UNM */
88 ,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_NOT */ 88 ,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_NOT */
89 ,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_LEN */ 89 ,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_LEN */
diff --git a/lopcodes.h b/lopcodes.h
index e427ce49..a5673ade 100644
--- a/lopcodes.h
+++ b/lopcodes.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lopcodes.h,v 1.142 2011/07/15 12:50:29 roberto Exp roberto $ 2** $Id: lopcodes.h,v 1.143 2013/04/26 13:07:53 roberto Exp roberto $
3** Opcodes for Lua virtual machine 3** Opcodes for Lua virtual machine
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -187,10 +187,10 @@ OP_SELF,/* A B C R(A+1) := R(B); R(A) := R(B)[RK(C)] */
187OP_ADD,/* A B C R(A) := RK(B) + RK(C) */ 187OP_ADD,/* A B C R(A) := RK(B) + RK(C) */
188OP_SUB,/* A B C R(A) := RK(B) - RK(C) */ 188OP_SUB,/* A B C R(A) := RK(B) - RK(C) */
189OP_MUL,/* A B C R(A) := RK(B) * RK(C) */ 189OP_MUL,/* A B C R(A) := RK(B) * RK(C) */
190OP_DIV,/* A B C R(A) := RK(B) / RK(C) */
191OP_IDIV,/* A B C R(A) := RK(B) // RK(C) */
192OP_MOD,/* A B C R(A) := RK(B) % RK(C) */ 190OP_MOD,/* A B C R(A) := RK(B) % RK(C) */
193OP_POW,/* A B C R(A) := RK(B) ^ RK(C) */ 191OP_POW,/* A B C R(A) := RK(B) ^ RK(C) */
192OP_DIV,/* A B C R(A) := RK(B) / RK(C) */
193OP_IDIV,/* A B C R(A) := RK(B) // RK(C) */
194OP_UNM,/* A B R(A) := -R(B) */ 194OP_UNM,/* A B R(A) := -R(B) */
195OP_NOT,/* A B R(A) := not R(B) */ 195OP_NOT,/* A B R(A) := not R(B) */
196OP_LEN,/* A B R(A) := length of R(B) */ 196OP_LEN,/* A B R(A) := length of R(B) */
diff --git a/lparser.c b/lparser.c
index 0f53ff7c..c23b2dde 100644
--- a/lparser.c
+++ b/lparser.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lparser.c,v 2.134 2013/08/16 18:55:49 roberto Exp roberto $ 2** $Id: lparser.c,v 2.135 2013/08/30 16:01:37 roberto Exp roberto $
3** Lua Parser 3** Lua Parser
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -990,10 +990,10 @@ static BinOpr getbinopr (int op) {
990 case '+': return OPR_ADD; 990 case '+': return OPR_ADD;
991 case '-': return OPR_SUB; 991 case '-': return OPR_SUB;
992 case '*': return OPR_MUL; 992 case '*': return OPR_MUL;
993 case '/': return OPR_DIV;
994 case TK_IDIV: return OPR_IDIV;
995 case '%': return OPR_MOD; 993 case '%': return OPR_MOD;
996 case '^': return OPR_POW; 994 case '^': return OPR_POW;
995 case '/': return OPR_DIV;
996 case TK_IDIV: return OPR_IDIV;
997 case TK_CONCAT: return OPR_CONCAT; 997 case TK_CONCAT: return OPR_CONCAT;
998 case TK_NE: return OPR_NE; 998 case TK_NE: return OPR_NE;
999 case TK_EQ: return OPR_EQ; 999 case TK_EQ: return OPR_EQ;
@@ -1012,12 +1012,14 @@ static const struct {
1012 lu_byte left; /* left priority for each binary operator */ 1012 lu_byte left; /* left priority for each binary operator */
1013 lu_byte right; /* right priority */ 1013 lu_byte right; /* right priority */
1014} priority[] = { /* ORDER OPR */ 1014} priority[] = { /* ORDER OPR */
1015 {6, 6}, {6, 6}, /* '+' '-' */ 1015 {6, 6}, {6, 6}, /* '+' '-' */
1016 {7, 7}, {7, 7}, {7, 7}, {7, 7}, /* '*' '/' '//' '%' */ 1016 {7, 7}, {7, 7}, /* '*' '%' */
1017 {10, 9}, {5, 4}, /* ^, .. (right associative) */ 1017 {10, 9}, /* '^' (right associative) */
1018 {3, 3}, {3, 3}, {3, 3}, /* ==, <, <= */ 1018 {7, 7}, {7, 7}, /* '/' '//' */
1019 {3, 3}, {3, 3}, {3, 3}, /* ~=, >, >= */ 1019 {5, 4}, /* '..' (right associative) */
1020 {2, 2}, {1, 1} /* and, or */ 1020 {3, 3}, {3, 3}, {3, 3}, /* ==, <, <= */
1021 {3, 3}, {3, 3}, {3, 3}, /* ~=, >, >= */
1022 {2, 2}, {1, 1} /* and, or */
1021}; 1023};
1022 1024
1023#define UNARY_PRIORITY 8 /* priority for unary operators */ 1025#define UNARY_PRIORITY 8 /* priority for unary operators */
diff --git a/ltests.c b/ltests.c
index bf32c115..a4462798 100644
--- a/ltests.c
+++ b/ltests.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ltests.c,v 2.158 2013/09/11 14:09:55 roberto Exp roberto $ 2** $Id: ltests.c,v 2.159 2013/09/11 14:47:08 roberto Exp roberto $
3** Internal Module for Debugging of the Lua Implementation 3** Internal Module for Debugging of the Lua Implementation
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -1198,7 +1198,7 @@ static int runC (lua_State *L, lua_State *L1, const char *pc) {
1198 } 1198 }
1199 } 1199 }
1200 else if EQ("arith") { 1200 else if EQ("arith") {
1201 static char ops[] = "+-*/\\%^_"; /* '\' -> '//'; '_' -> '..' */ 1201 static char ops[] = "+-*%^/\\_"; /* '\' -> '//'; '_' -> '..' */
1202 int op; 1202 int op;
1203 skip(&pc); 1203 skip(&pc);
1204 op = strchr(ops, *pc++) - ops; 1204 op = strchr(ops, *pc++) - ops;
diff --git a/ltm.c b/ltm.c
index 62c1430c..8eb504d1 100644
--- a/ltm.c
+++ b/ltm.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ltm.c,v 2.21 2013/08/21 20:09:51 roberto Exp roberto $ 2** $Id: ltm.c,v 2.22 2013/08/27 18:53:35 roberto Exp roberto $
3** Tag methods 3** Tag methods
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -36,8 +36,9 @@ void luaT_init (lua_State *L) {
36 static const char *const luaT_eventname[] = { /* ORDER TM */ 36 static const char *const luaT_eventname[] = { /* ORDER TM */
37 "__index", "__newindex", 37 "__index", "__newindex",
38 "__gc", "__mode", "__len", "__eq", 38 "__gc", "__mode", "__len", "__eq",
39 "__add", "__sub", "__mul", "__div", "__idiv", "__mod", 39 "__add", "__sub", "__mul", "__mod", "__pow",
40 "__pow", "__unm", "__lt", "__le", 40 "__div", "__idiv",
41 "__unm", "__lt", "__le",
41 "__concat", "__call" 42 "__concat", "__call"
42 }; 43 };
43 int i; 44 int i;
diff --git a/ltm.h b/ltm.h
index 053dc145..196825b9 100644
--- a/ltm.h
+++ b/ltm.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ltm.h,v 2.15 2013/04/26 13:07:53 roberto Exp roberto $ 2** $Id: ltm.h,v 2.16 2013/04/29 16:56:50 roberto Exp roberto $
3** Tag methods 3** Tag methods
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -13,7 +13,7 @@
13 13
14/* 14/*
15* WARNING: if you change the order of this enumeration, 15* WARNING: if you change the order of this enumeration,
16* grep "ORDER TM" 16* grep "ORDER TM" and "ORDER OP"
17*/ 17*/
18typedef enum { 18typedef enum {
19 TM_INDEX, 19 TM_INDEX,
@@ -25,10 +25,10 @@ typedef enum {
25 TM_ADD, 25 TM_ADD,
26 TM_SUB, 26 TM_SUB,
27 TM_MUL, 27 TM_MUL,
28 TM_DIV,
29 TM_IDIV,
30 TM_MOD, 28 TM_MOD,
31 TM_POW, 29 TM_POW,
30 TM_DIV,
31 TM_IDIV,
32 TM_UNM, 32 TM_UNM,
33 TM_LT, 33 TM_LT,
34 TM_LE, 34 TM_LE,
diff --git a/lua.h b/lua.h
index f98513ac..a44a1d9a 100644
--- a/lua.h
+++ b/lua.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lua.h,v 1.294 2013/09/13 16:21:52 roberto Exp roberto $ 2** $Id: lua.h,v 1.295 2013/12/09 14:21:10 roberto Exp roberto $
3** Lua - A Scripting Language 3** Lua - A Scripting Language
4** Lua.org, PUC-Rio, Brazil (http://www.lua.org) 4** Lua.org, PUC-Rio, Brazil (http://www.lua.org)
5** See Copyright Notice at the end of this file 5** See Copyright Notice at the end of this file
@@ -182,13 +182,13 @@ LUA_API const void *(lua_topointer) (lua_State *L, int idx);
182** Comparison and arithmetic functions 182** Comparison and arithmetic functions
183*/ 183*/
184 184
185#define LUA_OPADD 0 /* ORDER TM */ 185#define LUA_OPADD 0 /* ORDER TM, ORDER OP */
186#define LUA_OPSUB 1 186#define LUA_OPSUB 1
187#define LUA_OPMUL 2 187#define LUA_OPMUL 2
188#define LUA_OPDIV 3 188#define LUA_OPMOD 3
189#define LUA_OPIDIV 4 189#define LUA_OPPOW 4
190#define LUA_OPMOD 5 190#define LUA_OPDIV 5
191#define LUA_OPPOW 6 191#define LUA_OPIDIV 6
192#define LUA_OPUNM 7 192#define LUA_OPUNM 7
193 193
194LUA_API void (lua_arith) (lua_State *L, int op); 194LUA_API void (lua_arith) (lua_State *L, int op);