diff options
Diffstat (limited to '')
-rw-r--r-- | src/lj_debug.c | 54 |
1 files changed, 30 insertions, 24 deletions
diff --git a/src/lj_debug.c b/src/lj_debug.c index d5693779..7dba8072 100644 --- a/src/lj_debug.c +++ b/src/lj_debug.c | |||
@@ -425,7 +425,7 @@ LUA_API const char *lua_setlocal(lua_State *L, const lua_Debug *ar, int n) | |||
425 | 425 | ||
426 | LUA_API int lua_getinfo(lua_State *L, const char *what, lua_Debug *ar) | 426 | LUA_API int lua_getinfo(lua_State *L, const char *what, lua_Debug *ar) |
427 | { | 427 | { |
428 | int status = 1; | 428 | int opt_f = 0, opt_L = 0; |
429 | TValue *frame = NULL; | 429 | TValue *frame = NULL; |
430 | TValue *nextframe = NULL; | 430 | TValue *nextframe = NULL; |
431 | GCfunc *fn; | 431 | GCfunc *fn; |
@@ -478,35 +478,41 @@ LUA_API int lua_getinfo(lua_State *L, const char *what, lua_Debug *ar) | |||
478 | ar->name = NULL; | 478 | ar->name = NULL; |
479 | } | 479 | } |
480 | } else if (*what == 'f') { | 480 | } else if (*what == 'f') { |
481 | setfuncV(L, L->top, fn); | 481 | opt_f = 1; |
482 | incr_top(L); | ||
483 | } else if (*what == 'L') { | 482 | } else if (*what == 'L') { |
484 | if (isluafunc(fn)) { | 483 | opt_L = 1; |
485 | GCtab *t = lj_tab_new(L, 0, 0); | 484 | } else { |
486 | GCproto *pt = funcproto(fn); | 485 | return 0; /* Bad option. */ |
487 | const void *lineinfo = proto_lineinfo(pt); | 486 | } |
488 | if (lineinfo) { | 487 | } |
489 | BCLine first = pt->firstline; | 488 | if (opt_f) { |
490 | int sz = pt->numline < 256 ? 1 : pt->numline < 65536 ? 2 : 4; | 489 | setfuncV(L, L->top, fn); |
491 | MSize i, szl = pt->sizebc-1; | 490 | incr_top(L); |
492 | for (i = 0; i < szl; i++) { | 491 | } |
493 | BCLine line = first + | 492 | if (opt_L) { |
494 | (sz == 1 ? (BCLine)((const uint8_t *)lineinfo)[i] : | 493 | if (isluafunc(fn)) { |
495 | sz == 2 ? (BCLine)((const uint16_t *)lineinfo)[i] : | 494 | GCtab *t = lj_tab_new(L, 0, 0); |
496 | (BCLine)((const uint32_t *)lineinfo)[i]); | 495 | GCproto *pt = funcproto(fn); |
497 | setboolV(lj_tab_setint(L, t, line), 1); | 496 | const void *lineinfo = proto_lineinfo(pt); |
498 | } | 497 | if (lineinfo) { |
498 | BCLine first = pt->firstline; | ||
499 | int sz = pt->numline < 256 ? 1 : pt->numline < 65536 ? 2 : 4; | ||
500 | MSize i, szl = pt->sizebc-1; | ||
501 | for (i = 0; i < szl; i++) { | ||
502 | BCLine line = first + | ||
503 | (sz == 1 ? (BCLine)((const uint8_t *)lineinfo)[i] : | ||
504 | sz == 2 ? (BCLine)((const uint16_t *)lineinfo)[i] : | ||
505 | (BCLine)((const uint32_t *)lineinfo)[i]); | ||
506 | setboolV(lj_tab_setint(L, t, line), 1); | ||
499 | } | 507 | } |
500 | settabV(L, L->top, t); | ||
501 | } else { | ||
502 | setnilV(L->top); | ||
503 | } | 508 | } |
504 | incr_top(L); | 509 | settabV(L, L->top, t); |
505 | } else { | 510 | } else { |
506 | status = 0; /* Bad option. */ | 511 | setnilV(L->top); |
507 | } | 512 | } |
513 | incr_top(L); | ||
508 | } | 514 | } |
509 | return status; | 515 | return 1; /* Ok. */ |
510 | } | 516 | } |
511 | 517 | ||
512 | LUA_API int lua_getstack(lua_State *L, int level, lua_Debug *ar) | 518 | LUA_API int lua_getstack(lua_State *L, int level, lua_Debug *ar) |