diff options
Diffstat (limited to 'ltests.c')
-rw-r--r-- | ltests.c | 15 |
1 files changed, 6 insertions, 9 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ltests.c,v 1.54 2000/10/31 13:10:24 roberto Exp roberto $ | 2 | ** $Id: ltests.c,v 1.55 2000/12/28 12:55:41 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 | */ |
@@ -53,7 +53,7 @@ static void setnameval (lua_State *L, const char *name, int val) { | |||
53 | 53 | ||
54 | 54 | ||
55 | static const char *const instrname[NUM_OPCODES] = { | 55 | static const char *const instrname[NUM_OPCODES] = { |
56 | "END", "RETURN", "CALL", "TAILCALL", "PUSHNIL", "POP", "PUSHINT", | 56 | "RETURN", "CALL", "TAILCALL", "PUSHNIL", "POP", "PUSHINT", |
57 | "PUSHSTRING", "PUSHNUM", "PUSHNEGNUM", "PUSHUPVALUE", "GETLOCAL", | 57 | "PUSHSTRING", "PUSHNUM", "PUSHNEGNUM", "PUSHUPVALUE", "GETLOCAL", |
58 | "GETGLOBAL", "GETTABLE", "GETDOTTED", "GETINDEXED", "PUSHSELF", | 58 | "GETGLOBAL", "GETTABLE", "GETDOTTED", "GETINDEXED", "PUSHSELF", |
59 | "CREATETABLE", "SETLOCAL", "SETGLOBAL", "SETTABLE", "SETLIST", "SETMAP", | 59 | "CREATETABLE", "SETLOCAL", "SETGLOBAL", "SETTABLE", "SETLIST", "SETMAP", |
@@ -64,7 +64,7 @@ static const char *const instrname[NUM_OPCODES] = { | |||
64 | }; | 64 | }; |
65 | 65 | ||
66 | 66 | ||
67 | static int pushop (lua_State *L, Proto *p, int pc) { | 67 | static void pushop (lua_State *L, Proto *p, int pc) { |
68 | char buff[100]; | 68 | char buff[100]; |
69 | Instruction i = p->code[pc]; | 69 | Instruction i = p->code[pc]; |
70 | OpCode o = GET_OPCODE(i); | 70 | OpCode o = GET_OPCODE(i); |
@@ -85,26 +85,23 @@ static int pushop (lua_State *L, Proto *p, int pc) { | |||
85 | break; | 85 | break; |
86 | } | 86 | } |
87 | lua_pushstring(L, buff); | 87 | lua_pushstring(L, buff); |
88 | return (o != OP_END); | ||
89 | } | 88 | } |
90 | 89 | ||
91 | 90 | ||
92 | static int listcode (lua_State *L) { | 91 | static int listcode (lua_State *L) { |
93 | int pc; | 92 | int pc; |
94 | Proto *p; | 93 | Proto *p; |
95 | int res; | ||
96 | luaL_arg_check(L, lua_isfunction(L, 1) && !lua_iscfunction(L, 1), | 94 | luaL_arg_check(L, lua_isfunction(L, 1) && !lua_iscfunction(L, 1), |
97 | 1, "Lua function expected"); | 95 | 1, "Lua function expected"); |
98 | p = clvalue(luaA_index(L, 1))->f.l; | 96 | p = clvalue(luaA_index(L, 1))->f.l; |
99 | lua_newtable(L); | 97 | lua_newtable(L); |
100 | setnameval(L, "maxstack", p->maxstacksize); | 98 | setnameval(L, "maxstack", p->maxstacksize); |
101 | setnameval(L, "numparams", p->numparams); | 99 | setnameval(L, "numparams", p->numparams); |
102 | pc = 0; | 100 | for (pc=0; pc<p->sizecode; pc++) { |
103 | do { | ||
104 | lua_pushnumber(L, pc+1); | 101 | lua_pushnumber(L, pc+1); |
105 | res = pushop(L, p, pc++); | 102 | pushop(L, p, pc); |
106 | lua_settable(L, -3); | 103 | lua_settable(L, -3); |
107 | } while (res); | 104 | } |
108 | return 1; | 105 | return 1; |
109 | } | 106 | } |
110 | 107 | ||