MCPcopy Create free account
hub / github.com/Achain-Dev/Achain / lua_rotate

Function lua_rotate

src/Chain/libraries/glua/lapi.cpp:210–222  ·  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

208** rotate x n == BA. But BA == (A^r . B^r)^r.
209*/
210LUA_API void lua_rotate(lua_State *L, int idx, int n) {
211 StkId p, t, m;
212 lua_lock(L);
213 t = L->top - 1; /* end of stack segment being rotated */
214 p = index2addr(L, idx); /* start of segment */
215 api_checkstackindex(L, idx, p);
216 api_check(L, (n >= 0 ? n : -n) <= (t - p + 1), "invalid 'n'");
217 m = (n >= 0 ? t - n : p - n - 1); /* end of prefix */
218 reverse(L, p, m); /* reverse the prefix with length 'n' */
219 reverse(L, m + 1, t); /* reverse the suffix */
220 reverse(L, p, t); /* reverse the entire segment */
221 lua_unlock(L);
222}
223
224
225LUA_API void lua_copy(lua_State *L, int fromidx, int toidx) {

Callers 4

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

Calls 2

index2addrFunction · 0.85
reverseFunction · 0.70

Tested by

no test coverage detected