MCPcopy Create free account
hub / github.com/EmmyLua/EmmyLuaDebugger / luaV_objlen

Function luaV_objlen

third-party/lua-5.2.4/src/lvm.c:335–357  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 2

luaV_executeFunction · 0.70
lua_lenFunction · 0.70

Calls 4

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

Tested by

no test coverage detected