summaryrefslogtreecommitdiff
path: root/src/lj_debug.c
diff options
context:
space:
mode:
authorMike Pall <mike>2012-09-19 12:08:35 +0200
committerMike Pall <mike>2012-09-19 12:08:35 +0200
commitc687d01c465ba10927ddec22bdbecc533c05dfbe (patch)
treec5e45af5467e3cf0a109aa65ee217b1e43a3cc5e /src/lj_debug.c
parent7d49b19ad01b14d5547b888db9a31ad86f7f735f (diff)
downloadluajit2-c687d01c465ba10927ddec22bdbecc533c05dfbe.tar.gz
From Lua 5.2: debug.getlocal() accepts function arg, too.
Diffstat (limited to 'src/lj_debug.c')
-rw-r--r--src/lj_debug.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/lj_debug.c b/src/lj_debug.c
index 85dbac50..d5693779 100644
--- a/src/lj_debug.c
+++ b/src/lj_debug.c
@@ -401,10 +401,14 @@ void lj_debug_pushloc(lua_State *L, GCproto *pt, BCPos pc)
LUA_API const char *lua_getlocal(lua_State *L, const lua_Debug *ar, int n)
{
const char *name = NULL;
- TValue *o = debug_localname(L, ar, &name, (BCReg)n);
- if (name) {
- copyTV(L, L->top, o);
- incr_top(L);
+ if (ar) {
+ TValue *o = debug_localname(L, ar, &name, (BCReg)n);
+ if (name) {
+ copyTV(L, L->top, o);
+ incr_top(L);
+ }
+ } else if (tvisfunc(L->top-1) && isluafunc(funcV(L->top-1))) {
+ name = debug_varname(funcproto(funcV(L->top-1)), 0, (BCReg)n-1);
}
return name;
}