MCPcopy Create free account
hub / github.com/SakuraEngine/SakuraEngine / lua_rotate

Function lua_rotate

xrepo/packages/l/lua/port/lua/src/lapi.c:245–256  ·  view source on GitHub ↗

** Let x = AB, where A is a prefix of length 'n'. Then, ** rotate x n == BA. But BA == (A^r . B^r)^r. */

Source from the content-addressed store, hash-verified

243** rotate x n == BA. But BA == (A^r . B^r)^r.
244*/
245LUA_API void lua_rotate (lua_State *L, int idx, int n) {
246 StkId p, t, m;
247 lua_lock(L);
248 t = L->top - 1; /* end of stack segment being rotated */
249 p = index2stack(L, idx); /* start of segment */
250 api_check(L, (n >= 0 ? n : -n) <= (t - p + 1), "invalid 'n'");
251 m = (n >= 0 ? t - n : p - n - 1); /* end of prefix */
252 reverse(L, p, m); /* reverse the prefix with length 'n' */
253 reverse(L, m + 1, t); /* reverse the suffix */
254 reverse(L, p, t); /* reverse the entire segment */
255 lua_unlock(L);
256}
257
258
259LUA_API void lua_copy (lua_State *L, int fromidx, int toidx) {

Callers 5

luaB_xpcallFunction · 0.85
ll_requireFunction · 0.85
aux_linesFunction · 0.85
treatstackoptionFunction · 0.85
db_getlocalFunction · 0.85

Calls 2

index2stackFunction · 0.85
reverseFunction · 0.70

Tested by

no test coverage detected