#string is primitive
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: lstrlib.c,v 1.119 2005/07/12 14:32:08 roberto Exp $
|
** $Id: lstrlib.c,v 1.120 2005/07/31 16:47:34 roberto Exp roberto $
|
||||||
** Standard library for string operations and pattern-matching
|
** Standard library for string operations and pattern-matching
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@@ -810,8 +810,6 @@ static void createmetatable (lua_State *L) {
|
|||||||
lua_pop(L, 1); /* pop dummy string */
|
lua_pop(L, 1); /* pop dummy string */
|
||||||
lua_pushvalue(L, -2); /* string library... */
|
lua_pushvalue(L, -2); /* string library... */
|
||||||
lua_setfield(L, -2, "__index"); /* ...is the __index metamethod */
|
lua_setfield(L, -2, "__index"); /* ...is the __index metamethod */
|
||||||
lua_getfield(L, -2, "len");
|
|
||||||
lua_setfield(L, -2, "__len");
|
|
||||||
lua_pop(L, 1); /* pop metatable */
|
lua_pop(L, 1); /* pop metatable */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
13
lvm.c
13
lvm.c
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: lvm.c,v 2.47 2005/06/13 14:15:22 roberto Exp roberto $
|
** $Id: lvm.c,v 2.48 2005/07/05 14:31:20 roberto Exp roberto $
|
||||||
** Lua virtual machine
|
** Lua virtual machine
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@@ -548,15 +548,22 @@ StkId luaV_execute (lua_State *L, int nexeccalls) {
|
|||||||
}
|
}
|
||||||
case OP_LEN: {
|
case OP_LEN: {
|
||||||
const TValue *rb = RB(i);
|
const TValue *rb = RB(i);
|
||||||
if (ttype(rb) == LUA_TTABLE) {
|
switch (ttype(rb)) {
|
||||||
|
case LUA_TTABLE: {
|
||||||
setnvalue(ra, cast(lua_Number, luaH_getn(hvalue(rb))));
|
setnvalue(ra, cast(lua_Number, luaH_getn(hvalue(rb))));
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
else { /* try metamethod */
|
case LUA_TSTRING: {
|
||||||
|
setnvalue(ra, cast(lua_Number, tsvalue(rb)->len));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default: { /* try metamethod */
|
||||||
Protect(
|
Protect(
|
||||||
if (!call_binTM(L, rb, &luaO_nilobject, ra, TM_LEN))
|
if (!call_binTM(L, rb, &luaO_nilobject, ra, TM_LEN))
|
||||||
luaG_typeerror(L, rb, "get length of");
|
luaG_typeerror(L, rb, "get length of");
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
case OP_CONCAT: {
|
case OP_CONCAT: {
|
||||||
|
|||||||
Reference in New Issue
Block a user