MCPcopy Create free account
hub / github.com/DFHack/dfhack / dfhack_curry_wrap

Function dfhack_curry_wrap

library/LuaTools.cpp:1443–1461  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1441}
1442
1443static int dfhack_curry_wrap(lua_State *L)
1444{
1445 int nargs = lua_gettop(L);
1446 int ncurry = lua_tointeger(L, lua_upvalueindex(1));
1447 int scount = nargs + ncurry;
1448
1449 luaL_checkstack(L, ncurry, "stack overflow in curry");
1450
1451 // Insert values in O(N+M) by first shifting the existing data
1452 lua_settop(L, scount);
1453 for (int i = 0; i < nargs; i++)
1454 lua_copy(L, nargs-i, scount-i);
1455 for (int i = 1; i <= ncurry; i++)
1456 lua_copy(L, lua_upvalueindex(i+1), i);
1457
1458 lua_callk(L, scount-1, LUA_MULTRET, 0, gettop_wrapper);
1459
1460 return lua_gettop(L);
1461}
1462
1463static int dfhack_curry(lua_State *L)
1464{

Callers

nothing calls this directly

Calls 5

lua_gettopFunction · 0.85
luaL_checkstackFunction · 0.85
lua_settopFunction · 0.85
lua_copyFunction · 0.85
lua_callkFunction · 0.85

Tested by

no test coverage detected