keep `top' in registers when running basic tasks (settable, getglobal, ...)
This commit is contained in:
14
lapi.c
14
lapi.c
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
** $Id: lapi.c,v 1.68 2000/01/13 15:56:03 roberto Exp roberto $
|
||||
** $Id: lapi.c,v 1.69 2000/01/19 12:00:45 roberto Exp roberto $
|
||||
** Lua API
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
@@ -123,7 +123,7 @@ lua_Object lua_seterrormethod (lua_State *L) {
|
||||
|
||||
lua_Object lua_gettable (lua_State *L) {
|
||||
luaA_checkCparams(L, 2);
|
||||
luaV_gettable(L);
|
||||
luaV_gettable(L, L->top--);
|
||||
return luaA_putObjectOnTop(L);
|
||||
}
|
||||
|
||||
@@ -139,10 +139,12 @@ lua_Object lua_rawgettable (lua_State *L) {
|
||||
|
||||
|
||||
void lua_settable (lua_State *L) {
|
||||
StkId top;
|
||||
luaA_checkCparams(L, 3);
|
||||
luaD_checkstack(L, 3); /* may need that to call a tag method */
|
||||
luaV_settable(L, L->top-3);
|
||||
L->top -= 2; /* pop table and index */
|
||||
top = L->top;
|
||||
luaV_settable(L, top-3, top);
|
||||
L->top = top-3; /* pop table, index, and value */
|
||||
}
|
||||
|
||||
|
||||
@@ -163,7 +165,7 @@ lua_Object lua_createtable (lua_State *L) {
|
||||
|
||||
lua_Object lua_getglobal (lua_State *L, const char *name) {
|
||||
luaD_checkstack(L, 3); /* may need that to call a tag method */
|
||||
luaV_getglobal(L, luaS_assertglobalbyname(L, name));
|
||||
luaV_getglobal(L, luaS_assertglobalbyname(L, name), L->top++);
|
||||
return luaA_putObjectOnTop(L);
|
||||
}
|
||||
|
||||
@@ -177,7 +179,7 @@ lua_Object lua_rawgetglobal (lua_State *L, const char *name) {
|
||||
void lua_setglobal (lua_State *L, const char *name) {
|
||||
luaA_checkCparams(L, 1);
|
||||
luaD_checkstack(L, 3); /* may need that to call a tag method */
|
||||
luaV_setglobal(L, luaS_assertglobalbyname(L, name));
|
||||
luaV_setglobal(L, luaS_assertglobalbyname(L, name), L->top--);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user