summaryrefslogtreecommitdiff
path: root/src/lj_debug.c
diff options
context:
space:
mode:
authorMike Pall <mike>2012-09-20 15:50:20 +0200
committerMike Pall <mike>2012-09-20 15:50:20 +0200
commita9baead59f0521b289ba39e4d56ca92b0359e31e (patch)
treea50d922e3510da73b93b47100a31ab2bfdbba656 /src/lj_debug.c
parent965694b0afdebfa8b4b9b28a6a7f9341ea2f14f0 (diff)
downloadluajit2-a9baead59f0521b289ba39e4d56ca92b0359e31e.tar.gz
From Lua 5.2: debug.getinfo(..., "u") returns nparams and isvararg.
Diffstat (limited to 'src/lj_debug.c')
-rw-r--r--src/lj_debug.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/lj_debug.c b/src/lj_debug.c
index 7dba8072..0e26cd7c 100644
--- a/src/lj_debug.c
+++ b/src/lj_debug.c
@@ -423,7 +423,7 @@ LUA_API const char *lua_setlocal(lua_State *L, const lua_Debug *ar, int n)
return name;
}
-LUA_API int lua_getinfo(lua_State *L, const char *what, lua_Debug *ar)
+int lj_debug_getinfo(lua_State *L, const char *what, lj_Debug *ar, int ext)
{
int opt_f = 0, opt_L = 0;
TValue *frame = NULL;
@@ -471,6 +471,16 @@ LUA_API int lua_getinfo(lua_State *L, const char *what, lua_Debug *ar)
ar->currentline = frame ? debug_frameline(L, fn, nextframe) : -1;
} else if (*what == 'u') {
ar->nups = fn->c.nupvalues;
+ if (ext) {
+ if (isluafunc(fn)) {
+ GCproto *pt = funcproto(fn);
+ ar->nparams = pt->numparams;
+ ar->isvararg = !!(pt->flags & PROTO_VARARG);
+ } else {
+ ar->nparams = 0;
+ ar->isvararg = 1;
+ }
+ }
} else if (*what == 'n') {
ar->namewhat = frame ? lj_debug_funcname(L, frame, &ar->name) : NULL;
if (ar->namewhat == NULL) {
@@ -515,6 +525,11 @@ LUA_API int lua_getinfo(lua_State *L, const char *what, lua_Debug *ar)
return 1; /* Ok. */
}
+LUA_API int lua_getinfo(lua_State *L, const char *what, lua_Debug *ar)
+{
+ return lj_debug_getinfo(L, what, (lj_Debug *)ar, 0);
+}
+
LUA_API int lua_getstack(lua_State *L, int level, lua_Debug *ar)
{
int size;