diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2002-03-04 18:33:09 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2002-03-04 18:33:09 -0300 |
commit | 6b0c38c2e7da04c6bb1eb670cf45cf430881c9f9 (patch) | |
tree | 2123732e7dc44945b7e8923da7b2ce4be8a5673b /lvm.c | |
parent | 1a3f175640251437e60ca9a29131e289be624a5b (diff) | |
download | lua-6b0c38c2e7da04c6bb1eb670cf45cf430881c9f9.tar.gz lua-6b0c38c2e7da04c6bb1eb670cf45cf430881c9f9.tar.bz2 lua-6b0c38c2e7da04c6bb1eb670cf45cf430881c9f9.zip |
`inline' of tonumber
Diffstat (limited to 'lvm.c')
-rw-r--r-- | lvm.c | 13 |
1 files changed, 7 insertions, 6 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lvm.c,v 1.216 2002/02/14 21:46:43 roberto Exp roberto $ | 2 | ** $Id: lvm.c,v 1.217 2002/03/04 15:40:04 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 | */ |
@@ -12,7 +12,6 @@ | |||
12 | 12 | ||
13 | #include "lua.h" | 13 | #include "lua.h" |
14 | 14 | ||
15 | #include "lapi.h" | ||
16 | #include "ldebug.h" | 15 | #include "ldebug.h" |
17 | #include "ldo.h" | 16 | #include "ldo.h" |
18 | #include "lfunc.h" | 17 | #include "lfunc.h" |
@@ -542,16 +541,18 @@ StkId luaV_execute (lua_State *L) { | |||
542 | case OP_FORLOOP: { | 541 | case OP_FORLOOP: { |
543 | lua_Number step, index, limit; | 542 | lua_Number step, index, limit; |
544 | int j = GETARG_sBc(i); | 543 | int j = GETARG_sBc(i); |
544 | const TObject *plimit = ra+1; | ||
545 | const TObject *pstep = ra+2; | ||
545 | pc += j; /* jump back before tests (for error messages) */ | 546 | pc += j; /* jump back before tests (for error messages) */ |
546 | if (ttype(ra) != LUA_TNUMBER) | 547 | if (ttype(ra) != LUA_TNUMBER) |
547 | luaD_error(L, "`for' initial value must be a number"); | 548 | luaD_error(L, "`for' initial value must be a number"); |
548 | if (luaV_tonumber(ra+1, ra+1) == NULL) | 549 | if (!tonumber(plimit, ra+1)) |
549 | luaD_error(L, "`for' limit must be a number"); | 550 | luaD_error(L, "`for' limit must be a number"); |
550 | if (luaV_tonumber(ra+2, ra+2) == NULL) | 551 | if (!tonumber(pstep, ra+2)) |
551 | luaD_error(L, "`for' step must be a number"); | 552 | luaD_error(L, "`for' step must be a number"); |
552 | step = nvalue(ra+2); | 553 | step = nvalue(pstep); |
553 | index = nvalue(ra) + step; /* increment index */ | 554 | index = nvalue(ra) + step; /* increment index */ |
554 | limit = nvalue(ra+1); | 555 | limit = nvalue(plimit); |
555 | if (step > 0 ? index <= limit : index >= limit) | 556 | if (step > 0 ? index <= limit : index >= limit) |
556 | chgnvalue(ra, index); /* update index */ | 557 | chgnvalue(ra, index); /* update index */ |
557 | else | 558 | else |