diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2001-06-08 16:01:38 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2001-06-08 16:01:38 -0300 |
commit | cbc59592ff684b646b21766a66630df1f7974b25 (patch) | |
tree | 1e28529cda3b8f6baa63285f6a2571767c3ed05e /lapi.c | |
parent | 4905fdd1350bde68cd818b9198f28f5a47c208b0 (diff) | |
download | lua-cbc59592ff684b646b21766a66630df1f7974b25.tar.gz lua-cbc59592ff684b646b21766a66630df1f7974b25.tar.bz2 lua-cbc59592ff684b646b21766a66630df1f7974b25.zip |
new definition for `luaD_call' and `luaD_adjusttop'
Diffstat (limited to 'lapi.c')
-rw-r--r-- | lapi.c | 16 |
1 files changed, 11 insertions, 5 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lapi.c,v 1.142 2001/06/05 18:17:01 roberto Exp roberto $ | 2 | ** $Id: lapi.c,v 1.143 2001/06/06 18:00:19 roberto Exp roberto $ |
3 | ** Lua API | 3 | ** Lua API |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -95,11 +95,13 @@ LUA_API int lua_gettop (lua_State *L) { | |||
95 | 95 | ||
96 | LUA_API void lua_settop (lua_State *L, int index) { | 96 | LUA_API void lua_settop (lua_State *L, int index) { |
97 | lua_lock(L); | 97 | lua_lock(L); |
98 | if (index >= 0) | 98 | if (index >= 0) { |
99 | luaD_adjusttop(L, L->ci->base, index); | 99 | api_check(L, index <= L->stack_last - L->ci->base); |
100 | luaD_adjusttop(L, L->ci->base+index); | ||
101 | } | ||
100 | else { | 102 | else { |
101 | api_check(L, -(index+1) <= (L->top - L->ci->base)); | 103 | api_check(L, -(index+1) <= (L->top - L->ci->base)); |
102 | L->top = L->top+index+1; /* index is negative */ | 104 | L->top += index+1; /* `subtract' index (index is negative) */ |
103 | } | 105 | } |
104 | lua_unlock(L); | 106 | lua_unlock(L); |
105 | } | 107 | } |
@@ -545,9 +547,13 @@ LUA_API int lua_ref (lua_State *L, int lock) { | |||
545 | */ | 547 | */ |
546 | 548 | ||
547 | LUA_API void lua_rawcall (lua_State *L, int nargs, int nresults) { | 549 | LUA_API void lua_rawcall (lua_State *L, int nargs, int nresults) { |
550 | StkId func; | ||
548 | lua_lock(L); | 551 | lua_lock(L); |
549 | api_checknelems(L, nargs+1); | 552 | api_checknelems(L, nargs+1); |
550 | luaD_call(L, L->top-(nargs+1), nresults); | 553 | func = L->top - (nargs+1); |
554 | luaD_call(L, func); | ||
555 | if (nresults != LUA_MULTRET) | ||
556 | luaD_adjusttop(L, func + nresults); | ||
551 | lua_unlock(L); | 557 | lua_unlock(L); |
552 | } | 558 | } |
553 | 559 | ||