mirror of
https://github.com/lua/lua.git
synced 2025-02-04 06:13:04 +08:00
'objlen' can return integers
This commit is contained in:
parent
c75cca0559
commit
8c883cb4e8
6
lvm.c
6
lvm.c
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: lvm.c,v 2.168 2013/05/02 12:31:26 roberto Exp roberto $
|
** $Id: lvm.c,v 2.169 2013/05/06 17:17:09 roberto Exp roberto $
|
||||||
** Lua virtual machine
|
** Lua virtual machine
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@ -292,11 +292,11 @@ void luaV_objlen (lua_State *L, StkId ra, const TValue *rb) {
|
|||||||
Table *h = hvalue(rb);
|
Table *h = hvalue(rb);
|
||||||
tm = fasttm(L, h->metatable, TM_LEN);
|
tm = fasttm(L, h->metatable, TM_LEN);
|
||||||
if (tm) break; /* metamethod? break switch to call it */
|
if (tm) break; /* metamethod? break switch to call it */
|
||||||
setnvalue(ra, cast_num(luaH_getn(h))); /* else primitive len */
|
setivalue(ra, luaH_getn(h)); /* else primitive len */
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
case LUA_TSTRING: {
|
case LUA_TSTRING: {
|
||||||
setnvalue(ra, cast_num(tsvalue(rb)->len));
|
setivalue(ra, tsvalue(rb)->len);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
default: { /* try metamethod */
|
default: { /* try metamethod */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user