MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / luaV_objlen

Function luaV_objlen

lib/lua/src/lvm.c:700–726  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

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

Callers 2

luaV_executeFunction · 0.85
lua_lenFunction · 0.85

Calls 4

luaH_getnFunction · 0.85
luaT_gettmbyobjFunction · 0.85
luaG_typeerrorFunction · 0.85
luaT_callTMresFunction · 0.85

Tested by

no test coverage detected