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

Function luaV_objlen

third-party/lua-5.4.6/src/lvm.c:693–719  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

691** Main operation 'ra = #rb'.
692*/
693void luaV_objlen (lua_State *L, StkId ra, const TValue *rb) {
694 const TValue *tm;
695 switch (ttypetag(rb)) {
696 case LUA_VTABLE: {
697 Table *h = hvalue(rb);
698 tm = fasttm(L, h->metatable, TM_LEN);
699 if (tm) break; /* metamethod? break switch to call it */
700 setivalue(s2v(ra), luaH_getn(h)); /* else primitive len */
701 return;
702 }
703 case LUA_VSHRSTR: {
704 setivalue(s2v(ra), tsvalue(rb)->shrlen);
705 return;
706 }
707 case LUA_VLNGSTR: {
708 setivalue(s2v(ra), tsvalue(rb)->u.lnglen);
709 return;
710 }
711 default: { /* try metamethod */
712 tm = luaT_gettmbyobj(L, rb, TM_LEN);
713 if (l_unlikely(notm(tm))) /* no metamethod? */
714 luaG_typeerror(L, rb, "get length of");
715 break;
716 }
717 }
718 luaT_callTMres(L, tm, rb, rb, ra);
719}
720
721
722/*

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