diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2010-04-14 12:13:48 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2010-04-14 12:13:48 -0300 |
commit | 7dfa4cd655118faf164427356609fec31906dac2 (patch) | |
tree | d39fac9afba1dc0ab01dd5d174824120650c9eab /ltests.c | |
parent | fc6203ee4308173283f9ad9de6694d47f0908c4d (diff) | |
download | lua-7dfa4cd655118faf164427356609fec31906dac2.tar.gz lua-7dfa4cd655118faf164427356609fec31906dac2.tar.bz2 lua-7dfa4cd655118faf164427356609fec31906dac2.zip |
first implementation of light C functions
Diffstat (limited to 'ltests.c')
-rw-r--r-- | ltests.c | 9 |
1 files changed, 6 insertions, 3 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ltests.c,v 2.92 2010/04/12 12:42:07 roberto Exp roberto $ | 2 | ** $Id: ltests.c,v 2.93 2010/04/12 16:07:39 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 | */ |
@@ -191,7 +191,7 @@ static void printobj (global_State *g, GCObject *o) { | |||
191 | GCObject *p; | 191 | GCObject *p; |
192 | for (p = g->allgc; p != o && p != NULL; p = gch(p)->next) i++; | 192 | for (p = g->allgc; p != o && p != NULL; p = gch(p)->next) i++; |
193 | if (p == NULL) i = -1; | 193 | if (p == NULL) i = -1; |
194 | printf("%d:%s(%p)-%c(%02X)", i, typename(gch(o)->tt), (void *)o, | 194 | printf("%d:%s(%p)-%c(%02X)", i, ttypename(gch(o)->tt), (void *)o, |
195 | isdead(g,o)?'d':isblack(o)?'b':iswhite(o)?'w':'g', gch(o)->marked); | 195 | isdead(g,o)?'d':isblack(o)?'b':iswhite(o)?'w':'g', gch(o)->marked); |
196 | } | 196 | } |
197 | 197 | ||
@@ -519,7 +519,7 @@ static int mem_query (lua_State *L) { | |||
519 | const char *t = luaL_checkstring(L, 1); | 519 | const char *t = luaL_checkstring(L, 1); |
520 | int i; | 520 | int i; |
521 | for (i = LUA_NUMTAGS - 1; i >= 0; i--) { | 521 | for (i = LUA_NUMTAGS - 1; i >= 0; i--) { |
522 | if (strcmp(t, typename(i)) == 0) { | 522 | if (strcmp(t, ttypename(i)) == 0) { |
523 | lua_pushinteger(L, l_memcontrol.objcount[i]); | 523 | lua_pushinteger(L, l_memcontrol.objcount[i]); |
524 | return 1; | 524 | return 1; |
525 | } | 525 | } |
@@ -944,6 +944,9 @@ static int runC (lua_State *L, lua_State *L1, const char *pc) { | |||
944 | else if EQ("tonumber") { | 944 | else if EQ("tonumber") { |
945 | lua_pushnumber(L1, lua_tonumber(L1, getindex)); | 945 | lua_pushnumber(L1, lua_tonumber(L1, getindex)); |
946 | } | 946 | } |
947 | else if EQ("topointer") { | ||
948 | lua_pushlightuserdata(L1, cast(void *, lua_topointer(L1, getindex))); | ||
949 | } | ||
947 | else if EQ("tostring") { | 950 | else if EQ("tostring") { |
948 | const char *s = lua_tostring(L1, getindex); | 951 | const char *s = lua_tostring(L1, getindex); |
949 | const char *s1 = lua_pushstring(L1, s); | 952 | const char *s1 = lua_pushstring(L1, s); |