Skip to content

Commit b0f1c1f

Browse files
committed
[vm] Add rawiter() function
1 parent 8b4220c commit b0f1c1f

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

VM/src/lbaselib.cpp

+8-10
Original file line numberDiff line numberDiff line change
@@ -233,24 +233,20 @@ int luaB_next(lua_State* L)
233233
}
234234
}
235235

236-
/*
237-
static int luaB_nexti(lua_State *L)
236+
static int luaB_rawiter(lua_State *L)
238237
{
239238
luaL_checktype(L, 1, LUA_TTABLE);
240239
int i=luaL_optinteger(L,2,0);
241-
i=lua_nexti(L,1,i);
242-
if (i) {
240+
i=lua_rawiter(L,1,i);
241+
if (i>=0) {
243242
lua_pushinteger(L,i);
244243
return 3;
245244
}
246-
else
247-
{
248-
lua_pushnil(L);
249-
return 1;
250-
}
251-
lua_pushcclosure(L, luaB_nexti, "nexti", 1);
245+
lua_pushnil(L);
246+
return 1;
252247
}
253248

249+
/*
254250
static int pairsnexti(lua_State *L)
255251
{
256252
luaL_checktype(L, 1, LUA_TTABLE);
@@ -266,6 +262,7 @@ static int pairsnexti(lua_State *L)
266262
lua_pushnil(L);
267263
return 1;
268264
}
265+
lua_pushcclosure(L, luaB_nexti, "nexti", 1);
269266
}
270267
*/
271268

@@ -569,6 +566,7 @@ static const luaL_Reg base_funcs[] = {
569566
{"getfenv", luaB_getfenv},
570567
{"getmetatable", luaB_getmetatable},
571568
{"next", luaB_next},
569+
{"rawiter", luaB_rawiter},
572570
{"newproxy", luaB_newproxy},
573571
{"print", luaB_print},
574572
{"rawequal", luaB_rawequal},

0 commit comments

Comments
 (0)