mirror of
https://github.com/lua/lua
synced 2025-02-12 03:04:03 +03:00
new macro 'cast_void'
This commit is contained in:
parent
c5bb3643ab
commit
cd12410195
7
lcode.c
7
lcode.c
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** $Id: lcode.c,v 2.81 2014/03/06 13:58:28 roberto Exp roberto $
|
||||
** $Id: lcode.c,v 2.82 2014/03/06 16:15:18 roberto Exp roberto $
|
||||
** Code generator for Lua
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
@ -756,8 +756,9 @@ void luaK_indexed (FuncState *fs, expdesc *t, expdesc *k) {
|
||||
static int validop (OpCode op, TValue *v1, TValue *v2) {
|
||||
lua_Number a, b;
|
||||
lua_Integer i;
|
||||
(void)a; (void)b; /* macro may not use its arguments */
|
||||
if (luai_numinvalidop(op, (tonumber(v1, &a), a), (tonumber(v2, &b), b)))
|
||||
cast_void(a); cast_void(b); /* macro may not use its arguments */
|
||||
if (luai_numinvalidop(op, (cast_void(tonumber(v1, &a)), a),
|
||||
(cast_void(tonumber(v2, &b)), b)))
|
||||
return 0;
|
||||
switch (op) {
|
||||
case LUA_OPIDIV: /* division by 0 and conversion errors */
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** $Id: llimits.h,v 1.109 2013/08/21 19:02:30 roberto Exp roberto $
|
||||
** $Id: llimits.h,v 1.110 2014/02/26 12:38:43 roberto Exp roberto $
|
||||
** Limits, basic types, and some other `installation-dependent' definitions
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
@ -106,6 +106,7 @@ typedef LUAI_UACNUMBER l_uacNumber;
|
||||
|
||||
#define cast(t, exp) ((t)(exp))
|
||||
|
||||
#define cast_void(i) cast(void, (i))
|
||||
#define cast_byte(i) cast(lu_byte, (i))
|
||||
#define cast_num(i) cast(lua_Number, (i))
|
||||
#define cast_int(i) cast(int, (i))
|
||||
|
6
lvm.c
6
lvm.c
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** $Id: lvm.c,v 2.186 2014/02/05 19:14:53 roberto Exp roberto $
|
||||
** $Id: lvm.c,v 2.187 2014/03/06 16:15:18 roberto Exp roberto $
|
||||
** Lua virtual machine
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
@ -222,7 +222,7 @@ int luaV_equalobj (lua_State *L, const TValue *t1, const TValue *t2) {
|
||||
else { /* two numbers with different variants */
|
||||
lua_Number n1, n2;
|
||||
lua_assert(ttisnumber(t1) && ttisnumber(t2));
|
||||
(void)tonumber(t1, &n1); (void)tonumber(t2, &n2);
|
||||
cast_void(tonumber(t1, &n1)); cast_void(tonumber(t2, &n2));
|
||||
return luai_numeq(n1, n2);
|
||||
}
|
||||
}
|
||||
@ -265,7 +265,7 @@ void luaV_concat (lua_State *L, int total) {
|
||||
if (!(ttisstring(top-2) || ttisnumber(top-2)) || !tostring(L, top-1))
|
||||
luaT_trybinTM(L, top-2, top-1, top-2, TM_CONCAT);
|
||||
else if (tsvalue(top-1)->len == 0) /* second operand is empty? */
|
||||
(void)tostring(L, top - 2); /* result is first operand */
|
||||
cast_void(tostring(L, top - 2)); /* result is first operand */
|
||||
else if (ttisstring(top-2) && tsvalue(top-2)->len == 0) {
|
||||
setobjs2s(L, top - 2, top - 1); /* result is second op. */
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user