MCPcopy Create free account
hub / github.com/F-Stack/f-stack / luaV_objlen

Function luaV_objlen

freebsd/contrib/openzfs/module/lua/lvm.c:336–358  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

334
335
336void luaV_objlen (lua_State *L, StkId ra, const TValue *rb) {
337 const TValue *tm;
338 switch (ttypenv(rb)) {
339 case LUA_TTABLE: {
340 Table *h = hvalue(rb);
341 tm = fasttm(L, h->metatable, TM_LEN);
342 if (tm) break; /* metamethod? break switch to call it */
343 setnvalue(ra, cast_num(luaH_getn(h))); /* else primitive len */
344 return;
345 }
346 case LUA_TSTRING: {
347 setnvalue(ra, cast_num(tsvalue(rb)->len));
348 return;
349 }
350 default: { /* try metamethod */
351 tm = luaT_gettmbyobj(L, rb, TM_LEN);
352 if (ttisnil(tm)) /* no metamethod? */
353 luaG_typeerror(L, rb, "get length of");
354 break;
355 }
356 }
357 callTM(L, tm, rb, rb, ra, 1);
358}
359
360/*
361 * luaV_div and luaV_mod patched in from Lua 5.3.2 in order to properly handle

Callers 2

luaV_executeFunction · 0.85
lua_lenFunction · 0.85

Calls 4

luaH_getnFunction · 0.70
luaT_gettmbyobjFunction · 0.70
luaG_typeerrorFunction · 0.70
callTMFunction · 0.70

Tested by

no test coverage detected