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

Function tmove

third-party/lua-5.5.0/src/ltablib.c:126–155  ·  view source on GitHub ↗

** Copy elements (1[f], ..., 1[e]) into (tt[t], tt[t+1], ...). Whenever ** possible, copy in increasing order, which is better for rehashing. ** "possible" means destination after original range, or smaller ** than origin, or copying to another table. */

Source from the content-addressed store, hash-verified

124** than origin, or copying to another table.
125*/
126static int tmove (lua_State *L) {
127 lua_Integer f = luaL_checkinteger(L, 2);
128 lua_Integer e = luaL_checkinteger(L, 3);
129 lua_Integer t = luaL_checkinteger(L, 4);
130 int tt = !lua_isnoneornil(L, 5) ? 5 : 1; /* destination table */
131 checktab(L, 1, TAB_R);
132 checktab(L, tt, TAB_W);
133 if (e >= f) { /* otherwise, nothing to move */
134 lua_Integer n, i;
135 luaL_argcheck(L, f > 0 || e < LUA_MAXINTEGER + f, 3,
136 "too many elements to move");
137 n = e - f + 1; /* number of elements to move */
138 luaL_argcheck(L, t <= LUA_MAXINTEGER - n + 1, 4,
139 "destination wrap around");
140 if (t > e || t <= f || (tt != 1 && !lua_compare(L, 1, tt, LUA_OPEQ))) {
141 for (i = 0; i < n; i++) {
142 lua_geti(L, 1, f + i);
143 lua_seti(L, tt, t + i);
144 }
145 }
146 else {
147 for (i = n - 1; i >= 0; i--) {
148 lua_geti(L, 1, f + i);
149 lua_seti(L, tt, t + i);
150 }
151 }
152 }
153 lua_pushvalue(L, tt); /* return destination table */
154 return 1;
155}
156
157
158static void addfield (lua_State *L, luaL_Buffer *b, lua_Integer i) {

Callers

nothing calls this directly

Calls 6

luaL_checkintegerFunction · 0.70
checktabFunction · 0.70
lua_compareFunction · 0.70
lua_getiFunction · 0.70
lua_setiFunction · 0.70
lua_pushvalueFunction · 0.70

Tested by

no test coverage detected