diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2002-11-07 13:37:10 -0200 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2002-11-07 13:37:10 -0200 |
| commit | dff9be4224a1cd0f338b544b9e01d42f0f4e537f (patch) | |
| tree | 1dc8846da882dd37d9f420c10ea545ce92fb3b8a /lapi.c | |
| parent | 118347d8c3b83ea0291918e81c5367937316fabb (diff) | |
| download | lua-dff9be4224a1cd0f338b544b9e01d42f0f4e537f.tar.gz lua-dff9be4224a1cd0f338b544b9e01d42f0f4e537f.tar.bz2 lua-dff9be4224a1cd0f338b544b9e01d42f0f4e537f.zip | |
new macros to distinguish different types of object moves (for future GC
evolution).
Diffstat (limited to 'lapi.c')
| -rw-r--r-- | lapi.c | 36 |
1 files changed, 17 insertions, 19 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lapi.c,v 1.215 2002/10/25 21:31:28 roberto Exp roberto $ | 2 | ** $Id: lapi.c,v 1.216 2002/11/06 19:08:00 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 | */ |
| @@ -84,7 +84,7 @@ static TObject *luaA_indexAcceptable (lua_State *L, int index) { | |||
| 84 | 84 | ||
| 85 | 85 | ||
| 86 | void luaA_pushobject (lua_State *L, const TObject *o) { | 86 | void luaA_pushobject (lua_State *L, const TObject *o) { |
| 87 | setobj(L->top, o); | 87 | setobj2s(L->top, o); |
| 88 | incr_top(L); | 88 | incr_top(L); |
| 89 | } | 89 | } |
| 90 | 90 | ||
| @@ -111,7 +111,7 @@ LUA_API void lua_movethread (lua_State *from, lua_State *to, int n) { | |||
| 111 | api_checknelems(from, n); | 111 | api_checknelems(from, n); |
| 112 | from->top -= n; | 112 | from->top -= n; |
| 113 | for (i = 0; i < n; i++) { | 113 | for (i = 0; i < n; i++) { |
| 114 | setobj(to->top, from->top + i); | 114 | setobj2s(to->top, from->top + i); |
| 115 | api_incr_top(to); | 115 | api_incr_top(to); |
| 116 | } | 116 | } |
| 117 | lua_unlock(to); | 117 | lua_unlock(to); |
| @@ -171,7 +171,7 @@ LUA_API void lua_remove (lua_State *L, int index) { | |||
| 171 | StkId p; | 171 | StkId p; |
| 172 | lua_lock(L); | 172 | lua_lock(L); |
| 173 | p = luaA_index(L, index); | 173 | p = luaA_index(L, index); |
| 174 | while (++p < L->top) setobj(p-1, p); | 174 | while (++p < L->top) setobjs2s(p-1, p); |
| 175 | L->top--; | 175 | L->top--; |
| 176 | lua_unlock(L); | 176 | lua_unlock(L); |
| 177 | } | 177 | } |
| @@ -182,8 +182,8 @@ LUA_API void lua_insert (lua_State *L, int index) { | |||
| 182 | StkId q; | 182 | StkId q; |
| 183 | lua_lock(L); | 183 | lua_lock(L); |
| 184 | p = luaA_index(L, index); | 184 | p = luaA_index(L, index); |
| 185 | for (q = L->top; q>p; q--) setobj(q, q-1); | 185 | for (q = L->top; q>p; q--) setobjs2s(q, q-1); |
| 186 | setobj(p, L->top); | 186 | setobjs2s(p, L->top); |
| 187 | lua_unlock(L); | 187 | lua_unlock(L); |
| 188 | } | 188 | } |
| 189 | 189 | ||
| @@ -191,7 +191,7 @@ LUA_API void lua_insert (lua_State *L, int index) { | |||
| 191 | LUA_API void lua_replace (lua_State *L, int index) { | 191 | LUA_API void lua_replace (lua_State *L, int index) { |
| 192 | lua_lock(L); | 192 | lua_lock(L); |
| 193 | api_checknelems(L, 1); | 193 | api_checknelems(L, 1); |
| 194 | setobj(luaA_index(L, index), L->top - 1); | 194 | setobj(luaA_index(L, index), L->top - 1); /* unknown destination */ |
| 195 | L->top--; | 195 | L->top--; |
| 196 | lua_unlock(L); | 196 | lua_unlock(L); |
| 197 | } | 197 | } |
| @@ -199,7 +199,7 @@ LUA_API void lua_replace (lua_State *L, int index) { | |||
| 199 | 199 | ||
| 200 | LUA_API void lua_pushvalue (lua_State *L, int index) { | 200 | LUA_API void lua_pushvalue (lua_State *L, int index) { |
| 201 | lua_lock(L); | 201 | lua_lock(L); |
| 202 | setobj(L->top, luaA_index(L, index)); | 202 | setobj2s(L->top, luaA_index(L, index)); |
| 203 | api_incr_top(L); | 203 | api_incr_top(L); |
| 204 | lua_unlock(L); | 204 | lua_unlock(L); |
| 205 | } | 205 | } |
| @@ -394,7 +394,7 @@ LUA_API void lua_pushnumber (lua_State *L, lua_Number n) { | |||
| 394 | 394 | ||
| 395 | LUA_API void lua_pushlstring (lua_State *L, const char *s, size_t len) { | 395 | LUA_API void lua_pushlstring (lua_State *L, const char *s, size_t len) { |
| 396 | lua_lock(L); | 396 | lua_lock(L); |
| 397 | setsvalue(L->top, luaS_newlstr(L, s, len)); | 397 | setsvalue2s(L->top, luaS_newlstr(L, s, len)); |
| 398 | api_incr_top(L); | 398 | api_incr_top(L); |
| 399 | lua_unlock(L); | 399 | lua_unlock(L); |
| 400 | } | 400 | } |
| @@ -469,11 +469,9 @@ LUA_API void lua_pushlightuserdata (lua_State *L, void *p) { | |||
| 469 | 469 | ||
| 470 | LUA_API void lua_gettable (lua_State *L, int index) { | 470 | LUA_API void lua_gettable (lua_State *L, int index) { |
| 471 | StkId t; | 471 | StkId t; |
| 472 | const TObject *v; | ||
| 473 | lua_lock(L); | 472 | lua_lock(L); |
| 474 | t = luaA_index(L, index); | 473 | t = luaA_index(L, index); |
| 475 | v = luaV_gettable(L, t, L->top-1, 0); | 474 | setobj2s(L->top - 1, luaV_gettable(L, t, L->top - 1, 0)); |
| 476 | setobj(L->top - 1, v); | ||
| 477 | lua_unlock(L); | 475 | lua_unlock(L); |
| 478 | } | 476 | } |
| 479 | 477 | ||
| @@ -483,7 +481,7 @@ LUA_API void lua_rawget (lua_State *L, int index) { | |||
| 483 | lua_lock(L); | 481 | lua_lock(L); |
| 484 | t = luaA_index(L, index); | 482 | t = luaA_index(L, index); |
| 485 | api_check(L, ttistable(t)); | 483 | api_check(L, ttistable(t)); |
| 486 | setobj(L->top - 1, luaH_get(hvalue(t), L->top - 1)); | 484 | setobj2s(L->top - 1, luaH_get(hvalue(t), L->top - 1)); |
| 487 | lua_unlock(L); | 485 | lua_unlock(L); |
| 488 | } | 486 | } |
| 489 | 487 | ||
| @@ -493,7 +491,7 @@ LUA_API void lua_rawgeti (lua_State *L, int index, int n) { | |||
| 493 | lua_lock(L); | 491 | lua_lock(L); |
| 494 | o = luaA_index(L, index); | 492 | o = luaA_index(L, index); |
| 495 | api_check(L, ttistable(o)); | 493 | api_check(L, ttistable(o)); |
| 496 | setobj(L->top, luaH_getnum(hvalue(o), n)); | 494 | setobj2s(L->top, luaH_getnum(hvalue(o), n)); |
| 497 | api_incr_top(L); | 495 | api_incr_top(L); |
| 498 | lua_unlock(L); | 496 | lua_unlock(L); |
| 499 | } | 497 | } |
| @@ -553,7 +551,7 @@ LUA_API void lua_getglobals (lua_State *L, int index) { | |||
| 553 | StkId o; | 551 | StkId o; |
| 554 | lua_lock(L); | 552 | lua_lock(L); |
| 555 | o = luaA_index(L, index); | 553 | o = luaA_index(L, index); |
| 556 | setobj(L->top, isLfunction(o) ? &clvalue(o)->l.g : gt(L)); | 554 | setobj2s(L->top, isLfunction(o) ? &clvalue(o)->l.g : gt(L)); |
| 557 | api_incr_top(L); | 555 | api_incr_top(L); |
| 558 | lua_unlock(L); | 556 | lua_unlock(L); |
| 559 | } | 557 | } |
| @@ -581,7 +579,7 @@ LUA_API void lua_rawset (lua_State *L, int index) { | |||
| 581 | api_checknelems(L, 2); | 579 | api_checknelems(L, 2); |
| 582 | t = luaA_index(L, index); | 580 | t = luaA_index(L, index); |
| 583 | api_check(L, ttistable(t)); | 581 | api_check(L, ttistable(t)); |
| 584 | setobj(luaH_set(L, hvalue(t), L->top-2), L->top-1); | 582 | setobj2t(luaH_set(L, hvalue(t), L->top-2), L->top-1); |
| 585 | L->top -= 2; | 583 | L->top -= 2; |
| 586 | lua_unlock(L); | 584 | lua_unlock(L); |
| 587 | } | 585 | } |
| @@ -593,7 +591,7 @@ LUA_API void lua_rawseti (lua_State *L, int index, int n) { | |||
| 593 | api_checknelems(L, 1); | 591 | api_checknelems(L, 1); |
| 594 | o = luaA_index(L, index); | 592 | o = luaA_index(L, index); |
| 595 | api_check(L, ttistable(o)); | 593 | api_check(L, ttistable(o)); |
| 596 | setobj(luaH_setnum(L, hvalue(o), n), L->top-1); | 594 | setobj2t(luaH_setnum(L, hvalue(o), n), L->top-1); |
| 597 | L->top--; | 595 | L->top--; |
| 598 | lua_unlock(L); | 596 | lua_unlock(L); |
| 599 | } | 597 | } |
| @@ -787,7 +785,7 @@ LUA_API void lua_concat (lua_State *L, int n) { | |||
| 787 | luaC_checkGC(L); | 785 | luaC_checkGC(L); |
| 788 | } | 786 | } |
| 789 | else if (n == 0) { /* push empty string */ | 787 | else if (n == 0) { /* push empty string */ |
| 790 | setsvalue(L->top, luaS_newlstr(L, NULL, 0)); | 788 | setsvalue2s(L->top, luaS_newlstr(L, NULL, 0)); |
| 791 | api_incr_top(L); | 789 | api_incr_top(L); |
| 792 | } | 790 | } |
| 793 | /* else n == 1; nothing to do */ | 791 | /* else n == 1; nothing to do */ |
| @@ -815,7 +813,7 @@ LUA_API int lua_pushupvalues (lua_State *L) { | |||
| 815 | n = func->c.nupvalues; | 813 | n = func->c.nupvalues; |
| 816 | luaD_checkstack(L, n + LUA_MINSTACK); | 814 | luaD_checkstack(L, n + LUA_MINSTACK); |
| 817 | for (i=0; i<n; i++) { | 815 | for (i=0; i<n; i++) { |
| 818 | setobj(L->top, &func->c.upvalue[i]); | 816 | setobj2s(L->top, &func->c.upvalue[i]); |
| 819 | L->top++; | 817 | L->top++; |
| 820 | } | 818 | } |
| 821 | lua_unlock(L); | 819 | lua_unlock(L); |
