Browse Source

new debug info 'isvararg' and 'nparams'

pull/9/head
Roberto Ierusalimschy 15 years ago
parent
commit
5bcfe0c700
  1. 19
      ldblib.c
  2. 10
      ldebug.c
  3. 4
      lua.h

19
ldblib.c

@ -1,5 +1,5 @@
/*
** $Id: ldblib.c,v 1.117 2009/11/24 12:05:44 roberto Exp roberto $
** $Id: ldblib.c,v 1.118 2009/11/25 15:27:51 roberto Exp roberto $
** Interface from Lua to its debug API
** See Copyright Notice in lua.h
*/
@ -73,6 +73,12 @@ static void settabsi (lua_State *L, const char *i, int v) {
}
static void settabsb (lua_State *L, const char *i, int v) {
lua_pushboolean(L, v);
lua_setfield(L, -2, i);
}
static lua_State *getthread (lua_State *L, int *arg) {
if (lua_isthread(L, 1)) {
*arg = 1;
@ -127,16 +133,17 @@ static int db_getinfo (lua_State *L) {
}
if (strchr(options, 'l'))
settabsi(L, "currentline", ar.currentline);
if (strchr(options, 'u'))
if (strchr(options, 'u')) {
settabsi(L, "nups", ar.nups);
settabsi(L, "nparams", ar.nparams);
settabsb(L, "isvararg", ar.isvararg);
}
if (strchr(options, 'n')) {
settabss(L, "name", ar.name);
settabss(L, "namewhat", ar.namewhat);
}
if (strchr(options, 't')) {
lua_pushboolean(L, ar.istailcall);
lua_setfield(L, -2, "istailcall");
}
if (strchr(options, 't'))
settabsb(L, "istailcall", ar.istailcall);
if (strchr(options, 'L'))
treatstackoption(L, L1, "activelines");
if (strchr(options, 'f'))

10
ldebug.c

@ -1,5 +1,5 @@
/*
** $Id: ldebug.c,v 2.59 2009/11/26 15:34:15 roberto Exp roberto $
** $Id: ldebug.c,v 2.60 2009/12/01 16:31:04 roberto Exp roberto $
** Debug Interface
** See Copyright Notice in lua.h
*/
@ -192,6 +192,14 @@ static int auxgetinfo (lua_State *L, const char *what, lua_Debug *ar,
}
case 'u': {
ar->nups = f->c.nupvalues;
if (f->c.isC) {
ar->isvararg = 1;
ar->nparams = 0;
}
else {
ar->isvararg = f->l.p->is_vararg;
ar->nparams = f->l.p->numparams;
}
break;
}
case 't': {

4
lua.h

@ -1,5 +1,5 @@
/*
** $Id: lua.h,v 1.257 2009/12/22 16:47:00 roberto Exp roberto $
** $Id: lua.h,v 1.258 2010/01/05 18:33:26 roberto Exp roberto $
** Lua - A Scripting Language
** Lua.org, PUC-Rio, Brazil (http://www.lua.org)
** See Copyright Notice at the end of this file
@ -407,6 +407,8 @@ struct lua_Debug {
int linedefined; /* (S) */
int lastlinedefined; /* (S) */
unsigned char nups; /* (u) number of upvalues */
unsigned char nparams;/* (u) number of parameters */
char isvararg; /* (u) */
char istailcall; /* (t) */
char short_src[LUA_IDSIZE]; /* (S) */
/* private part */

Loading…
Cancel
Save