summaryrefslogtreecommitdiff
path: root/lvm.c
diff options
context:
space:
mode:
Diffstat (limited to 'lvm.c')
-rw-r--r--lvm.c25
1 files changed, 16 insertions, 9 deletions
diff --git a/lvm.c b/lvm.c
index adc9019a..037d696e 100644
--- a/lvm.c
+++ b/lvm.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lvm.c,v 2.47 2005/06/13 14:15:22 roberto Exp roberto $ 2** $Id: lvm.c,v 2.48 2005/07/05 14:31:20 roberto Exp roberto $
3** Lua virtual machine 3** Lua virtual machine
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -548,14 +548,21 @@ StkId luaV_execute (lua_State *L, int nexeccalls) {
548 } 548 }
549 case OP_LEN: { 549 case OP_LEN: {
550 const TValue *rb = RB(i); 550 const TValue *rb = RB(i);
551 if (ttype(rb) == LUA_TTABLE) { 551 switch (ttype(rb)) {
552 setnvalue(ra, cast(lua_Number, luaH_getn(hvalue(rb)))); 552 case LUA_TTABLE: {
553 } 553 setnvalue(ra, cast(lua_Number, luaH_getn(hvalue(rb))));
554 else { /* try metamethod */ 554 break;
555 Protect( 555 }
556 if (!call_binTM(L, rb, &luaO_nilobject, ra, TM_LEN)) 556 case LUA_TSTRING: {
557 luaG_typeerror(L, rb, "get length of"); 557 setnvalue(ra, cast(lua_Number, tsvalue(rb)->len));
558 ) 558 break;
559 }
560 default: { /* try metamethod */
561 Protect(
562 if (!call_binTM(L, rb, &luaO_nilobject, ra, TM_LEN))
563 luaG_typeerror(L, rb, "get length of");
564 )
565 }
559 } 566 }
560 continue; 567 continue;
561 } 568 }