diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2000-01-24 18:14:07 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2000-01-24 18:14:07 -0200 |
commit | 99e340b2ba08226f4f7b457b170296af8d82959b (patch) | |
tree | 2b243fb8723b046c47c4b4f4de9175c94bc98dd2 /lapi.c | |
parent | 9744255ae929d11661ae622201a6d627b6403088 (diff) | |
download | lua-99e340b2ba08226f4f7b457b170296af8d82959b.tar.gz lua-99e340b2ba08226f4f7b457b170296af8d82959b.tar.bz2 lua-99e340b2ba08226f4f7b457b170296af8d82959b.zip |
keep `top' in registers when running basic tasks (settable, getglobal, ...)
Diffstat (limited to 'lapi.c')
-rw-r--r-- | lapi.c | 14 |
1 files changed, 8 insertions, 6 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lapi.c,v 1.68 2000/01/13 15:56:03 roberto Exp roberto $ | 2 | ** $Id: lapi.c,v 1.69 2000/01/19 12:00:45 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 | */ |
@@ -123,7 +123,7 @@ lua_Object lua_seterrormethod (lua_State *L) { | |||
123 | 123 | ||
124 | lua_Object lua_gettable (lua_State *L) { | 124 | lua_Object lua_gettable (lua_State *L) { |
125 | luaA_checkCparams(L, 2); | 125 | luaA_checkCparams(L, 2); |
126 | luaV_gettable(L); | 126 | luaV_gettable(L, L->top--); |
127 | return luaA_putObjectOnTop(L); | 127 | return luaA_putObjectOnTop(L); |
128 | } | 128 | } |
129 | 129 | ||
@@ -139,10 +139,12 @@ lua_Object lua_rawgettable (lua_State *L) { | |||
139 | 139 | ||
140 | 140 | ||
141 | void lua_settable (lua_State *L) { | 141 | void lua_settable (lua_State *L) { |
142 | StkId top; | ||
142 | luaA_checkCparams(L, 3); | 143 | luaA_checkCparams(L, 3); |
143 | luaD_checkstack(L, 3); /* may need that to call a tag method */ | 144 | luaD_checkstack(L, 3); /* may need that to call a tag method */ |
144 | luaV_settable(L, L->top-3); | 145 | top = L->top; |
145 | L->top -= 2; /* pop table and index */ | 146 | luaV_settable(L, top-3, top); |
147 | L->top = top-3; /* pop table, index, and value */ | ||
146 | } | 148 | } |
147 | 149 | ||
148 | 150 | ||
@@ -163,7 +165,7 @@ lua_Object lua_createtable (lua_State *L) { | |||
163 | 165 | ||
164 | lua_Object lua_getglobal (lua_State *L, const char *name) { | 166 | lua_Object lua_getglobal (lua_State *L, const char *name) { |
165 | luaD_checkstack(L, 3); /* may need that to call a tag method */ | 167 | luaD_checkstack(L, 3); /* may need that to call a tag method */ |
166 | luaV_getglobal(L, luaS_assertglobalbyname(L, name)); | 168 | luaV_getglobal(L, luaS_assertglobalbyname(L, name), L->top++); |
167 | return luaA_putObjectOnTop(L); | 169 | return luaA_putObjectOnTop(L); |
168 | } | 170 | } |
169 | 171 | ||
@@ -177,7 +179,7 @@ lua_Object lua_rawgetglobal (lua_State *L, const char *name) { | |||
177 | void lua_setglobal (lua_State *L, const char *name) { | 179 | void lua_setglobal (lua_State *L, const char *name) { |
178 | luaA_checkCparams(L, 1); | 180 | luaA_checkCparams(L, 1); |
179 | luaD_checkstack(L, 3); /* may need that to call a tag method */ | 181 | luaD_checkstack(L, 3); /* may need that to call a tag method */ |
180 | luaV_setglobal(L, luaS_assertglobalbyname(L, name)); | 182 | luaV_setglobal(L, luaS_assertglobalbyname(L, name), L->top--); |
181 | } | 183 | } |
182 | 184 | ||
183 | 185 | ||