From 03c6a05ec836c3a90a6b8d730120afdad39c092b Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Wed, 4 Apr 2018 11:23:41 -0300 Subject: no more nil-in-table --- ltm.c | 30 +----------------------------- 1 file changed, 1 insertion(+), 29 deletions(-) (limited to 'ltm.c') diff --git a/ltm.c b/ltm.c index 2a9a4cbe..6d285510 100644 --- a/ltm.c +++ b/ltm.c @@ -1,5 +1,5 @@ /* -** $Id: ltm.c,v 2.65 2018/02/26 14:16:05 roberto Exp roberto $ +** $Id: ltm.c,v 2.66 2018/02/27 17:48:28 roberto Exp roberto $ ** Tag methods ** See Copyright Notice in lua.h */ @@ -38,7 +38,6 @@ LUAI_DDEF const char *const luaT_typenames_[LUA_TOTALTAGS] = { void luaT_init (lua_State *L) { static const char *const luaT_eventname[] = { /* ORDER TM */ "__index", "__newindex", - "__undef", "__isdef", "__gc", "__mode", "__len", "__eq", "__add", "__sub", "__mul", "__mod", "__pow", "__div", "__idiv", @@ -250,30 +249,3 @@ void luaT_getvarargs (lua_State *L, CallInfo *ci, StkId where, int wanted) { setnilvalue(s2v(where + i)); } - -int luaT_keydef (lua_State *L, TValue *obj, TValue *key, int remove) { - const TValue *tm; - TMS event = remove ? TM_UNDEF : TM_ISDEF; - if (!ttistable(obj)) { /* not a table? */ - tm = luaT_gettmbyobj(L, obj, event); /* get its metamethod */ - if (notm(tm)) { /* no metamethod? */ - const char *msg = remove ? "remove key from" : "check key from"; - luaG_typeerror(L, obj, msg); /* error */ - } - /* else will call metamethod 'tm' */ - } - else { /* 'obj' is a table */ - Table *t = hvalue(obj); - tm = fasttm(L, t->metatable, event); - if (tm == NULL) { /* no metamethod? */ - const TValue *val = luaH_get(t, key); /* get entry */ - int res = !isempty(val); /* true if entry is not empty */ - if (remove && res) /* key is present and should be removed? */ - setempty(cast(TValue*, val)); /* remove it */ - return res; - } - /* else will call metamethod 'tm' */ - } - luaT_callTMres(L, tm, obj, key, L->top); - return !l_isfalse(s2v(L->top)); -} -- cgit v1.2.3-55-g6feb