diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2001-04-17 14:35:54 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2001-04-17 14:35:54 -0300 |
commit | beee01b170c5fea9ed4527b28b9221d2df1baaba (patch) | |
tree | 82263b6e128ffe09fe3da63de16c626522320dfc /ltests.c | |
parent | 6473f965ca699719b3b9908008f15da48cc2e6f1 (diff) | |
download | lua-beee01b170c5fea9ed4527b28b9221d2df1baaba.tar.gz lua-beee01b170c5fea9ed4527b28b9221d2df1baaba.tar.bz2 lua-beee01b170c5fea9ed4527b28b9221d2df1baaba.zip |
re-implementation of refs through weak tables
Diffstat (limited to 'ltests.c')
-rw-r--r-- | ltests.c | 15 |
1 files changed, 12 insertions, 3 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ltests.c,v 1.77 2001/03/26 14:31:49 roberto Exp roberto $ | 2 | ** $Id: ltests.c,v 1.78 2001/04/11 14:42: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 | */ |
@@ -383,21 +383,30 @@ static int string_query (lua_State *L) { | |||
383 | 383 | ||
384 | 384 | ||
385 | static int tref (lua_State *L) { | 385 | static int tref (lua_State *L) { |
386 | int level = lua_gettop(L); | ||
386 | luaL_checkany(L, 1); | 387 | luaL_checkany(L, 1); |
387 | lua_pushvalue(L, 1); | 388 | lua_pushvalue(L, 1); |
388 | lua_pushnumber(L, lua_ref(L, luaL_opt_int(L, 2, 1))); | 389 | lua_pushnumber(L, lua_ref(L, luaL_opt_int(L, 2, 1))); |
390 | assert(lua_gettop(L) == level+1); /* +1 for result */ | ||
389 | return 1; | 391 | return 1; |
390 | } | 392 | } |
391 | 393 | ||
392 | static int getref (lua_State *L) { | 394 | static int getref (lua_State *L) { |
393 | if (lua_getref(L, luaL_check_int(L, 1))) | 395 | int level = lua_gettop(L); |
396 | if (lua_getref(L, luaL_check_int(L, 1))) { | ||
397 | assert(lua_gettop(L) == level+1); | ||
394 | return 1; | 398 | return 1; |
395 | else | 399 | } |
400 | else { | ||
401 | assert(lua_gettop(L) == level); | ||
396 | return 0; | 402 | return 0; |
403 | } | ||
397 | } | 404 | } |
398 | 405 | ||
399 | static int unref (lua_State *L) { | 406 | static int unref (lua_State *L) { |
407 | int level = lua_gettop(L); | ||
400 | lua_unref(L, luaL_check_int(L, 1)); | 408 | lua_unref(L, luaL_check_int(L, 1)); |
409 | assert(lua_gettop(L) == level); | ||
401 | return 0; | 410 | return 0; |
402 | } | 411 | } |
403 | 412 | ||