diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2024-01-29 14:29:24 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2024-01-29 14:29:24 -0300 |
commit | c31d6774ac7db4cfbc548ce507ae65ab6036f873 (patch) | |
tree | 906369526757f8a26ad213ba571f18d58a9776ac /ltm.c | |
parent | 108e0bdc8495782544c351b17eaae1411a910e89 (diff) | |
download | lua-c31d6774ac7db4cfbc548ce507ae65ab6036f873.tar.gz lua-c31d6774ac7db4cfbc548ce507ae65ab6036f873.tar.bz2 lua-c31d6774ac7db4cfbc548ce507ae65ab6036f873.zip |
Details
Diffstat (limited to 'ltm.c')
-rw-r--r-- | ltm.c | 7 |
1 files changed, 3 insertions, 4 deletions
@@ -92,10 +92,9 @@ const char *luaT_objtypename (lua_State *L, const TValue *o) { | |||
92 | Table *mt; | 92 | Table *mt; |
93 | if ((ttistable(o) && (mt = hvalue(o)->metatable) != NULL) || | 93 | if ((ttistable(o) && (mt = hvalue(o)->metatable) != NULL) || |
94 | (ttisfulluserdata(o) && (mt = uvalue(o)->metatable) != NULL)) { | 94 | (ttisfulluserdata(o) && (mt = uvalue(o)->metatable) != NULL)) { |
95 | TValue name; | 95 | const TValue *name = luaH_Hgetshortstr(mt, luaS_new(L, "__name")); |
96 | int hres = luaH_getshortstr(mt, luaS_new(L, "__name"), &name); | 96 | if (ttisstring(name)) /* is '__name' a string? */ |
97 | if (hres == HOK && ttisstring(&name)) /* is '__name' a string? */ | 97 | return getstr(tsvalue(name)); /* use it as type name */ |
98 | return getstr(tsvalue(&name)); /* use it as type name */ | ||
99 | } | 98 | } |
100 | return ttypename(ttype(o)); /* else use standard type name */ | 99 | return ttypename(ttype(o)); /* else use standard type name */ |
101 | } | 100 | } |