aboutsummaryrefslogtreecommitdiff
path: root/ldebug.c
diff options
context:
space:
mode:
Diffstat (limited to 'ldebug.c')
-rw-r--r--ldebug.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/ldebug.c b/ldebug.c
index 304e5708..fcead7ce 100644
--- a/ldebug.c
+++ b/ldebug.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ldebug.c,v 2.70 2010/04/13 20:48:12 roberto Exp roberto $ 2** $Id: ldebug.c,v 2.71 2010/06/16 13:44:36 roberto Exp roberto $
3** Debug Interface 3** Debug Interface
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -119,12 +119,21 @@ static const char *findlocal (lua_State *L, CallInfo *ci, int n,
119 119
120 120
121LUA_API const char *lua_getlocal (lua_State *L, const lua_Debug *ar, int n) { 121LUA_API const char *lua_getlocal (lua_State *L, const lua_Debug *ar, int n) {
122 StkId pos; 122 const char *name;
123 const char *name = findlocal(L, ar->i_ci, n, &pos);
124 lua_lock(L); 123 lua_lock(L);
125 if (name) { 124 if (ar == NULL) { /* information about non-active function? */
126 setobj2s(L, L->top, pos); 125 if (!isLfunction(L->top - 1)) /* not a Lua function? */
127 api_incr_top(L); 126 name = NULL;
127 else /* consider live variables at function start (parameters) */
128 name = luaF_getlocalname(clvalue(L->top - 1)->l.p, n, 0);
129 }
130 else { /* active function; get information through 'ar' */
131 StkId pos;
132 name = findlocal(L, ar->i_ci, n, &pos);
133 if (name) {
134 setobj2s(L, L->top, pos);
135 api_incr_top(L);
136 }
128 } 137 }
129 lua_unlock(L); 138 lua_unlock(L);
130 return name; 139 return name;