mirror of
https://github.com/lua/lua
synced 2024-12-24 03:16:50 +03:00
`inline' of tonumber
This commit is contained in:
parent
1a3f175640
commit
6b0c38c2e7
13
lvm.c
13
lvm.c
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** $Id: lvm.c,v 1.216 2002/02/14 21:46:43 roberto Exp roberto $
|
||||
** $Id: lvm.c,v 1.217 2002/03/04 15:40:04 roberto Exp roberto $
|
||||
** Lua virtual machine
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
@ -12,7 +12,6 @@
|
||||
|
||||
#include "lua.h"
|
||||
|
||||
#include "lapi.h"
|
||||
#include "ldebug.h"
|
||||
#include "ldo.h"
|
||||
#include "lfunc.h"
|
||||
@ -542,16 +541,18 @@ StkId luaV_execute (lua_State *L) {
|
||||
case OP_FORLOOP: {
|
||||
lua_Number step, index, limit;
|
||||
int j = GETARG_sBc(i);
|
||||
const TObject *plimit = ra+1;
|
||||
const TObject *pstep = ra+2;
|
||||
pc += j; /* jump back before tests (for error messages) */
|
||||
if (ttype(ra) != LUA_TNUMBER)
|
||||
luaD_error(L, "`for' initial value must be a number");
|
||||
if (luaV_tonumber(ra+1, ra+1) == NULL)
|
||||
if (!tonumber(plimit, ra+1))
|
||||
luaD_error(L, "`for' limit must be a number");
|
||||
if (luaV_tonumber(ra+2, ra+2) == NULL)
|
||||
if (!tonumber(pstep, ra+2))
|
||||
luaD_error(L, "`for' step must be a number");
|
||||
step = nvalue(ra+2);
|
||||
step = nvalue(pstep);
|
||||
index = nvalue(ra) + step; /* increment index */
|
||||
limit = nvalue(ra+1);
|
||||
limit = nvalue(plimit);
|
||||
if (step > 0 ? index <= limit : index >= limit)
|
||||
chgnvalue(ra, index); /* update index */
|
||||
else
|
||||
|
5
lvm.h
5
lvm.h
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** $Id: lvm.h,v 1.1 2001/11/29 22:14:34 rieru Exp rieru $
|
||||
** $Id: lvm.h,v 1.36 2002/02/07 17:24:05 roberto Exp roberto $
|
||||
** Lua virtual machine
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
@ -15,7 +15,8 @@
|
||||
|
||||
#define tostring(L,o) ((ttype(o) == LUA_TSTRING) || (luaV_tostring(L, o)))
|
||||
|
||||
#define tonumber(o,n) (((o) = luaV_tonumber(o,n)) != NULL)
|
||||
#define tonumber(o,n) (ttype(o) == LUA_TNUMBER || \
|
||||
(((o) = luaV_tonumber(o,n)) != NULL))
|
||||
|
||||
|
||||
const TObject *luaV_tonumber (const TObject *obj, TObject *n);
|
||||
|
Loading…
Reference in New Issue
Block a user