MCPcopy Create free account
hub / github.com/ObEngine/ObEngine / luaV_objlen

Function luaV_objlen

extlibs/lua/src/lvm.c:680–706  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

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

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