diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2009-07-15 15:37:19 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2009-07-15 15:37:19 -0300 |
commit | bd5fa9cc8fdd966edc46c3de2cc420a72240ead3 (patch) | |
tree | 15f713451602e39e8f01ae4311c6c15b92f2448b | |
parent | 2658c94925fbc93991e854afc2e7354f225967aa (diff) | |
download | lua-bd5fa9cc8fdd966edc46c3de2cc420a72240ead3.tar.gz lua-bd5fa9cc8fdd966edc46c3de2cc420a72240ead3.tar.bz2 lua-bd5fa9cc8fdd966edc46c3de2cc420a72240ead3.zip |
new macro 'getproto'
-rw-r--r-- | lapi.c | 4 | ||||
-rw-r--r-- | lobject.h | 3 | ||||
-rw-r--r-- | ltests.c | 8 |
3 files changed, 8 insertions, 7 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lapi.c,v 2.85 2009/07/15 17:26:14 roberto Exp roberto $ | 2 | ** $Id: lapi.c,v 2.86 2009/07/15 17:57:03 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 | */ |
@@ -910,7 +910,7 @@ LUA_API int lua_dump (lua_State *L, lua_Writer writer, void *data) { | |||
910 | api_checknelems(L, 1); | 910 | api_checknelems(L, 1); |
911 | o = L->top - 1; | 911 | o = L->top - 1; |
912 | if (isLfunction(o)) | 912 | if (isLfunction(o)) |
913 | status = luaU_dump(L, clvalue(o)->l.p, writer, data, 0); | 913 | status = luaU_dump(L, getproto(o), writer, data, 0); |
914 | else | 914 | else |
915 | status = 1; | 915 | status = 1; |
916 | lua_unlock(L); | 916 | lua_unlock(L); |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lobject.h,v 2.26 2009/06/17 17:48:34 roberto Exp roberto $ | 2 | ** $Id: lobject.h,v 2.27 2009/06/18 16:36:40 roberto Exp roberto $ |
3 | ** Type definitions for Lua objects | 3 | ** Type definitions for Lua objects |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -312,6 +312,7 @@ typedef union Closure { | |||
312 | #define iscfunction(o) (ttype(o) == LUA_TFUNCTION && clvalue(o)->c.isC) | 312 | #define iscfunction(o) (ttype(o) == LUA_TFUNCTION && clvalue(o)->c.isC) |
313 | #define isLfunction(o) (ttype(o) == LUA_TFUNCTION && !clvalue(o)->c.isC) | 313 | #define isLfunction(o) (ttype(o) == LUA_TFUNCTION && !clvalue(o)->c.isC) |
314 | 314 | ||
315 | #define getproto(o) (clvalue(o)->l.p) | ||
315 | 316 | ||
316 | /* | 317 | /* |
317 | ** Tables | 318 | ** Tables |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ltests.c,v 2.66 2009/06/17 17:53:14 roberto Exp roberto $ | 2 | ** $Id: ltests.c,v 2.67 2009/07/15 17:26:14 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 | */ |
@@ -440,7 +440,7 @@ static int listcode (lua_State *L) { | |||
440 | Proto *p; | 440 | Proto *p; |
441 | luaL_argcheck(L, lua_isfunction(L, 1) && !lua_iscfunction(L, 1), | 441 | luaL_argcheck(L, lua_isfunction(L, 1) && !lua_iscfunction(L, 1), |
442 | 1, "Lua function expected"); | 442 | 1, "Lua function expected"); |
443 | p = clvalue(obj_at(L, 1))->l.p; | 443 | p = getproto(obj_at(L, 1)); |
444 | lua_newtable(L); | 444 | lua_newtable(L); |
445 | setnameval(L, "maxstack", p->maxstacksize); | 445 | setnameval(L, "maxstack", p->maxstacksize); |
446 | setnameval(L, "numparams", p->numparams); | 446 | setnameval(L, "numparams", p->numparams); |
@@ -459,7 +459,7 @@ static int listk (lua_State *L) { | |||
459 | int i; | 459 | int i; |
460 | luaL_argcheck(L, lua_isfunction(L, 1) && !lua_iscfunction(L, 1), | 460 | luaL_argcheck(L, lua_isfunction(L, 1) && !lua_iscfunction(L, 1), |
461 | 1, "Lua function expected"); | 461 | 1, "Lua function expected"); |
462 | p = clvalue(obj_at(L, 1))->l.p; | 462 | p = getproto(obj_at(L, 1)); |
463 | lua_createtable(L, p->sizek, 0); | 463 | lua_createtable(L, p->sizek, 0); |
464 | for (i=0; i<p->sizek; i++) { | 464 | for (i=0; i<p->sizek; i++) { |
465 | pushobject(L, p->k+i); | 465 | pushobject(L, p->k+i); |
@@ -476,7 +476,7 @@ static int listlocals (lua_State *L) { | |||
476 | const char *name; | 476 | const char *name; |
477 | luaL_argcheck(L, lua_isfunction(L, 1) && !lua_iscfunction(L, 1), | 477 | luaL_argcheck(L, lua_isfunction(L, 1) && !lua_iscfunction(L, 1), |
478 | 1, "Lua function expected"); | 478 | 1, "Lua function expected"); |
479 | p = clvalue(obj_at(L, 1))->l.p; | 479 | p = getproto(obj_at(L, 1)); |
480 | while ((name = luaF_getlocalname(p, ++i, pc)) != NULL) | 480 | while ((name = luaF_getlocalname(p, ++i, pc)) != NULL) |
481 | lua_pushstring(L, name); | 481 | lua_pushstring(L, name); |
482 | return i-1; | 482 | return i-1; |