From Lua 5.2: __len for tables. Needs -DLUAJIT_ENABLE_LUA52COMPAT.
This commit is contained in:
@@ -309,10 +309,19 @@ TValue * LJ_FASTCALL lj_meta_len(lua_State *L, cTValue *o)
|
||||
{
|
||||
cTValue *mo = lj_meta_lookup(L, o, MM_len);
|
||||
if (tvisnil(mo)) {
|
||||
lj_err_optype(L, o, LJ_ERR_OPLEN);
|
||||
return NULL; /* unreachable */
|
||||
#ifdef LUAJIT_ENABLE_LUA52COMPAT
|
||||
if (tvistab(o))
|
||||
tabref(tabV(o)->metatable)->nomm |= (uint8_t)(1u<<MM_len);
|
||||
else
|
||||
#endif
|
||||
lj_err_optype(L, o, LJ_ERR_OPLEN);
|
||||
return NULL;
|
||||
}
|
||||
#ifdef LUAJIT_ENABLE_LUA52COMPAT
|
||||
return mmcall(L, lj_cont_ra, mo, o, o);
|
||||
#else
|
||||
return mmcall(L, lj_cont_ra, mo, o, niltv(L));
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Helper for equality comparisons. __eq metamethod. */
|
||||
|
||||
Reference in New Issue
Block a user