diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2000-09-05 16:33:32 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2000-09-05 16:33:32 -0300 |
commit | 6e80c1cde193b767d63d2cc30ebd71d65512e061 (patch) | |
tree | cb599bdc956c0dc9b3d469bb01de47185db3e4e2 /ltests.c | |
parent | f67f324377aff66d78479eaaffbb94a6b092ae45 (diff) | |
download | lua-6e80c1cde193b767d63d2cc30ebd71d65512e061.tar.gz lua-6e80c1cde193b767d63d2cc30ebd71d65512e061.tar.bz2 lua-6e80c1cde193b767d63d2cc30ebd71d65512e061.zip |
new version for API
Diffstat (limited to 'ltests.c')
-rw-r--r-- | ltests.c | 30 |
1 files changed, 15 insertions, 15 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ltests.c,v 1.38 2000/08/31 13:29:47 roberto Exp roberto $ | 2 | ** $Id: ltests.c,v 1.39 2000/08/31 20:23:40 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 | */ |
@@ -38,10 +38,9 @@ void luaB_opentests (lua_State *L); | |||
38 | 38 | ||
39 | 39 | ||
40 | static void setnameval (lua_State *L, const char *name, int val) { | 40 | static void setnameval (lua_State *L, const char *name, int val) { |
41 | lua_pushobject(L, -1); | ||
42 | lua_pushstring(L, name); | 41 | lua_pushstring(L, name); |
43 | lua_pushnumber(L, val); | 42 | lua_pushnumber(L, val); |
44 | lua_settable(L); | 43 | lua_settable(L, -3); |
45 | } | 44 | } |
46 | 45 | ||
47 | 46 | ||
@@ -100,10 +99,9 @@ static int listcode (lua_State *L) { | |||
100 | setnameval(L, "numparams", p->numparams); | 99 | setnameval(L, "numparams", p->numparams); |
101 | pc = 0; | 100 | pc = 0; |
102 | do { | 101 | do { |
103 | lua_pushobject(L, -1); | ||
104 | lua_pushnumber(L, pc+1); | 102 | lua_pushnumber(L, pc+1); |
105 | res = pushop(L, p, pc++); | 103 | res = pushop(L, p, pc++); |
106 | lua_settable(L); | 104 | lua_settable(L, -3); |
107 | } while (res); | 105 | } while (res); |
108 | return 1; | 106 | return 1; |
109 | } | 107 | } |
@@ -116,10 +114,9 @@ static int liststrings (lua_State *L) { | |||
116 | p = clvalue(luaA_index(L, 1))->f.l; | 114 | p = clvalue(luaA_index(L, 1))->f.l; |
117 | lua_newtable(L); | 115 | lua_newtable(L); |
118 | for (i=0; i<p->nkstr; i++) { | 116 | for (i=0; i<p->nkstr; i++) { |
119 | lua_pushobject(L, -1); | ||
120 | lua_pushnumber(L, i+1); | 117 | lua_pushnumber(L, i+1); |
121 | lua_pushstring(L, p->kstr[i]->str); | 118 | lua_pushstring(L, p->kstr[i]->str); |
122 | lua_settable(L); | 119 | lua_settable(L, -3); |
123 | } | 120 | } |
124 | return 1; | 121 | return 1; |
125 | } | 122 | } |
@@ -241,7 +238,7 @@ static int string_query (lua_State *L) { | |||
241 | 238 | ||
242 | static int tref (lua_State *L) { | 239 | static int tref (lua_State *L) { |
243 | luaL_checktype(L, 1, "any"); | 240 | luaL_checktype(L, 1, "any"); |
244 | lua_pushobject(L, 1); | 241 | lua_pushvalue(L, 1); |
245 | lua_pushnumber(L, lua_ref(L, luaL_opt_int(L, 2, 1))); | 242 | lua_pushnumber(L, lua_ref(L, luaL_opt_int(L, 2, 1))); |
246 | return 1; | 243 | return 1; |
247 | } | 244 | } |
@@ -270,7 +267,7 @@ static int udataval (lua_State *L) { | |||
270 | } | 267 | } |
271 | 268 | ||
272 | static int newstate (lua_State *L) { | 269 | static int newstate (lua_State *L) { |
273 | lua_State *L1 = lua_newstate(luaL_check_int(L, 1), luaL_check_int(L, 2)); | 270 | lua_State *L1 = lua_newstate(luaL_check_int(L, 1)); |
274 | if (L1) | 271 | if (L1) |
275 | lua_pushuserdata(L, L1); | 272 | lua_pushuserdata(L, L1); |
276 | else | 273 | else |
@@ -390,17 +387,20 @@ static int testC (lua_State *L) { | |||
390 | else if EQ("pushnum") { | 387 | else if EQ("pushnum") { |
391 | lua_pushnumber(L, getnum); | 388 | lua_pushnumber(L, getnum); |
392 | } | 389 | } |
393 | else if EQ("pushobject") { | 390 | else if EQ("pushvalue") { |
394 | lua_pushobject(L, getnum); | 391 | lua_pushvalue(L, getnum); |
395 | } | 392 | } |
396 | else if EQ("move") { | 393 | else if EQ("remove") { |
397 | lua_move(L, getnum); | 394 | lua_remove(L, getnum); |
398 | } | 395 | } |
399 | else if EQ("insert") { | 396 | else if EQ("insert") { |
400 | lua_insert(L, getnum); | 397 | lua_insert(L, getnum); |
401 | } | 398 | } |
402 | else if EQ("next") { | 399 | else if EQ("next") { |
403 | lua_next(L); | 400 | lua_next(L, -2); |
401 | } | ||
402 | else if EQ("concat") { | ||
403 | lua_concat(L, getnum); | ||
404 | } | 404 | } |
405 | else if EQ("call") { | 405 | else if EQ("call") { |
406 | int narg = getnum; | 406 | int narg = getnum; |
@@ -445,7 +445,7 @@ static const struct luaL_reg tests_funcs[] = { | |||
445 | void luaB_opentests (lua_State *L) { | 445 | void luaB_opentests (lua_State *L) { |
446 | lua_newtable(L); | 446 | lua_newtable(L); |
447 | lua_getglobals(L); | 447 | lua_getglobals(L); |
448 | lua_pushobject(L, -2); | 448 | lua_pushvalue(L, -2); |
449 | lua_setglobals(L); | 449 | lua_setglobals(L); |
450 | luaL_openl(L, tests_funcs); /* open functions inside new table */ | 450 | luaL_openl(L, tests_funcs); /* open functions inside new table */ |
451 | lua_setglobals(L); /* restore old table of globals */ | 451 | lua_setglobals(L); /* restore old table of globals */ |