diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2014-03-07 13:19:00 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2014-03-07 13:19:00 -0300 |
commit | cd12410195e092f966db2c9e524c2cd5fd09fa1a (patch) | |
tree | 5c7eb74fe79df2cb5fb65969bfc0fda23a11d9e6 | |
parent | c5bb3643ab28d5309971f1960dd5222b9c81fd3a (diff) | |
download | lua-cd12410195e092f966db2c9e524c2cd5fd09fa1a.tar.gz lua-cd12410195e092f966db2c9e524c2cd5fd09fa1a.tar.bz2 lua-cd12410195e092f966db2c9e524c2cd5fd09fa1a.zip |
new macro 'cast_void'
-rw-r--r-- | lcode.c | 7 | ||||
-rw-r--r-- | llimits.h | 3 | ||||
-rw-r--r-- | lvm.c | 6 |
3 files changed, 9 insertions, 7 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lcode.c,v 2.81 2014/03/06 13:58:28 roberto Exp roberto $ | 2 | ** $Id: lcode.c,v 2.82 2014/03/06 16:15:18 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 | */ |
@@ -756,8 +756,9 @@ void luaK_indexed (FuncState *fs, expdesc *t, expdesc *k) { | |||
756 | static int validop (OpCode op, TValue *v1, TValue *v2) { | 756 | static int validop (OpCode op, TValue *v1, TValue *v2) { |
757 | lua_Number a, b; | 757 | lua_Number a, b; |
758 | lua_Integer i; | 758 | lua_Integer i; |
759 | (void)a; (void)b; /* macro may not use its arguments */ | 759 | cast_void(a); cast_void(b); /* macro may not use its arguments */ |
760 | if (luai_numinvalidop(op, (tonumber(v1, &a), a), (tonumber(v2, &b), b))) | 760 | if (luai_numinvalidop(op, (cast_void(tonumber(v1, &a)), a), |
761 | (cast_void(tonumber(v2, &b)), b))) | ||
761 | return 0; | 762 | return 0; |
762 | switch (op) { | 763 | switch (op) { |
763 | case LUA_OPIDIV: /* division by 0 and conversion errors */ | 764 | case LUA_OPIDIV: /* division by 0 and conversion errors */ |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: llimits.h,v 1.109 2013/08/21 19:02:30 roberto Exp roberto $ | 2 | ** $Id: llimits.h,v 1.110 2014/02/26 12:38:43 roberto Exp roberto $ |
3 | ** Limits, basic types, and some other `installation-dependent' definitions | 3 | ** Limits, basic types, and some other `installation-dependent' definitions |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -106,6 +106,7 @@ typedef LUAI_UACNUMBER l_uacNumber; | |||
106 | 106 | ||
107 | #define cast(t, exp) ((t)(exp)) | 107 | #define cast(t, exp) ((t)(exp)) |
108 | 108 | ||
109 | #define cast_void(i) cast(void, (i)) | ||
109 | #define cast_byte(i) cast(lu_byte, (i)) | 110 | #define cast_byte(i) cast(lu_byte, (i)) |
110 | #define cast_num(i) cast(lua_Number, (i)) | 111 | #define cast_num(i) cast(lua_Number, (i)) |
111 | #define cast_int(i) cast(int, (i)) | 112 | #define cast_int(i) cast(int, (i)) |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lvm.c,v 2.186 2014/02/05 19:14:53 roberto Exp roberto $ | 2 | ** $Id: lvm.c,v 2.187 2014/03/06 16:15:18 roberto Exp roberto $ |
3 | ** Lua virtual machine | 3 | ** Lua virtual machine |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -222,7 +222,7 @@ int luaV_equalobj (lua_State *L, const TValue *t1, const TValue *t2) { | |||
222 | else { /* two numbers with different variants */ | 222 | else { /* two numbers with different variants */ |
223 | lua_Number n1, n2; | 223 | lua_Number n1, n2; |
224 | lua_assert(ttisnumber(t1) && ttisnumber(t2)); | 224 | lua_assert(ttisnumber(t1) && ttisnumber(t2)); |
225 | (void)tonumber(t1, &n1); (void)tonumber(t2, &n2); | 225 | cast_void(tonumber(t1, &n1)); cast_void(tonumber(t2, &n2)); |
226 | return luai_numeq(n1, n2); | 226 | return luai_numeq(n1, n2); |
227 | } | 227 | } |
228 | } | 228 | } |
@@ -265,7 +265,7 @@ void luaV_concat (lua_State *L, int total) { | |||
265 | if (!(ttisstring(top-2) || ttisnumber(top-2)) || !tostring(L, top-1)) | 265 | if (!(ttisstring(top-2) || ttisnumber(top-2)) || !tostring(L, top-1)) |
266 | luaT_trybinTM(L, top-2, top-1, top-2, TM_CONCAT); | 266 | luaT_trybinTM(L, top-2, top-1, top-2, TM_CONCAT); |
267 | else if (tsvalue(top-1)->len == 0) /* second operand is empty? */ | 267 | else if (tsvalue(top-1)->len == 0) /* second operand is empty? */ |
268 | (void)tostring(L, top - 2); /* result is first operand */ | 268 | cast_void(tostring(L, top - 2)); /* result is first operand */ |
269 | else if (ttisstring(top-2) && tsvalue(top-2)->len == 0) { | 269 | else if (ttisstring(top-2) && tsvalue(top-2)->len == 0) { |
270 | setobjs2s(L, top - 2, top - 1); /* result is second op. */ | 270 | setobjs2s(L, top - 2, top - 1); /* result is second op. */ |
271 | } | 271 | } |