mirror of
https://github.com/lua/lua.git
synced 2024-11-27 12:13:38 +08:00
new function 'printcode'
This commit is contained in:
parent
bc1b0733b8
commit
7f9a32ad85
19
ltests.c
19
ltests.c
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** $Id: ltests.c,v 2.222 2017/06/27 18:32:49 roberto Exp roberto $
|
||||
** $Id: ltests.c,v 2.223 2017/06/29 15:06:44 roberto Exp roberto $
|
||||
** Internal Module for Debugging of the Lua Implementation
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
@ -595,6 +595,22 @@ static int listcode (lua_State *L) {
|
||||
}
|
||||
|
||||
|
||||
static int printcode (lua_State *L) {
|
||||
int pc;
|
||||
Proto *p;
|
||||
luaL_argcheck(L, lua_isfunction(L, 1) && !lua_iscfunction(L, 1),
|
||||
1, "Lua function expected");
|
||||
p = getproto(obj_at(L, 1));
|
||||
printf("maxstack: %d\n", p->maxstacksize);
|
||||
printf("numparams: %d\n", p->numparams);
|
||||
for (pc=0; pc<p->sizecode; pc++) {
|
||||
char buff[100];
|
||||
printf("%d\t%s\n", pc + 1, buildop(p, pc, buff));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int listk (lua_State *L) {
|
||||
Proto *p;
|
||||
int i;
|
||||
@ -1634,6 +1650,7 @@ static const struct luaL_Reg tests_funcs[] = {
|
||||
{"log2", log2_aux},
|
||||
{"limits", get_limits},
|
||||
{"listcode", listcode},
|
||||
{"printcode", printcode},
|
||||
{"listk", listk},
|
||||
{"listlocals", listlocals},
|
||||
{"loadlib", loadlib},
|
||||
|
Loading…
Reference in New Issue
Block a user