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

Function lua_rotate

third-party/lua-5.5.0/src/lapi.c:238–250  ·  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

236** rotate x n == BA. But BA == (A^r . B^r)^r.
237*/
238LUA_API void lua_rotate (lua_State *L, int idx, int n) {
239 StkId p, t, m;
240 lua_lock(L);
241 t = L->top.p - 1; /* end of stack segment being rotated */
242 p = index2stack(L, idx); /* start of segment */
243 api_check(L, L->tbclist.p < p, "moving a to-be-closed slot");
244 api_check(L, (n >= 0 ? n : -n) <= (t - p + 1), "invalid 'n'");
245 m = (n >= 0 ? t - n : p - n - 1); /* end of prefix */
246 reverse(L, p, m); /* reverse the prefix with length 'n' */
247 reverse(L, m + 1, t); /* reverse the suffix */
248 reverse(L, p, t); /* reverse the entire segment */
249 lua_unlock(L);
250}
251
252
253LUA_API void lua_copy (lua_State *L, int fromidx, int toidx) {

Callers 5

luaB_xpcallFunction · 0.70
ll_requireFunction · 0.70
aux_linesFunction · 0.70
treatstackoptionFunction · 0.70
db_getlocalFunction · 0.70

Calls 2

index2stackFunction · 0.70
reverseFunction · 0.70

Tested by

no test coverage detected