new macros 'chgfltvalue'/'chgivalue' (numerical for loop does
not need to set the type of its internal variable at each iteration)
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: lobject.h,v 2.106 2015/01/05 13:52:37 roberto Exp roberto $
|
** $Id: lobject.h,v 2.107 2015/01/16 16:54:37 roberto Exp roberto $
|
||||||
** Type definitions for Lua objects
|
** Type definitions for Lua objects
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@@ -190,9 +190,15 @@ typedef struct lua_TValue TValue;
|
|||||||
#define setfltvalue(obj,x) \
|
#define setfltvalue(obj,x) \
|
||||||
{ TValue *io=(obj); val_(io).n=(x); settt_(io, LUA_TNUMFLT); }
|
{ TValue *io=(obj); val_(io).n=(x); settt_(io, LUA_TNUMFLT); }
|
||||||
|
|
||||||
|
#define chgfltvalue(obj,x) \
|
||||||
|
{ TValue *io=(obj); lua_assert(ttisfloat(io)); val_(io).n=(x); }
|
||||||
|
|
||||||
#define setivalue(obj,x) \
|
#define setivalue(obj,x) \
|
||||||
{ TValue *io=(obj); val_(io).i=(x); settt_(io, LUA_TNUMINT); }
|
{ TValue *io=(obj); val_(io).i=(x); settt_(io, LUA_TNUMINT); }
|
||||||
|
|
||||||
|
#define chgivalue(obj,x) \
|
||||||
|
{ TValue *io=(obj); lua_assert(ttisinteger(io)); val_(io).i=(x); }
|
||||||
|
|
||||||
#define setnilvalue(obj) settt_(obj, LUA_TNIL)
|
#define setnilvalue(obj) settt_(obj, LUA_TNIL)
|
||||||
|
|
||||||
#define setfvalue(obj,x) \
|
#define setfvalue(obj,x) \
|
||||||
|
|||||||
6
lvm.c
6
lvm.c
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: lvm.c,v 2.234 2015/02/05 17:15:33 roberto Exp roberto $
|
** $Id: lvm.c,v 2.235 2015/02/20 14:27:53 roberto Exp roberto $
|
||||||
** Lua virtual machine
|
** Lua virtual machine
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@@ -1040,7 +1040,7 @@ void luaV_execute (lua_State *L) {
|
|||||||
lua_Integer limit = ivalue(ra + 1);
|
lua_Integer limit = ivalue(ra + 1);
|
||||||
if ((0 < step) ? (idx <= limit) : (limit <= idx)) {
|
if ((0 < step) ? (idx <= limit) : (limit <= idx)) {
|
||||||
ci->u.l.savedpc += GETARG_sBx(i); /* jump back */
|
ci->u.l.savedpc += GETARG_sBx(i); /* jump back */
|
||||||
setivalue(ra, idx); /* update internal index... */
|
chgivalue(ra, idx); /* update internal index... */
|
||||||
setivalue(ra + 3, idx); /* ...and external index */
|
setivalue(ra + 3, idx); /* ...and external index */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1051,7 +1051,7 @@ void luaV_execute (lua_State *L) {
|
|||||||
if (luai_numlt(0, step) ? luai_numle(idx, limit)
|
if (luai_numlt(0, step) ? luai_numle(idx, limit)
|
||||||
: luai_numle(limit, idx)) {
|
: luai_numle(limit, idx)) {
|
||||||
ci->u.l.savedpc += GETARG_sBx(i); /* jump back */
|
ci->u.l.savedpc += GETARG_sBx(i); /* jump back */
|
||||||
setfltvalue(ra, idx); /* update internal index... */
|
chgfltvalue(ra, idx); /* update internal index... */
|
||||||
setfltvalue(ra + 3, idx); /* ...and external index */
|
setfltvalue(ra + 3, idx); /* ...and external index */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user