MCPcopy Create free account
hub / github.com/BZFlag-Dev/bzflag / foldcap

Function foldcap

other_src/lua/src/lpeg.cpp:1999–2016  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1997
1998
1999static int foldcap (CapState *cs) {
2000 int n;
2001 lua_State *L = cs->L;
2002 int idx = cs->cap->idx;
2003 if (isfullcap(cs->cap++) || isclosecap(cs->cap) || (n = pushcapture(cs)) == 0)
2004 return luaL_error(L, "no initial value for fold capture");
2005 if (n > 1)
2006 lua_pop(L, n - 1); /* leave only one result */
2007 while (!isclosecap(cs->cap)) {
2008 updatecache(cs, idx);
2009 lua_pushvalue(L, subscache(cs)); /* get folding function */
2010 lua_insert(L, -2); /* put it before accumulator */
2011 n = pushcapture(cs); /* get other captures */
2012 lua_call(L, n + 1, 1); /* call folding function */
2013 }
2014 cs->cap++; /* skip close entry */
2015 return 1;
2016}
2017
2018
2019static int functioncap (CapState *cs) {

Callers 1

pushcaptureFunction · 0.85

Calls 5

pushcaptureFunction · 0.85
luaL_errorFunction · 0.70
lua_pushvalueFunction · 0.70
lua_insertFunction · 0.70
lua_callFunction · 0.70

Tested by

no test coverage detected