diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2003-02-27 09:33:07 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2003-02-27 09:33:07 -0300 |
| commit | e1a424e8a35738bf56ecdad01155fb45b3001660 (patch) | |
| tree | 34c232ea0cb15e410a161ee0f65bd9bdb73838d7 | |
| parent | 59ce42dbd5a2dd2dd8bfbbf3e856742a535afc5b (diff) | |
| download | lua-e1a424e8a35738bf56ecdad01155fb45b3001660.tar.gz lua-e1a424e8a35738bf56ecdad01155fb45b3001660.tar.bz2 lua-e1a424e8a35738bf56ecdad01155fb45b3001660.zip | |
avoid the identifier `index' (clashes with BSD `index' function)
| -rw-r--r-- | lapi.c | 158 | ||||
| -rw-r--r-- | lcode.c | 10 | ||||
| -rw-r--r-- | ltests.c | 18 | ||||
| -rw-r--r-- | lvm.c | 10 |
4 files changed, 98 insertions, 98 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lapi.c,v 1.230 2003/02/20 19:33:23 roberto Exp roberto $ | 2 | ** $Id: lapi.c,v 1.231 2003/02/24 16:54:20 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 | */ |
| @@ -45,43 +45,43 @@ const char lua_ident[] = | |||
| 45 | 45 | ||
| 46 | 46 | ||
| 47 | 47 | ||
| 48 | static TObject *negindex (lua_State *L, int index) { | 48 | static TObject *negindex (lua_State *L, int idx) { |
| 49 | if (index > LUA_REGISTRYINDEX) { | 49 | if (idx > LUA_REGISTRYINDEX) { |
| 50 | api_check(L, index != 0 && -index <= L->top - L->base); | 50 | api_check(L, idx != 0 && -idx <= L->top - L->base); |
| 51 | return L->top+index; | 51 | return L->top+idx; |
| 52 | } | 52 | } |
| 53 | else switch (index) { /* pseudo-indices */ | 53 | else switch (idx) { /* pseudo-indices */ |
| 54 | case LUA_REGISTRYINDEX: return registry(L); | 54 | case LUA_REGISTRYINDEX: return registry(L); |
| 55 | case LUA_GLOBALSINDEX: return gt(L); | 55 | case LUA_GLOBALSINDEX: return gt(L); |
| 56 | default: { | 56 | default: { |
| 57 | TObject *func = (L->base - 1); | 57 | TObject *func = (L->base - 1); |
| 58 | index = LUA_GLOBALSINDEX - index; | 58 | idx = LUA_GLOBALSINDEX - idx; |
| 59 | api_check(L, iscfunction(func) && index <= clvalue(func)->c.nupvalues); | 59 | api_check(L, iscfunction(func) && idx <= clvalue(func)->c.nupvalues); |
| 60 | return &clvalue(func)->c.upvalue[index-1]; | 60 | return &clvalue(func)->c.upvalue[idx-1]; |
| 61 | } | 61 | } |
| 62 | } | 62 | } |
| 63 | } | 63 | } |
| 64 | 64 | ||
| 65 | 65 | ||
| 66 | static TObject *luaA_index (lua_State *L, int index) { | 66 | static TObject *luaA_index (lua_State *L, int idx) { |
| 67 | if (index > 0) { | 67 | if (idx > 0) { |
| 68 | api_check(L, index <= L->top - L->base); | 68 | api_check(L, idx <= L->top - L->base); |
| 69 | return L->base + index - 1; | 69 | return L->base + idx - 1; |
| 70 | } | 70 | } |
| 71 | else | 71 | else |
| 72 | return negindex(L, index); | 72 | return negindex(L, idx); |
| 73 | } | 73 | } |
| 74 | 74 | ||
| 75 | 75 | ||
| 76 | static TObject *luaA_indexAcceptable (lua_State *L, int index) { | 76 | static TObject *luaA_indexAcceptable (lua_State *L, int idx) { |
| 77 | if (index > 0) { | 77 | if (idx > 0) { |
| 78 | TObject *o = L->base+(index-1); | 78 | TObject *o = L->base+(idx-1); |
| 79 | api_check(L, index <= L->stack_last - L->base); | 79 | api_check(L, idx <= L->stack_last - L->base); |
| 80 | if (o >= L->top) return NULL; | 80 | if (o >= L->top) return NULL; |
| 81 | else return o; | 81 | else return o; |
| 82 | } | 82 | } |
| 83 | else | 83 | else |
| 84 | return negindex(L, index); | 84 | return negindex(L, idx); |
| 85 | } | 85 | } |
| 86 | 86 | ||
| 87 | 87 | ||
| @@ -154,55 +154,55 @@ LUA_API int lua_gettop (lua_State *L) { | |||
| 154 | } | 154 | } |
| 155 | 155 | ||
| 156 | 156 | ||
| 157 | LUA_API void lua_settop (lua_State *L, int index) { | 157 | LUA_API void lua_settop (lua_State *L, int idx) { |
| 158 | lua_lock(L); | 158 | lua_lock(L); |
| 159 | if (index >= 0) { | 159 | if (idx >= 0) { |
| 160 | api_check(L, index <= L->stack_last - L->base); | 160 | api_check(L, idx <= L->stack_last - L->base); |
| 161 | while (L->top < L->base + index) | 161 | while (L->top < L->base + idx) |
| 162 | setnilvalue(L->top++); | 162 | setnilvalue(L->top++); |
| 163 | L->top = L->base + index; | 163 | L->top = L->base + idx; |
| 164 | } | 164 | } |
| 165 | else { | 165 | else { |
| 166 | api_check(L, -(index+1) <= (L->top - L->base)); | 166 | api_check(L, -(idx+1) <= (L->top - L->base)); |
| 167 | L->top += index+1; /* `subtract' index (index is negative) */ | 167 | L->top += idx+1; /* `subtract' index (index is negative) */ |
| 168 | } | 168 | } |
| 169 | lua_unlock(L); | 169 | lua_unlock(L); |
| 170 | } | 170 | } |
| 171 | 171 | ||
| 172 | 172 | ||
| 173 | LUA_API void lua_remove (lua_State *L, int index) { | 173 | LUA_API void lua_remove (lua_State *L, int idx) { |
| 174 | StkId p; | 174 | StkId p; |
| 175 | lua_lock(L); | 175 | lua_lock(L); |
| 176 | p = luaA_index(L, index); | 176 | p = luaA_index(L, idx); |
| 177 | while (++p < L->top) setobjs2s(p-1, p); | 177 | while (++p < L->top) setobjs2s(p-1, p); |
| 178 | L->top--; | 178 | L->top--; |
| 179 | lua_unlock(L); | 179 | lua_unlock(L); |
| 180 | } | 180 | } |
| 181 | 181 | ||
| 182 | 182 | ||
| 183 | LUA_API void lua_insert (lua_State *L, int index) { | 183 | LUA_API void lua_insert (lua_State *L, int idx) { |
| 184 | StkId p; | 184 | StkId p; |
| 185 | StkId q; | 185 | StkId q; |
| 186 | lua_lock(L); | 186 | lua_lock(L); |
| 187 | p = luaA_index(L, index); | 187 | p = luaA_index(L, idx); |
| 188 | for (q = L->top; q>p; q--) setobjs2s(q, q-1); | 188 | for (q = L->top; q>p; q--) setobjs2s(q, q-1); |
| 189 | setobjs2s(p, L->top); | 189 | setobjs2s(p, L->top); |
| 190 | lua_unlock(L); | 190 | lua_unlock(L); |
| 191 | } | 191 | } |
| 192 | 192 | ||
| 193 | 193 | ||
| 194 | LUA_API void lua_replace (lua_State *L, int index) { | 194 | LUA_API void lua_replace (lua_State *L, int idx) { |
| 195 | lua_lock(L); | 195 | lua_lock(L); |
| 196 | api_checknelems(L, 1); | 196 | api_checknelems(L, 1); |
| 197 | setobj(luaA_index(L, index), L->top - 1); /* write barrier */ | 197 | setobj(luaA_index(L, idx), L->top - 1); /* write barrier */ |
| 198 | L->top--; | 198 | L->top--; |
| 199 | lua_unlock(L); | 199 | lua_unlock(L); |
| 200 | } | 200 | } |
| 201 | 201 | ||
| 202 | 202 | ||
| 203 | LUA_API void lua_pushvalue (lua_State *L, int index) { | 203 | LUA_API void lua_pushvalue (lua_State *L, int idx) { |
| 204 | lua_lock(L); | 204 | lua_lock(L); |
| 205 | setobj2s(L->top, luaA_index(L, index)); | 205 | setobj2s(L->top, luaA_index(L, idx)); |
| 206 | api_incr_top(L); | 206 | api_incr_top(L); |
| 207 | lua_unlock(L); | 207 | lua_unlock(L); |
| 208 | } | 208 | } |
| @@ -214,8 +214,8 @@ LUA_API void lua_pushvalue (lua_State *L, int index) { | |||
| 214 | */ | 214 | */ |
| 215 | 215 | ||
| 216 | 216 | ||
| 217 | LUA_API int lua_type (lua_State *L, int index) { | 217 | LUA_API int lua_type (lua_State *L, int idx) { |
| 218 | StkId o = luaA_indexAcceptable(L, index); | 218 | StkId o = luaA_indexAcceptable(L, idx); |
| 219 | return (o == NULL) ? LUA_TNONE : ttype(o); | 219 | return (o == NULL) ? LUA_TNONE : ttype(o); |
| 220 | } | 220 | } |
| 221 | 221 | ||
| @@ -226,27 +226,27 @@ LUA_API const char *lua_typename (lua_State *L, int t) { | |||
| 226 | } | 226 | } |
| 227 | 227 | ||
| 228 | 228 | ||
| 229 | LUA_API int lua_iscfunction (lua_State *L, int index) { | 229 | LUA_API int lua_iscfunction (lua_State *L, int idx) { |
| 230 | StkId o = luaA_indexAcceptable(L, index); | 230 | StkId o = luaA_indexAcceptable(L, idx); |
| 231 | return (o == NULL) ? 0 : iscfunction(o); | 231 | return (o == NULL) ? 0 : iscfunction(o); |
| 232 | } | 232 | } |
| 233 | 233 | ||
| 234 | 234 | ||
| 235 | LUA_API int lua_isnumber (lua_State *L, int index) { | 235 | LUA_API int lua_isnumber (lua_State *L, int idx) { |
| 236 | TObject n; | 236 | TObject n; |
| 237 | const TObject *o = luaA_indexAcceptable(L, index); | 237 | const TObject *o = luaA_indexAcceptable(L, idx); |
| 238 | return (o != NULL && tonumber(o, &n)); | 238 | return (o != NULL && tonumber(o, &n)); |
| 239 | } | 239 | } |
| 240 | 240 | ||
| 241 | 241 | ||
| 242 | LUA_API int lua_isstring (lua_State *L, int index) { | 242 | LUA_API int lua_isstring (lua_State *L, int idx) { |
| 243 | int t = lua_type(L, index); | 243 | int t = lua_type(L, idx); |
| 244 | return (t == LUA_TSTRING || t == LUA_TNUMBER); | 244 | return (t == LUA_TSTRING || t == LUA_TNUMBER); |
| 245 | } | 245 | } |
| 246 | 246 | ||
| 247 | 247 | ||
| 248 | LUA_API int lua_isuserdata (lua_State *L, int index) { | 248 | LUA_API int lua_isuserdata (lua_State *L, int idx) { |
| 249 | const TObject *o = luaA_indexAcceptable(L, index); | 249 | const TObject *o = luaA_indexAcceptable(L, idx); |
| 250 | return (o != NULL && (ttisuserdata(o) || ttislightuserdata(o))); | 250 | return (o != NULL && (ttisuserdata(o) || ttislightuserdata(o))); |
| 251 | } | 251 | } |
| 252 | 252 | ||
| @@ -286,9 +286,9 @@ LUA_API int lua_lessthan (lua_State *L, int index1, int index2) { | |||
| 286 | 286 | ||
| 287 | 287 | ||
| 288 | 288 | ||
| 289 | LUA_API lua_Number lua_tonumber (lua_State *L, int index) { | 289 | LUA_API lua_Number lua_tonumber (lua_State *L, int idx) { |
| 290 | TObject n; | 290 | TObject n; |
| 291 | const TObject *o = luaA_indexAcceptable(L, index); | 291 | const TObject *o = luaA_indexAcceptable(L, idx); |
| 292 | if (o != NULL && tonumber(o, &n)) | 292 | if (o != NULL && tonumber(o, &n)) |
| 293 | return nvalue(o); | 293 | return nvalue(o); |
| 294 | else | 294 | else |
| @@ -296,14 +296,14 @@ LUA_API lua_Number lua_tonumber (lua_State *L, int index) { | |||
| 296 | } | 296 | } |
| 297 | 297 | ||
| 298 | 298 | ||
| 299 | LUA_API int lua_toboolean (lua_State *L, int index) { | 299 | LUA_API int lua_toboolean (lua_State *L, int idx) { |
| 300 | const TObject *o = luaA_indexAcceptable(L, index); | 300 | const TObject *o = luaA_indexAcceptable(L, idx); |
| 301 | return (o != NULL) && !l_isfalse(o); | 301 | return (o != NULL) && !l_isfalse(o); |
| 302 | } | 302 | } |
| 303 | 303 | ||
| 304 | 304 | ||
| 305 | LUA_API const char *lua_tostring (lua_State *L, int index) { | 305 | LUA_API const char *lua_tostring (lua_State *L, int idx) { |
| 306 | StkId o = luaA_indexAcceptable(L, index); | 306 | StkId o = luaA_indexAcceptable(L, idx); |
| 307 | if (o == NULL) | 307 | if (o == NULL) |
| 308 | return NULL; | 308 | return NULL; |
| 309 | else if (ttisstring(o)) | 309 | else if (ttisstring(o)) |
| @@ -319,8 +319,8 @@ LUA_API const char *lua_tostring (lua_State *L, int index) { | |||
| 319 | } | 319 | } |
| 320 | 320 | ||
| 321 | 321 | ||
| 322 | LUA_API size_t lua_strlen (lua_State *L, int index) { | 322 | LUA_API size_t lua_strlen (lua_State *L, int idx) { |
| 323 | StkId o = luaA_indexAcceptable(L, index); | 323 | StkId o = luaA_indexAcceptable(L, idx); |
| 324 | if (o == NULL) | 324 | if (o == NULL) |
| 325 | return 0; | 325 | return 0; |
| 326 | else if (ttisstring(o)) | 326 | else if (ttisstring(o)) |
| @@ -335,14 +335,14 @@ LUA_API size_t lua_strlen (lua_State *L, int index) { | |||
| 335 | } | 335 | } |
| 336 | 336 | ||
| 337 | 337 | ||
| 338 | LUA_API lua_CFunction lua_tocfunction (lua_State *L, int index) { | 338 | LUA_API lua_CFunction lua_tocfunction (lua_State *L, int idx) { |
| 339 | StkId o = luaA_indexAcceptable(L, index); | 339 | StkId o = luaA_indexAcceptable(L, idx); |
| 340 | return (o == NULL || !iscfunction(o)) ? NULL : clvalue(o)->c.f; | 340 | return (o == NULL || !iscfunction(o)) ? NULL : clvalue(o)->c.f; |
| 341 | } | 341 | } |
| 342 | 342 | ||
| 343 | 343 | ||
| 344 | LUA_API void *lua_touserdata (lua_State *L, int index) { | 344 | LUA_API void *lua_touserdata (lua_State *L, int idx) { |
| 345 | StkId o = luaA_indexAcceptable(L, index); | 345 | StkId o = luaA_indexAcceptable(L, idx); |
| 346 | if (o == NULL) return NULL; | 346 | if (o == NULL) return NULL; |
| 347 | switch (ttype(o)) { | 347 | switch (ttype(o)) { |
| 348 | case LUA_TUSERDATA: return (uvalue(o) + 1); | 348 | case LUA_TUSERDATA: return (uvalue(o) + 1); |
| @@ -352,14 +352,14 @@ LUA_API void *lua_touserdata (lua_State *L, int index) { | |||
| 352 | } | 352 | } |
| 353 | 353 | ||
| 354 | 354 | ||
| 355 | LUA_API lua_State *lua_tothread (lua_State *L, int index) { | 355 | LUA_API lua_State *lua_tothread (lua_State *L, int idx) { |
| 356 | StkId o = luaA_indexAcceptable(L, index); | 356 | StkId o = luaA_indexAcceptable(L, idx); |
| 357 | return (o == NULL || !ttisthread(o)) ? NULL : thvalue(o); | 357 | return (o == NULL || !ttisthread(o)) ? NULL : thvalue(o); |
| 358 | } | 358 | } |
| 359 | 359 | ||
| 360 | 360 | ||
| 361 | LUA_API const void *lua_topointer (lua_State *L, int index) { | 361 | LUA_API const void *lua_topointer (lua_State *L, int idx) { |
| 362 | StkId o = luaA_indexAcceptable(L, index); | 362 | StkId o = luaA_indexAcceptable(L, idx); |
| 363 | if (o == NULL) return NULL; | 363 | if (o == NULL) return NULL; |
| 364 | else { | 364 | else { |
| 365 | switch (ttype(o)) { | 365 | switch (ttype(o)) { |
| @@ -367,7 +367,7 @@ LUA_API const void *lua_topointer (lua_State *L, int index) { | |||
| 367 | case LUA_TFUNCTION: return clvalue(o); | 367 | case LUA_TFUNCTION: return clvalue(o); |
| 368 | case LUA_TUSERDATA: | 368 | case LUA_TUSERDATA: |
| 369 | case LUA_TLIGHTUSERDATA: | 369 | case LUA_TLIGHTUSERDATA: |
| 370 | return lua_touserdata(L, index); | 370 | return lua_touserdata(L, idx); |
| 371 | default: return NULL; | 371 | default: return NULL; |
| 372 | } | 372 | } |
| 373 | } | 373 | } |
| @@ -475,29 +475,29 @@ LUA_API void lua_pushlightuserdata (lua_State *L, void *p) { | |||
| 475 | */ | 475 | */ |
| 476 | 476 | ||
| 477 | 477 | ||
| 478 | LUA_API void lua_gettable (lua_State *L, int index) { | 478 | LUA_API void lua_gettable (lua_State *L, int idx) { |
| 479 | StkId t; | 479 | StkId t; |
| 480 | lua_lock(L); | 480 | lua_lock(L); |
| 481 | t = luaA_index(L, index); | 481 | t = luaA_index(L, idx); |
| 482 | setobj2s(L->top - 1, luaV_gettable(L, t, L->top - 1, 0)); | 482 | setobj2s(L->top - 1, luaV_gettable(L, t, L->top - 1, 0)); |
| 483 | lua_unlock(L); | 483 | lua_unlock(L); |
| 484 | } | 484 | } |
| 485 | 485 | ||
| 486 | 486 | ||
| 487 | LUA_API void lua_rawget (lua_State *L, int index) { | 487 | LUA_API void lua_rawget (lua_State *L, int idx) { |
| 488 | StkId t; | 488 | StkId t; |
| 489 | lua_lock(L); | 489 | lua_lock(L); |
| 490 | t = luaA_index(L, index); | 490 | t = luaA_index(L, idx); |
| 491 | api_check(L, ttistable(t)); | 491 | api_check(L, ttistable(t)); |
| 492 | setobj2s(L->top - 1, luaH_get(hvalue(t), L->top - 1)); | 492 | setobj2s(L->top - 1, luaH_get(hvalue(t), L->top - 1)); |
| 493 | lua_unlock(L); | 493 | lua_unlock(L); |
| 494 | } | 494 | } |
| 495 | 495 | ||
| 496 | 496 | ||
| 497 | LUA_API void lua_rawgeti (lua_State *L, int index, int n) { | 497 | LUA_API void lua_rawgeti (lua_State *L, int idx, int n) { |
| 498 | StkId o; | 498 | StkId o; |
| 499 | lua_lock(L); | 499 | lua_lock(L); |
| 500 | o = luaA_index(L, index); | 500 | o = luaA_index(L, idx); |
| 501 | api_check(L, ttistable(o)); | 501 | api_check(L, ttistable(o)); |
| 502 | setobj2s(L->top, luaH_getnum(hvalue(o), n)); | 502 | setobj2s(L->top, luaH_getnum(hvalue(o), n)); |
| 503 | api_incr_top(L); | 503 | api_incr_top(L); |
| @@ -542,10 +542,10 @@ LUA_API int lua_getmetatable (lua_State *L, int objindex) { | |||
| 542 | } | 542 | } |
| 543 | 543 | ||
| 544 | 544 | ||
| 545 | LUA_API void lua_getfenv (lua_State *L, int index) { | 545 | LUA_API void lua_getfenv (lua_State *L, int idx) { |
| 546 | StkId o; | 546 | StkId o; |
| 547 | lua_lock(L); | 547 | lua_lock(L); |
| 548 | o = luaA_index(L, index); | 548 | o = luaA_index(L, idx); |
| 549 | setobj2s(L->top, isLfunction(o) ? &clvalue(o)->l.g : gt(L)); | 549 | setobj2s(L->top, isLfunction(o) ? &clvalue(o)->l.g : gt(L)); |
| 550 | api_incr_top(L); | 550 | api_incr_top(L); |
| 551 | lua_unlock(L); | 551 | lua_unlock(L); |
| @@ -557,22 +557,22 @@ LUA_API void lua_getfenv (lua_State *L, int index) { | |||
| 557 | */ | 557 | */ |
| 558 | 558 | ||
| 559 | 559 | ||
| 560 | LUA_API void lua_settable (lua_State *L, int index) { | 560 | LUA_API void lua_settable (lua_State *L, int idx) { |
| 561 | StkId t; | 561 | StkId t; |
| 562 | lua_lock(L); | 562 | lua_lock(L); |
| 563 | api_checknelems(L, 2); | 563 | api_checknelems(L, 2); |
| 564 | t = luaA_index(L, index); | 564 | t = luaA_index(L, idx); |
| 565 | luaV_settable(L, t, L->top - 2, L->top - 1); | 565 | luaV_settable(L, t, L->top - 2, L->top - 1); |
| 566 | L->top -= 2; /* pop index and value */ | 566 | L->top -= 2; /* pop index and value */ |
| 567 | lua_unlock(L); | 567 | lua_unlock(L); |
| 568 | } | 568 | } |
| 569 | 569 | ||
| 570 | 570 | ||
| 571 | LUA_API void lua_rawset (lua_State *L, int index) { | 571 | LUA_API void lua_rawset (lua_State *L, int idx) { |
| 572 | StkId t; | 572 | StkId t; |
| 573 | lua_lock(L); | 573 | lua_lock(L); |
| 574 | api_checknelems(L, 2); | 574 | api_checknelems(L, 2); |
| 575 | t = luaA_index(L, index); | 575 | t = luaA_index(L, idx); |
| 576 | api_check(L, ttistable(t)); | 576 | api_check(L, ttistable(t)); |
| 577 | setobj2t(luaH_set(L, hvalue(t), L->top-2), L->top-1); /* write barrier */ | 577 | setobj2t(luaH_set(L, hvalue(t), L->top-2), L->top-1); /* write barrier */ |
| 578 | L->top -= 2; | 578 | L->top -= 2; |
| @@ -580,11 +580,11 @@ LUA_API void lua_rawset (lua_State *L, int index) { | |||
| 580 | } | 580 | } |
| 581 | 581 | ||
| 582 | 582 | ||
| 583 | LUA_API void lua_rawseti (lua_State *L, int index, int n) { | 583 | LUA_API void lua_rawseti (lua_State *L, int idx, int n) { |
| 584 | StkId o; | 584 | StkId o; |
| 585 | lua_lock(L); | 585 | lua_lock(L); |
| 586 | api_checknelems(L, 1); | 586 | api_checknelems(L, 1); |
| 587 | o = luaA_index(L, index); | 587 | o = luaA_index(L, idx); |
| 588 | api_check(L, ttistable(o)); | 588 | api_check(L, ttistable(o)); |
| 589 | setobj2t(luaH_setnum(L, hvalue(o), n), L->top-1); /* write barrier */ | 589 | setobj2t(luaH_setnum(L, hvalue(o), n), L->top-1); /* write barrier */ |
| 590 | L->top--; | 590 | L->top--; |
| @@ -620,12 +620,12 @@ LUA_API int lua_setmetatable (lua_State *L, int objindex) { | |||
| 620 | } | 620 | } |
| 621 | 621 | ||
| 622 | 622 | ||
| 623 | LUA_API int lua_setfenv (lua_State *L, int index) { | 623 | LUA_API int lua_setfenv (lua_State *L, int idx) { |
| 624 | StkId o; | 624 | StkId o; |
| 625 | int res = 0; | 625 | int res = 0; |
| 626 | lua_lock(L); | 626 | lua_lock(L); |
| 627 | api_checknelems(L, 1); | 627 | api_checknelems(L, 1); |
| 628 | o = luaA_index(L, index); | 628 | o = luaA_index(L, idx); |
| 629 | L->top--; | 629 | L->top--; |
| 630 | api_check(L, ttistable(L->top)); | 630 | api_check(L, ttistable(L->top)); |
| 631 | if (isLfunction(o)) { | 631 | if (isLfunction(o)) { |
| @@ -803,11 +803,11 @@ LUA_API int lua_error (lua_State *L) { | |||
| 803 | } | 803 | } |
| 804 | 804 | ||
| 805 | 805 | ||
| 806 | LUA_API int lua_next (lua_State *L, int index) { | 806 | LUA_API int lua_next (lua_State *L, int idx) { |
| 807 | StkId t; | 807 | StkId t; |
| 808 | int more; | 808 | int more; |
| 809 | lua_lock(L); | 809 | lua_lock(L); |
| 810 | t = luaA_index(L, index); | 810 | t = luaA_index(L, idx); |
| 811 | api_check(L, ttistable(t)); | 811 | api_check(L, ttistable(t)); |
| 812 | more = luaH_next(L, hvalue(t), L->top - 1); | 812 | more = luaH_next(L, hvalue(t), L->top - 1); |
| 813 | if (more) { | 813 | if (more) { |
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lcode.c,v 1.114 2002/12/04 17:38:31 roberto Exp roberto $ | 2 | ** $Id: lcode.c,v 1.115 2002/12/11 12:34:22 roberto Exp roberto $ |
| 3 | ** Code generator for Lua | 3 | ** Code generator for Lua |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -207,10 +207,10 @@ static void freeexp (FuncState *fs, expdesc *e) { | |||
| 207 | 207 | ||
| 208 | 208 | ||
| 209 | static int addk (FuncState *fs, TObject *k, TObject *v) { | 209 | static int addk (FuncState *fs, TObject *k, TObject *v) { |
| 210 | const TObject *index = luaH_get(fs->h, k); | 210 | const TObject *idx = luaH_get(fs->h, k); |
| 211 | if (ttisnumber(index)) { | 211 | if (ttisnumber(idx)) { |
| 212 | lua_assert(luaO_rawequalObj(&fs->f->k[cast(int, nvalue(index))], v)); | 212 | lua_assert(luaO_rawequalObj(&fs->f->k[cast(int, nvalue(idx))], v)); |
| 213 | return cast(int, nvalue(index)); | 213 | return cast(int, nvalue(idx)); |
| 214 | } | 214 | } |
| 215 | else { /* constant not found; create a new entry */ | 215 | else { /* constant not found; create a new entry */ |
| 216 | Proto *f = fs->f; | 216 | Proto *f = fs->f; |
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: ltests.c,v 1.152 2003/02/10 17:31:13 roberto Exp roberto $ | 2 | ** $Id: ltests.c,v 1.153 2003/02/18 16:02:56 roberto Exp roberto $ |
| 3 | ** Internal Module for Debugging of the Lua Implementation | 3 | ** Internal Module for Debugging of the Lua Implementation |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -41,7 +41,7 @@ static lua_State *lua_state = NULL; | |||
| 41 | int islocked = 0; | 41 | int islocked = 0; |
| 42 | 42 | ||
| 43 | 43 | ||
| 44 | #define index(L,k) (L->ci->base+(k) - 1) | 44 | #define func_at(L,k) (L->ci->base+(k) - 1) |
| 45 | 45 | ||
| 46 | 46 | ||
| 47 | static void setnameval (lua_State *L, const char *name, int val) { | 47 | static void setnameval (lua_State *L, const char *name, int val) { |
| @@ -190,7 +190,7 @@ static int listcode (lua_State *L) { | |||
| 190 | Proto *p; | 190 | Proto *p; |
| 191 | luaL_argcheck(L, lua_isfunction(L, 1) && !lua_iscfunction(L, 1), | 191 | luaL_argcheck(L, lua_isfunction(L, 1) && !lua_iscfunction(L, 1), |
| 192 | 1, "Lua function expected"); | 192 | 1, "Lua function expected"); |
| 193 | p = clvalue(index(L, 1))->l.p; | 193 | p = clvalue(func_at(L, 1))->l.p; |
| 194 | lua_newtable(L); | 194 | lua_newtable(L); |
| 195 | setnameval(L, "maxstack", p->maxstacksize); | 195 | setnameval(L, "maxstack", p->maxstacksize); |
| 196 | setnameval(L, "numparams", p->numparams); | 196 | setnameval(L, "numparams", p->numparams); |
| @@ -209,7 +209,7 @@ static int listk (lua_State *L) { | |||
| 209 | int i; | 209 | int i; |
| 210 | luaL_argcheck(L, lua_isfunction(L, 1) && !lua_iscfunction(L, 1), | 210 | luaL_argcheck(L, lua_isfunction(L, 1) && !lua_iscfunction(L, 1), |
| 211 | 1, "Lua function expected"); | 211 | 1, "Lua function expected"); |
| 212 | p = clvalue(index(L, 1))->l.p; | 212 | p = clvalue(func_at(L, 1))->l.p; |
| 213 | lua_newtable(L); | 213 | lua_newtable(L); |
| 214 | for (i=0; i<p->sizek; i++) { | 214 | for (i=0; i<p->sizek; i++) { |
| 215 | lua_pushnumber(L, i+1); | 215 | lua_pushnumber(L, i+1); |
| @@ -227,7 +227,7 @@ static int listlocals (lua_State *L) { | |||
| 227 | const char *name; | 227 | const char *name; |
| 228 | luaL_argcheck(L, lua_isfunction(L, 1) && !lua_iscfunction(L, 1), | 228 | luaL_argcheck(L, lua_isfunction(L, 1) && !lua_iscfunction(L, 1), |
| 229 | 1, "Lua function expected"); | 229 | 1, "Lua function expected"); |
| 230 | p = clvalue(index(L, 1))->l.p; | 230 | p = clvalue(func_at(L, 1))->l.p; |
| 231 | while ((name = luaF_getlocalname(p, ++i, pc)) != NULL) | 231 | while ((name = luaF_getlocalname(p, ++i, pc)) != NULL) |
| 232 | lua_pushstring(L, name); | 232 | lua_pushstring(L, name); |
| 233 | return i-1; | 233 | return i-1; |
| @@ -267,13 +267,13 @@ static int mem_query (lua_State *L) { | |||
| 267 | static int hash_query (lua_State *L) { | 267 | static int hash_query (lua_State *L) { |
| 268 | if (lua_isnone(L, 2)) { | 268 | if (lua_isnone(L, 2)) { |
| 269 | luaL_argcheck(L, lua_type(L, 1) == LUA_TSTRING, 1, "string expected"); | 269 | luaL_argcheck(L, lua_type(L, 1) == LUA_TSTRING, 1, "string expected"); |
| 270 | lua_pushnumber(L, tsvalue(index(L, 1))->tsv.hash); | 270 | lua_pushnumber(L, tsvalue(func_at(L, 1))->tsv.hash); |
| 271 | } | 271 | } |
| 272 | else { | 272 | else { |
| 273 | TObject *o = index(L, 1); | 273 | TObject *o = func_at(L, 1); |
| 274 | Table *t; | 274 | Table *t; |
| 275 | luaL_checktype(L, 2, LUA_TTABLE); | 275 | luaL_checktype(L, 2, LUA_TTABLE); |
| 276 | t = hvalue(index(L, 2)); | 276 | t = hvalue(func_at(L, 2)); |
| 277 | lua_pushnumber(L, luaH_mainposition(t, o) - t->node); | 277 | lua_pushnumber(L, luaH_mainposition(t, o) - t->node); |
| 278 | } | 278 | } |
| 279 | return 1; | 279 | return 1; |
| @@ -295,7 +295,7 @@ static int table_query (lua_State *L) { | |||
| 295 | const Table *t; | 295 | const Table *t; |
| 296 | int i = luaL_optint(L, 2, -1); | 296 | int i = luaL_optint(L, 2, -1); |
| 297 | luaL_checktype(L, 1, LUA_TTABLE); | 297 | luaL_checktype(L, 1, LUA_TTABLE); |
| 298 | t = hvalue(index(L, 1)); | 298 | t = hvalue(func_at(L, 1)); |
| 299 | if (i == -1) { | 299 | if (i == -1) { |
| 300 | lua_pushnumber(L, t->sizearray); | 300 | lua_pushnumber(L, t->sizearray); |
| 301 | lua_pushnumber(L, sizenode(t)); | 301 | lua_pushnumber(L, sizenode(t)); |
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lvm.c,v 1.276 2003/02/18 16:02:56 roberto Exp roberto $ | 2 | ** $Id: lvm.c,v 1.277 2003/02/27 11:52:30 roberto Exp roberto $ |
| 3 | ** Lua virtual machine | 3 | ** Lua virtual machine |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -680,7 +680,7 @@ StkId luaV_execute (lua_State *L) { | |||
| 680 | } | 680 | } |
| 681 | } | 681 | } |
| 682 | case OP_FORLOOP: { | 682 | case OP_FORLOOP: { |
| 683 | lua_Number step, index, limit; | 683 | lua_Number step, idx, limit; |
| 684 | const TObject *plimit = ra+1; | 684 | const TObject *plimit = ra+1; |
| 685 | const TObject *pstep = ra+2; | 685 | const TObject *pstep = ra+2; |
| 686 | if (!ttisnumber(ra)) | 686 | if (!ttisnumber(ra)) |
| @@ -690,11 +690,11 @@ StkId luaV_execute (lua_State *L) { | |||
| 690 | if (!tonumber(pstep, ra+2)) | 690 | if (!tonumber(pstep, ra+2)) |
| 691 | luaG_runerror(L, "`for' step must be a number"); | 691 | luaG_runerror(L, "`for' step must be a number"); |
| 692 | step = nvalue(pstep); | 692 | step = nvalue(pstep); |
| 693 | index = nvalue(ra) + step; /* increment index */ | 693 | idx = nvalue(ra) + step; /* increment index */ |
| 694 | limit = nvalue(plimit); | 694 | limit = nvalue(plimit); |
| 695 | if (step > 0 ? index <= limit : index >= limit) { | 695 | if (step > 0 ? idx <= limit : idx >= limit) { |
| 696 | dojump(pc, GETARG_sBx(i)); /* jump back */ | 696 | dojump(pc, GETARG_sBx(i)); /* jump back */ |
| 697 | chgnvalue(ra, index); /* update index */ | 697 | chgnvalue(ra, idx); /* update index */ |
| 698 | } | 698 | } |
| 699 | break; | 699 | break; |
| 700 | } | 700 | } |
