eris: add new API function lua_insert_frame

This commit is contained in:
2023-04-13 14:38:22 -04:00
parent 30155ae388
commit 4bcdcb103d
2 changed files with 18 additions and 0 deletions

View File

@@ -203,6 +203,23 @@ LUA_API void lua_insert (lua_State *L, int idx) {
} }
// Insert specified number of 'nil' at base of the stack.
LUA_API void lua_insert_frame (lua_State *L, int count) {
StkId p, q;
if (count > 0) {
lua_lock(L);
api_check(L, L->top + count <= L->stack_last, "Not enough space to insert frame");
p = L->ci->func + 1;
for (q = L->top - 1; q >= p; q--)
setobjs2s(L, q + count, q);
L->top += count;
for (q = p + count; p < q; p++)
setnilvalue(p);
lua_unlock(L);
}
}
static void moveto (lua_State *L, TValue *fr, int idx) { static void moveto (lua_State *L, TValue *fr, int idx) {
TValue *to = index2addr(L, idx); TValue *to = index2addr(L, idx);
api_checkvalidindex(L, to); api_checkvalidindex(L, to);

View File

@@ -147,6 +147,7 @@ LUA_API void (lua_settop) (lua_State *L, int idx);
LUA_API void (lua_pushvalue) (lua_State *L, int idx); LUA_API void (lua_pushvalue) (lua_State *L, int idx);
LUA_API void (lua_remove) (lua_State *L, int idx); LUA_API void (lua_remove) (lua_State *L, int idx);
LUA_API void (lua_insert) (lua_State *L, int idx); LUA_API void (lua_insert) (lua_State *L, int idx);
LUA_API void (lua_insert_frame) (lua_State *L, int count);
LUA_API void (lua_replace) (lua_State *L, int idx); LUA_API void (lua_replace) (lua_State *L, int idx);
LUA_API void (lua_copy) (lua_State *L, int fromidx, int toidx); LUA_API void (lua_copy) (lua_State *L, int fromidx, int toidx);
LUA_API int (lua_checkstack) (lua_State *L, int sz); LUA_API int (lua_checkstack) (lua_State *L, int sz);