diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2023-11-07 17:26:15 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2023-11-07 17:26:15 -0300 |
commit | 37c215b43f27a1c41e8a920987e1c3bd7b34330d (patch) | |
tree | f14f4417384cffb9d2e5ef3c09621555a5d1e9a2 /ltm.c | |
parent | 9e99f3071d07767f9e882c4abf3537f75ce2d161 (diff) | |
parent | fa075b79530af1cbc977349f2e467d69ce01202c (diff) | |
download | lua-37c215b43f27a1c41e8a920987e1c3bd7b34330d.tar.gz lua-37c215b43f27a1c41e8a920987e1c3bd7b34330d.tar.bz2 lua-37c215b43f27a1c41e8a920987e1c3bd7b34330d.zip |
Merge branch 'newarray' into nextversion
Diffstat (limited to 'ltm.c')
-rw-r--r-- | ltm.c | 11 |
1 files changed, 6 insertions, 5 deletions
@@ -58,7 +58,7 @@ void luaT_init (lua_State *L) { | |||
58 | ** tag methods | 58 | ** tag methods |
59 | */ | 59 | */ |
60 | const TValue *luaT_gettm (Table *events, TMS event, TString *ename) { | 60 | const 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 | } |