MCPcopy Create free account
hub / github.com/EmmyLua/EmmyLuaDebugger / luaV_objlen

Function luaV_objlen

third-party/lua-5.5.0/src/lvm.c:731–757  ·  view source on GitHub ↗

** Main operation 'ra = #rb'. */

Source from the content-addressed store, hash-verified

729** Main operation 'ra = #rb'.
730*/
731void luaV_objlen (lua_State *L, StkId ra, const TValue *rb) {
732 const TValue *tm;
733 switch (ttypetag(rb)) {
734 case LUA_VTABLE: {
735 Table *h = hvalue(rb);
736 tm = fasttm(L, h->metatable, TM_LEN);
737 if (tm) break; /* metamethod? break switch to call it */
738 setivalue(s2v(ra), l_castU2S(luaH_getn(L, h))); /* else primitive len */
739 return;
740 }
741 case LUA_VSHRSTR: {
742 setivalue(s2v(ra), tsvalue(rb)->shrlen);
743 return;
744 }
745 case LUA_VLNGSTR: {
746 setivalue(s2v(ra), cast_st2S(tsvalue(rb)->u.lnglen));
747 return;
748 }
749 default: { /* try metamethod */
750 tm = luaT_gettmbyobj(L, rb, TM_LEN);
751 if (l_unlikely(notm(tm))) /* no metamethod? */
752 luaG_typeerror(L, rb, "get length of");
753 break;
754 }
755 }
756 luaT_callTMres(L, tm, rb, rb, ra);
757}
758
759
760/*

Callers 2

luaV_executeFunction · 0.70
lua_lenFunction · 0.70

Calls 4

luaH_getnFunction · 0.70
luaT_gettmbyobjFunction · 0.70
luaG_typeerrorFunction · 0.70
luaT_callTMresFunction · 0.70

Tested by

no test coverage detected