new operation *t (for size of t) (may yet be removed...)

This commit is contained in:
Roberto Ierusalimschy
2005-03-16 13:59:21 -03:00
parent 9ffae705ee
commit 04bbd01171
6 changed files with 47 additions and 15 deletions

17
lvm.c
View File

@@ -1,5 +1,5 @@
/*
** $Id: lvm.c,v 2.31 2005/03/08 20:10:05 roberto Exp roberto $
** $Id: lvm.c,v 2.32 2005/03/09 16:28:07 roberto Exp roberto $
** Lua virtual machine
** See Copyright Notice in lua.h
*/
@@ -562,6 +562,21 @@ StkId luaV_execute (lua_State *L, int nexeccalls) {
setbvalue(ra, res);
continue;
}
case OP_SIZ: {
const TValue *rb = RB(i);
switch (ttype(rb)) {
case LUA_TTABLE:
setnvalue(ra, cast(lua_Number, luaH_getn(hvalue(rb))));
break;
case LUA_TSTRING:
setnvalue(ra, cast(lua_Number, tsvalue(rb)->len));
break;
default: /* no metamethod?? */
L->ci->savedpc = pc;
luaG_typeerror(L, rb, "get the size of");
}
continue;
}
case OP_CONCAT: {
int b = GETARG_B(i);
int c = GETARG_C(i);