MCPcopy Create free account
hub / github.com/Overload-Technologies/Overload / luaV_objlen

Function luaV_objlen

Dependencies/lua/src/lvm.c:690–716  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

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

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