`*' operator is primitive only for tables

This commit is contained in:
Roberto Ierusalimschy
2005-05-02 14:49:43 -03:00
parent 9832f6b186
commit 9b8d136e1c

21
lvm.c
View File

@@ -1,5 +1,5 @@
/* /*
** $Id: lvm.c,v 2.37 2005/04/05 13:41:29 roberto Exp roberto $ ** $Id: lvm.c,v 2.38 2005/04/11 18:01:29 roberto Exp roberto $
** Lua virtual machine ** Lua virtual machine
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@@ -527,9 +527,9 @@ StkId luaV_execute (lua_State *L, int nexeccalls) {
setnvalue(ra, luai_numunm(nb)); setnvalue(ra, luai_numunm(nb));
} }
else { else {
setnilvalue(&temp); rb = RB(i); /* `tonumber' erased `rb' */
if (!call_binTM(L, RB(i), &temp, ra, TM_UNM)) /***/ if (!call_binTM(L, rb, &luaO_nilobject, ra, TM_UNM)) /***/
luaG_aritherror(L, RB(i), &temp); luaG_aritherror(L, rb, &luaO_nilobject);
} }
continue; continue;
} }
@@ -540,15 +540,12 @@ StkId luaV_execute (lua_State *L, int nexeccalls) {
} }
case OP_SIZ: { case OP_SIZ: {
const TValue *rb = RB(i); const TValue *rb = RB(i);
switch (ttype(rb)) { if (ttype(rb) == LUA_TTABLE) {
case LUA_TTABLE:
setnvalue(ra, cast(lua_Number, luaH_getn(hvalue(rb)))); setnvalue(ra, cast(lua_Number, luaH_getn(hvalue(rb))));
break; }
case LUA_TSTRING: else { /* try metamethod */
setnvalue(ra, cast(lua_Number, tsvalue(rb)->len)); if (!call_binTM(L, rb, &luaO_nilobject, ra, TM_SIZ)) /***/
break; luaG_typeerror(L, rb, "get size of");
default: /* no metamethod?? */
luaG_typeerror(L, rb, "get the size of");
} }
continue; continue;
} }