MCPcopy Create free account
hub / github.com/EmmyLua/EmmyLuaDebugger / foreachi

Function foreachi

third-party/lua-5.1.5/src/ltablib.c:22–36  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

20
21
22static int foreachi (lua_State *L) {
23 int i;
24 int n = aux_getn(L, 1);
25 luaL_checktype(L, 2, LUA_TFUNCTION);
26 for (i=1; i <= n; i++) {
27 lua_pushvalue(L, 2); /* function */
28 lua_pushinteger(L, i); /* 1st argument */
29 lua_rawgeti(L, 1, i); /* 2nd argument */
30 lua_call(L, 2, 1);
31 if (!lua_isnil(L, -1))
32 return 1;
33 lua_pop(L, 1); /* remove nil result */
34 }
35 return 0;
36}
37
38
39static int foreach (lua_State *L) {

Callers

nothing calls this directly

Calls 5

luaL_checktypeFunction · 0.70
lua_pushvalueFunction · 0.70
lua_pushintegerFunction · 0.70
lua_rawgetiFunction · 0.70
lua_callFunction · 0.70

Tested by

no test coverage detected