aboutsummaryrefslogtreecommitdiff
path: root/ltm.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2023-11-07 17:26:15 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2023-11-07 17:26:15 -0300
commit37c215b43f27a1c41e8a920987e1c3bd7b34330d (patch)
treef14f4417384cffb9d2e5ef3c09621555a5d1e9a2 /ltm.c
parent9e99f3071d07767f9e882c4abf3537f75ce2d161 (diff)
parentfa075b79530af1cbc977349f2e467d69ce01202c (diff)
downloadlua-37c215b43f27a1c41e8a920987e1c3bd7b34330d.tar.gz
lua-37c215b43f27a1c41e8a920987e1c3bd7b34330d.tar.bz2
lua-37c215b43f27a1c41e8a920987e1c3bd7b34330d.zip
Merge branch 'newarray' into nextversion
Diffstat (limited to 'ltm.c')
-rw-r--r--ltm.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/ltm.c b/ltm.c
index 8e0d2222..c943bc7b 100644
--- a/ltm.c
+++ b/ltm.c
@@ -58,7 +58,7 @@ void luaT_init (lua_State *L) {
58** tag methods 58** tag methods
59*/ 59*/
60const TValue *luaT_gettm (Table *events, TMS event, TString *ename) { 60const TValue *luaT_gettm (Table *events, TMS event, TString *ename) {
61 const TValue *tm = luaH_getshortstr(events, ename); 61 const TValue *tm = luaH_Hgetshortstr(events, ename);
62 lua_assert(event <= TM_EQ); 62 lua_assert(event <= TM_EQ);
63 if (notm(tm)) { /* no tag method? */ 63 if (notm(tm)) { /* no tag method? */
64 events->flags |= cast_byte(1u<<event); /* cache this fact */ 64 events->flags |= cast_byte(1u<<event); /* cache this fact */
@@ -80,7 +80,7 @@ const TValue *luaT_gettmbyobj (lua_State *L, const TValue *o, TMS event) {
80 default: 80 default:
81 mt = G(L)->mt[ttype(o)]; 81 mt = G(L)->mt[ttype(o)];
82 } 82 }
83 return (mt ? luaH_getshortstr(mt, G(L)->tmname[event]) : &G(L)->nilvalue); 83 return (mt ? luaH_Hgetshortstr(mt, G(L)->tmname[event]) : &G(L)->nilvalue);
84} 84}
85 85
86 86
@@ -92,9 +92,10 @@ 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 const TValue *name = luaH_getshortstr(mt, luaS_new(L, "__name")); 95 TValue name;
96 if (ttisstring(name)) /* is '__name' a string? */ 96 int hres = luaH_getshortstr(mt, luaS_new(L, "__name"), &name);
97 return getstr(tsvalue(name)); /* use it as type name */ 97 if (hres == HOK && ttisstring(&name)) /* is '__name' a string? */
98 return getstr(tsvalue(&name)); /* use it as type name */
98 } 99 }
99 return ttypename(ttype(o)); /* else use standard type name */ 100 return ttypename(ttype(o)); /* else use standard type name */
100} 101}