aboutsummaryrefslogtreecommitdiff
path: root/lapi.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2001-02-01 14:03:38 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2001-02-01 14:03:38 -0200
commit4ab6acacdfdb5d5d29ed4d089aeda3ec6d82670b (patch)
tree86b28ac2c82f1d69a29ec8c842e6b559ad2b9923 /lapi.c
parent68587639945aa68844871fdd74a6729b653f523a (diff)
downloadlua-4ab6acacdfdb5d5d29ed4d089aeda3ec6d82670b.tar.gz
lua-4ab6acacdfdb5d5d29ed4d089aeda3ec6d82670b.tar.bz2
lua-4ab6acacdfdb5d5d29ed4d089aeda3ec6d82670b.zip
better control of relationship top x L->top
Diffstat (limited to 'lapi.c')
-rw-r--r--lapi.c26
1 files changed, 9 insertions, 17 deletions
diff --git a/lapi.c b/lapi.c
index bf66e3e9..7a4b3d44 100644
--- a/lapi.c
+++ b/lapi.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lapi.c,v 1.122 2001/01/29 17:16:58 roberto Exp roberto $ 2** $Id: lapi.c,v 1.123 2001/02/01 13:56:49 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*/
@@ -353,23 +353,18 @@ LUA_API void lua_pushusertag (lua_State *L, void *u, int tag) {
353 353
354 354
355LUA_API void lua_getglobal (lua_State *L, const char *name) { 355LUA_API void lua_getglobal (lua_State *L, const char *name) {
356 StkId top;
357 LUA_LOCK; 356 LUA_LOCK;
358 top = L->top; 357 luaV_getglobal(L, luaS_new(L, name), L->top);
359 setobj(top, luaV_getglobal(L, luaS_new(L, name)));
360 L->top = top;
361 api_incr_top(L); 358 api_incr_top(L);
362 LUA_UNLOCK; 359 LUA_UNLOCK;
363} 360}
364 361
365 362
366LUA_API void lua_gettable (lua_State *L, int index) { 363LUA_API void lua_gettable (lua_State *L, int index) {
367 StkId t, top; 364 StkId t;
368 LUA_LOCK; 365 LUA_LOCK;
369 t = Index(L, index); 366 t = Index(L, index);
370 top = L->top; 367 luaV_gettable(L, t, L->top, L->top-1);
371 setobj(top-1, luaV_gettable(L, t));
372 L->top = top; /* tag method may change top */
373 LUA_UNLOCK; 368 LUA_UNLOCK;
374} 369}
375 370
@@ -437,22 +432,19 @@ LUA_API void lua_newtable (lua_State *L) {
437 432
438 433
439LUA_API void lua_setglobal (lua_State *L, const char *name) { 434LUA_API void lua_setglobal (lua_State *L, const char *name) {
440 StkId top;
441 LUA_LOCK; 435 LUA_LOCK;
442 top = L->top; 436 luaV_setglobal(L, luaS_new(L, name), L->top);
443 luaV_setglobal(L, luaS_new(L, name)); 437 L->top--; /* remove element from the top */
444 L->top = top-1; /* remove element from the top */
445 LUA_UNLOCK; 438 LUA_UNLOCK;
446} 439}
447 440
448 441
449LUA_API void lua_settable (lua_State *L, int index) { 442LUA_API void lua_settable (lua_State *L, int index) {
450 StkId t, top; 443 StkId t;
451 LUA_LOCK; 444 LUA_LOCK;
452 t = Index(L, index); 445 t = Index(L, index);
453 top = L->top; 446 luaV_settable(L, t, L->top - 2, L->top);
454 luaV_settable(L, t, top-2); 447 L->top -= 2; /* pop index and value */
455 L->top = top-2; /* pop index and value */
456 LUA_UNLOCK; 448 LUA_UNLOCK;
457} 449}
458 450