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

Function tunpack

third-party/lua-5.5.0/src/ltablib.c:205–219  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

203
204
205static int tunpack (lua_State *L) {
206 lua_Unsigned n;
207 lua_Integer i = luaL_optinteger(L, 2, 1);
208 lua_Integer e = luaL_opt(L, luaL_checkinteger, 3, luaL_len(L, 1));
209 if (i > e) return 0; /* empty range */
210 n = l_castS2U(e) - l_castS2U(i); /* number of elements minus 1 */
211 if (l_unlikely(n >= (unsigned int)INT_MAX ||
212 !lua_checkstack(L, (int)(++n))))
213 return luaL_error(L, "too many results to unpack");
214 for (; i < e; i++) { /* push arg[i..e - 1] (to avoid overflows) */
215 lua_geti(L, 1, i);
216 }
217 lua_geti(L, 1, e); /* push last element */
218 return (int)n;
219}
220
221/* }====================================================== */
222

Callers

nothing calls this directly

Calls 5

luaL_lenFunction · 0.85
luaL_optintegerFunction · 0.70
lua_checkstackFunction · 0.70
luaL_errorFunction · 0.70
lua_getiFunction · 0.70

Tested by

no test coverage detected