diff options
Diffstat (limited to 'ltests.c')
| -rw-r--r-- | ltests.c | 34 |
1 files changed, 24 insertions, 10 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: ltests.c,v 1.28 2000/06/28 17:06:07 roberto Exp roberto $ | 2 | ** $Id: ltests.c,v 1.29 2000/06/30 19:17:08 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 | */ |
| @@ -169,9 +169,14 @@ static void get_limits (void) { | |||
| 169 | 169 | ||
| 170 | 170 | ||
| 171 | static void mem_query (void) { | 171 | static void mem_query (void) { |
| 172 | lua_pushnumber(memdebug_total); | 172 | lua_Object arg = lua_getparam(1); |
| 173 | lua_pushnumber(memdebug_numblocks); | 173 | if (arg == LUA_NOOBJECT) { |
| 174 | lua_pushnumber(memdebug_maxmem); | 174 | lua_pushnumber(memdebug_total); |
| 175 | lua_pushnumber(memdebug_numblocks); | ||
| 176 | lua_pushnumber(memdebug_maxmem); | ||
| 177 | } | ||
| 178 | else | ||
| 179 | memdebug_memlimit = luaL_check_int(1); | ||
| 175 | } | 180 | } |
| 176 | 181 | ||
| 177 | 182 | ||
| @@ -375,7 +380,10 @@ static void testC (void) { | |||
| 375 | else if EQ("newstate") { | 380 | else if EQ("newstate") { |
| 376 | int stacksize = getnum(&pc); | 381 | int stacksize = getnum(&pc); |
| 377 | lua_State *L1 = lua_newstate(stacksize, getnum(&pc)); | 382 | lua_State *L1 = lua_newstate(stacksize, getnum(&pc)); |
| 378 | lua_pushuserdata(L1); | 383 | if (L1) |
| 384 | lua_pushuserdata(L1); | ||
| 385 | else | ||
| 386 | lua_pushnil(); | ||
| 379 | } | 387 | } |
| 380 | else if EQ("closestate") { | 388 | else if EQ("closestate") { |
| 381 | (lua_close)((lua_State *)lua_getuserdata(reg[getreg(&pc)])); | 389 | (lua_close)((lua_State *)lua_getuserdata(reg[getreg(&pc)])); |
| @@ -385,14 +393,20 @@ static void testC (void) { | |||
| 385 | lua_Object str = reg[getreg(&pc)]; | 393 | lua_Object str = reg[getreg(&pc)]; |
| 386 | lua_State *L1; | 394 | lua_State *L1; |
| 387 | lua_Object temp; | 395 | lua_Object temp; |
| 388 | int i; | 396 | int status; |
| 389 | if (!lua_isuserdata(ol1) || !lua_isstring(str)) | 397 | if (!lua_isuserdata(ol1) || !lua_isstring(str)) |
| 390 | lua_error("bad arguments for `doremote'"); | 398 | lua_error("bad arguments for `doremote'"); |
| 391 | L1 = (lua_State *)lua_getuserdata(ol1); | 399 | L1 = (lua_State *)lua_getuserdata(ol1); |
| 392 | (lua_dostring)(L1, lua_getstring(str)); | 400 | status = (lua_dostring)(L1, lua_getstring(str)); |
| 393 | i = 1; | 401 | if (status != 0) { |
| 394 | while ((temp = (lua_getresult)(L1, i++)) != LUA_NOOBJECT) | 402 | lua_pushnil(); |
| 395 | lua_pushstring((lua_getstring)(L1, temp)); | 403 | lua_pushnumber(status); |
| 404 | } | ||
| 405 | else { | ||
| 406 | int i = 1; | ||
| 407 | while ((temp = (lua_getresult)(L1, i++)) != LUA_NOOBJECT) | ||
| 408 | lua_pushstring((lua_getstring)(L1, temp)); | ||
| 409 | } | ||
| 396 | } | 410 | } |
| 397 | #if LUA_DEPRECATETFUNCS | 411 | #if LUA_DEPRECATETFUNCS |
| 398 | else if EQ("rawsetglobal") { | 412 | else if EQ("rawsetglobal") { |
