'getlocal' gets information about parameters of Lua functions
This commit is contained in:
21
ldebug.c
21
ldebug.c
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
** $Id: ldebug.c,v 2.70 2010/04/13 20:48:12 roberto Exp roberto $
|
||||
** $Id: ldebug.c,v 2.71 2010/06/16 13:44:36 roberto Exp roberto $
|
||||
** Debug Interface
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
@@ -119,12 +119,21 @@ static const char *findlocal (lua_State *L, CallInfo *ci, int n,
|
||||
|
||||
|
||||
LUA_API const char *lua_getlocal (lua_State *L, const lua_Debug *ar, int n) {
|
||||
StkId pos;
|
||||
const char *name = findlocal(L, ar->i_ci, n, &pos);
|
||||
const char *name;
|
||||
lua_lock(L);
|
||||
if (name) {
|
||||
setobj2s(L, L->top, pos);
|
||||
api_incr_top(L);
|
||||
if (ar == NULL) { /* information about non-active function? */
|
||||
if (!isLfunction(L->top - 1)) /* not a Lua function? */
|
||||
name = NULL;
|
||||
else /* consider live variables at function start (parameters) */
|
||||
name = luaF_getlocalname(clvalue(L->top - 1)->l.p, n, 0);
|
||||
}
|
||||
else { /* active function; get information through 'ar' */
|
||||
StkId pos;
|
||||
name = findlocal(L, ar->i_ci, n, &pos);
|
||||
if (name) {
|
||||
setobj2s(L, L->top, pos);
|
||||
api_incr_top(L);
|
||||
}
|
||||
}
|
||||
lua_unlock(L);
|
||||
return name;
|
||||
|
||||
Reference in New Issue
Block a user