| 224 | |
| 225 | |
| 226 | static int auxgetinfo (lua_State *L, const char *what, lua_Debug *ar, |
| 227 | Closure *f, CallInfo *ci) { |
| 228 | int status = 1; |
| 229 | for (; *what; what++) { |
| 230 | switch (*what) { |
| 231 | case 'S': { |
| 232 | funcinfo(ar, f); |
| 233 | break; |
| 234 | } |
| 235 | case 'l': { |
| 236 | ar->currentline = (ci && isLua(ci)) ? currentline(ci) : -1; |
| 237 | break; |
| 238 | } |
| 239 | case 'u': { |
| 240 | ar->nups = (f == NULL) ? 0 : f->c.nupvalues; |
| 241 | if (noLuaClosure(f)) { |
| 242 | ar->isvararg = 1; |
| 243 | ar->nparams = 0; |
| 244 | } |
| 245 | else { |
| 246 | ar->isvararg = f->l.p->is_vararg; |
| 247 | ar->nparams = f->l.p->numparams; |
| 248 | } |
| 249 | break; |
| 250 | } |
| 251 | case 't': { |
| 252 | ar->istailcall = (ci) ? ci->callstatus & CIST_TAIL : 0; |
| 253 | break; |
| 254 | } |
| 255 | case 'n': { |
| 256 | /* calling function is a known Lua function? */ |
| 257 | if (ci && !(ci->callstatus & CIST_TAIL) && isLua(ci->previous)) |
| 258 | ar->namewhat = getfuncname(L, ci->previous, &ar->name); |
| 259 | else |
| 260 | ar->namewhat = NULL; |
| 261 | if (ar->namewhat == NULL) { |
| 262 | ar->namewhat = ""; /* not found */ |
| 263 | ar->name = NULL; |
| 264 | } |
| 265 | break; |
| 266 | } |
| 267 | case 'L': |
| 268 | case 'f': /* handled by lua_getinfo */ |
| 269 | break; |
| 270 | default: status = 0; /* invalid option */ |
| 271 | } |
| 272 | } |
| 273 | return status; |
| 274 | } |
| 275 | |
| 276 | |
| 277 | LUA_API int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar) { |
no test coverage detected