diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2000-09-18 16:39:26 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2000-09-18 16:39:26 -0300 |
commit | 6030d5fed4e754eec9b891aa09d37e15d5ae2562 (patch) | |
tree | 3d9faead002ebd45a57df0b95800655c15b35eb3 /lapi.c | |
parent | 91c003dcc2d84094a1098151c343071b19949910 (diff) | |
download | lua-6030d5fed4e754eec9b891aa09d37e15d5ae2562.tar.gz lua-6030d5fed4e754eec9b891aa09d37e15d5ae2562.tar.bz2 lua-6030d5fed4e754eec9b891aa09d37e15d5ae2562.zip |
avoid assignment to local structure
Diffstat (limited to 'lapi.c')
-rw-r--r-- | lapi.c | 27 |
1 files changed, 13 insertions, 14 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lapi.c,v 1.97 2000/09/12 13:47:46 roberto Exp $ | 2 | ** $Id: lapi.c,v 1.98 2000/09/14 14:09:31 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 | */ |
@@ -76,12 +76,11 @@ void lua_remove (lua_State *L, int index) { | |||
76 | 76 | ||
77 | 77 | ||
78 | void lua_insert (lua_State *L, int index) { | 78 | void lua_insert (lua_State *L, int index) { |
79 | TObject temp = *(L->top-1); | ||
80 | StkId p = Index(L, index); | 79 | StkId p = Index(L, index); |
81 | StkId q; | 80 | StkId q; |
82 | for (q = L->top-1; q>p; q--) | 81 | for (q = L->top; q>p; q--) |
83 | *q = *(q-1); | 82 | *q = *(q-1); |
84 | *p = temp; | 83 | *p = *L->top; |
85 | } | 84 | } |
86 | 85 | ||
87 | 86 | ||
@@ -249,16 +248,16 @@ void lua_getglobal (lua_State *L, const char *name) { | |||
249 | } | 248 | } |
250 | 249 | ||
251 | 250 | ||
252 | void lua_gettable (lua_State *L, int tableindex) { | 251 | void lua_gettable (lua_State *L, int index) { |
253 | StkId t = Index(L, tableindex); | 252 | StkId t = Index(L, index); |
254 | StkId top = L->top; | 253 | StkId top = L->top; |
255 | *(top-1) = *luaV_gettable(L, t); | 254 | *(top-1) = *luaV_gettable(L, t); |
256 | L->top = top; /* tag method may change top */ | 255 | L->top = top; /* tag method may change top */ |
257 | } | 256 | } |
258 | 257 | ||
259 | 258 | ||
260 | void lua_rawget (lua_State *L, int tableindex) { | 259 | void lua_rawget (lua_State *L, int index) { |
261 | StkId t = Index(L, tableindex); | 260 | StkId t = Index(L, index); |
262 | LUA_ASSERT(ttype(t) == TAG_TABLE, "table expected"); | 261 | LUA_ASSERT(ttype(t) == TAG_TABLE, "table expected"); |
263 | *(L->top - 1) = *luaH_get(L, hvalue(t), L->top - 1); | 262 | *(L->top - 1) = *luaH_get(L, hvalue(t), L->top - 1); |
264 | } | 263 | } |
@@ -313,16 +312,16 @@ void lua_setglobal (lua_State *L, const char *name) { | |||
313 | } | 312 | } |
314 | 313 | ||
315 | 314 | ||
316 | void lua_settable (lua_State *L, int tableindex) { | 315 | void lua_settable (lua_State *L, int index) { |
317 | StkId t = Index(L, tableindex); | 316 | StkId t = Index(L, index); |
318 | StkId top = L->top; | 317 | StkId top = L->top; |
319 | luaV_settable(L, t, top-2); | 318 | luaV_settable(L, t, top-2); |
320 | L->top = top-2; /* pop index and value */ | 319 | L->top = top-2; /* pop index and value */ |
321 | } | 320 | } |
322 | 321 | ||
323 | 322 | ||
324 | void lua_rawset (lua_State *L, int tableindex) { | 323 | void lua_rawset (lua_State *L, int index) { |
325 | StkId t = Index(L, tableindex); | 324 | StkId t = Index(L, index); |
326 | LUA_ASSERT(ttype(t) == TAG_TABLE, "table expected"); | 325 | LUA_ASSERT(ttype(t) == TAG_TABLE, "table expected"); |
327 | *luaH_set(L, hvalue(t), L->top-2) = *(L->top-1); | 326 | *luaH_set(L, hvalue(t), L->top-2) = *(L->top-1); |
328 | L->top -= 2; | 327 | L->top -= 2; |
@@ -406,8 +405,8 @@ void lua_unref (lua_State *L, int ref) { | |||
406 | } | 405 | } |
407 | 406 | ||
408 | 407 | ||
409 | int lua_next (lua_State *L, int tableindex) { | 408 | int lua_next (lua_State *L, int index) { |
410 | StkId t = Index(L, tableindex); | 409 | StkId t = Index(L, index); |
411 | Node *n; | 410 | Node *n; |
412 | LUA_ASSERT(ttype(t) == TAG_TABLE, "table expected"); | 411 | LUA_ASSERT(ttype(t) == TAG_TABLE, "table expected"); |
413 | n = luaH_next(L, hvalue(t), Index(L, -1)); | 412 | n = luaH_next(L, hvalue(t), Index(L, -1)); |