diff options
| -rw-r--r-- | ltests.c | 19 |
1 files changed, 18 insertions, 1 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: ltests.c,v 2.222 2017/06/27 18:32:49 roberto Exp roberto $ | 2 | ** $Id: ltests.c,v 2.223 2017/06/29 15:06:44 roberto Exp roberto $ |
| 3 | ** Internal Module for Debugging of the Lua Implementation | 3 | ** Internal Module for Debugging of the Lua Implementation |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -595,6 +595,22 @@ static int listcode (lua_State *L) { | |||
| 595 | } | 595 | } |
| 596 | 596 | ||
| 597 | 597 | ||
| 598 | static int printcode (lua_State *L) { | ||
| 599 | int pc; | ||
| 600 | Proto *p; | ||
| 601 | luaL_argcheck(L, lua_isfunction(L, 1) && !lua_iscfunction(L, 1), | ||
| 602 | 1, "Lua function expected"); | ||
| 603 | p = getproto(obj_at(L, 1)); | ||
| 604 | printf("maxstack: %d\n", p->maxstacksize); | ||
| 605 | printf("numparams: %d\n", p->numparams); | ||
| 606 | for (pc=0; pc<p->sizecode; pc++) { | ||
| 607 | char buff[100]; | ||
| 608 | printf("%d\t%s\n", pc + 1, buildop(p, pc, buff)); | ||
| 609 | } | ||
| 610 | return 0; | ||
| 611 | } | ||
| 612 | |||
| 613 | |||
| 598 | static int listk (lua_State *L) { | 614 | static int listk (lua_State *L) { |
| 599 | Proto *p; | 615 | Proto *p; |
| 600 | int i; | 616 | int i; |
| @@ -1634,6 +1650,7 @@ static const struct luaL_Reg tests_funcs[] = { | |||
| 1634 | {"log2", log2_aux}, | 1650 | {"log2", log2_aux}, |
| 1635 | {"limits", get_limits}, | 1651 | {"limits", get_limits}, |
| 1636 | {"listcode", listcode}, | 1652 | {"listcode", listcode}, |
| 1653 | {"printcode", printcode}, | ||
| 1637 | {"listk", listk}, | 1654 | {"listk", listk}, |
| 1638 | {"listlocals", listlocals}, | 1655 | {"listlocals", listlocals}, |
| 1639 | {"loadlib", loadlib}, | 1656 | {"loadlib", loadlib}, |
