MCPcopy Create free account
hub / github.com/BigPig0/RelayLive / luaV_objlen

Function luaV_objlen

ThirdParty/lua/lua/lvm.c:404–426  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

402** Main operation 'ra' = #rb'.
403*/
404void luaV_objlen (lua_State *L, StkId ra, const TValue *rb) {
405 const TValue *tm;
406 switch (ttnov(rb)) {
407 case LUA_TTABLE: {
408 Table *h = hvalue(rb);
409 tm = fasttm(L, h->metatable, TM_LEN);
410 if (tm) break; /* metamethod? break switch to call it */
411 setivalue(ra, luaH_getn(h)); /* else primitive len */
412 return;
413 }
414 case LUA_TSTRING: {
415 setivalue(ra, tsvalue(rb)->len);
416 return;
417 }
418 default: { /* try metamethod */
419 tm = luaT_gettmbyobj(L, rb, TM_LEN);
420 if (ttisnil(tm)) /* no metamethod? */
421 luaG_typeerror(L, rb, "get length of");
422 break;
423 }
424 }
425 luaT_callTM(L, tm, rb, rb, ra, 1);
426}
427
428
429/*

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_callTMFunction · 0.85

Tested by

no test coverage detected