MCPcopy Create free account
hub / github.com/Achain-Dev/Achain / luaV_objlen

Function luaV_objlen

src/Chain/libraries/glua/lvm.cpp:563–589  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

561** Main operation 'ra' = #rb'.
562*/
563void luaV_objlen(lua_State *L, StkId ra, const TValue *rb) {
564 const TValue *tm;
565 switch (ttype(rb)) {
566 case LUA_TTABLE: {
567 Table *h = hvalue(rb);
568 tm = fasttm(L, h->metatable, TM_LEN);
569 if (tm) break; /* metamethod? break switch to call it */
570 setivalue(ra, luaH_getn(h)); /* else primitive len */
571 return;
572 }
573 case LUA_TSHRSTR: {
574 setivalue(ra, tsvalue(rb)->shrlen);
575 return;
576 }
577 case LUA_TLNGSTR: {
578 setivalue(ra, tsvalue(rb)->u.lnglen);
579 return;
580 }
581 default: { /* try metamethod */
582 tm = luaT_gettmbyobj(L, rb, TM_LEN);
583 if (ttisnil(tm)) /* no metamethod? */
584 luaG_typeerror(L, rb, "get length of");
585 break;
586 }
587 }
588 luaT_callTM(L, tm, rb, rb, ra, 1);
589}
590
591
592/*

Callers 2

vmcaseFunction · 0.85
lua_lenFunction · 0.85

Calls 4

luaH_getnFunction · 0.85
luaT_gettmbyobjFunction · 0.85
luaG_typeerrorFunction · 0.85
luaT_callTMFunction · 0.85

Tested by

no test coverage detected