diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2002-03-04 18:29:41 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2002-03-04 18:29:41 -0300 |
| commit | 88c7b574cb5ac0402178b9c61fabe8fc50152e3c (patch) | |
| tree | 742d781041b1981ec31015daf543b977d8f2366f /ltests.c | |
| parent | 51bf91a9705ab38224f42464fb07da968758b0f7 (diff) | |
| download | lua-88c7b574cb5ac0402178b9c61fabe8fc50152e3c.tar.gz lua-88c7b574cb5ac0402178b9c61fabe8fc50152e3c.tar.bz2 lua-88c7b574cb5ac0402178b9c61fabe8fc50152e3c.zip | |
`luaA_index' is a local macro now
Diffstat (limited to '')
| -rw-r--r-- | ltests.c | 18 |
1 files changed, 10 insertions, 8 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: ltests.c,v 1.109 2002/02/14 21:42:22 roberto Exp roberto $ | 2 | ** $Id: ltests.c,v 1.110 2002/03/04 15:26: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,6 +41,8 @@ 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) | ||
| 45 | |||
| 44 | 46 | ||
| 45 | static void setnameval (lua_State *L, const char *name, int val) { | 47 | static void setnameval (lua_State *L, const char *name, int val) { |
| 46 | lua_pushstring(L, name); | 48 | lua_pushstring(L, name); |
| @@ -165,7 +167,7 @@ static int listcode (lua_State *L) { | |||
| 165 | Proto *p; | 167 | Proto *p; |
| 166 | luaL_arg_check(L, lua_isfunction(L, 1) && !lua_iscfunction(L, 1), | 168 | luaL_arg_check(L, lua_isfunction(L, 1) && !lua_iscfunction(L, 1), |
| 167 | 1, "Lua function expected"); | 169 | 1, "Lua function expected"); |
| 168 | p = clvalue(luaA_index(L, 1))->l.p; | 170 | p = clvalue(index(L, 1))->l.p; |
| 169 | lua_newtable(L); | 171 | lua_newtable(L); |
| 170 | setnameval(L, "maxstack", p->maxstacksize); | 172 | setnameval(L, "maxstack", p->maxstacksize); |
| 171 | setnameval(L, "numparams", p->numparams); | 173 | setnameval(L, "numparams", p->numparams); |
| @@ -184,7 +186,7 @@ static int listk (lua_State *L) { | |||
| 184 | int i; | 186 | int i; |
| 185 | luaL_arg_check(L, lua_isfunction(L, 1) && !lua_iscfunction(L, 1), | 187 | luaL_arg_check(L, lua_isfunction(L, 1) && !lua_iscfunction(L, 1), |
| 186 | 1, "Lua function expected"); | 188 | 1, "Lua function expected"); |
| 187 | p = clvalue(luaA_index(L, 1))->l.p; | 189 | p = clvalue(index(L, 1))->l.p; |
| 188 | lua_newtable(L); | 190 | lua_newtable(L); |
| 189 | for (i=0; i<p->sizek; i++) { | 191 | for (i=0; i<p->sizek; i++) { |
| 190 | lua_pushnumber(L, i+1); | 192 | lua_pushnumber(L, i+1); |
| @@ -202,7 +204,7 @@ static int listlocals (lua_State *L) { | |||
| 202 | const char *name; | 204 | const char *name; |
| 203 | luaL_arg_check(L, lua_isfunction(L, 1) && !lua_iscfunction(L, 1), | 205 | luaL_arg_check(L, lua_isfunction(L, 1) && !lua_iscfunction(L, 1), |
| 204 | 1, "Lua function expected"); | 206 | 1, "Lua function expected"); |
| 205 | p = clvalue(luaA_index(L, 1))->l.p; | 207 | p = clvalue(index(L, 1))->l.p; |
| 206 | while ((name = luaF_getlocalname(p, ++i, pc)) != NULL) | 208 | while ((name = luaF_getlocalname(p, ++i, pc)) != NULL) |
| 207 | lua_pushstring(L, name); | 209 | lua_pushstring(L, name); |
| 208 | return i-1; | 210 | return i-1; |
| @@ -242,13 +244,13 @@ static int mem_query (lua_State *L) { | |||
| 242 | static int hash_query (lua_State *L) { | 244 | static int hash_query (lua_State *L) { |
| 243 | if (lua_isnone(L, 2)) { | 245 | if (lua_isnone(L, 2)) { |
| 244 | luaL_arg_check(L, lua_type(L, 1) == LUA_TSTRING, 1, "string expected"); | 246 | luaL_arg_check(L, lua_type(L, 1) == LUA_TSTRING, 1, "string expected"); |
| 245 | lua_pushnumber(L, tsvalue(luaA_index(L, 1))->tsv.hash); | 247 | lua_pushnumber(L, tsvalue(index(L, 1))->tsv.hash); |
| 246 | } | 248 | } |
| 247 | else { | 249 | else { |
| 248 | TObject *o = luaA_index(L, 1); | 250 | TObject *o = index(L, 1); |
| 249 | Table *t; | 251 | Table *t; |
| 250 | luaL_check_type(L, 2, LUA_TTABLE); | 252 | luaL_check_type(L, 2, LUA_TTABLE); |
| 251 | t = hvalue(luaA_index(L, 2)); | 253 | t = hvalue(index(L, 2)); |
| 252 | lua_pushnumber(L, luaH_mainposition(t, o) - t->node); | 254 | lua_pushnumber(L, luaH_mainposition(t, o) - t->node); |
| 253 | } | 255 | } |
| 254 | return 1; | 256 | return 1; |
| @@ -270,7 +272,7 @@ static int table_query (lua_State *L) { | |||
| 270 | const Table *t; | 272 | const Table *t; |
| 271 | int i = luaL_opt_int(L, 2, -1); | 273 | int i = luaL_opt_int(L, 2, -1); |
| 272 | luaL_check_type(L, 1, LUA_TTABLE); | 274 | luaL_check_type(L, 1, LUA_TTABLE); |
| 273 | t = hvalue(luaA_index(L, 1)); | 275 | t = hvalue(index(L, 1)); |
| 274 | if (i == -1) { | 276 | if (i == -1) { |
| 275 | lua_pushnumber(L, t->sizearray); | 277 | lua_pushnumber(L, t->sizearray); |
| 276 | lua_pushnumber(L, sizenode(t)); | 278 | lua_pushnumber(L, sizenode(t)); |
