| 173 | |
| 174 | |
| 175 | LUA_API void lua_settop(lua_State *L, int idx) { |
| 176 | StkId func = L->ci->func; |
| 177 | lua_lock(L); |
| 178 | if (idx >= 0) { |
| 179 | api_check(L, idx <= L->stack_last - (func + 1), "new top too large"); |
| 180 | while (L->top < (func + 1) + idx) |
| 181 | setnilvalue(L->top++); |
| 182 | L->top = (func + 1) + idx; |
| 183 | } |
| 184 | else { |
| 185 | api_check(L, -(idx + 1) <= (L->top - (func + 1)), "invalid new top"); |
| 186 | L->top += idx + 1; /* 'subtract' index (index is negative) */ |
| 187 | } |
| 188 | lua_unlock(L); |
| 189 | } |
| 190 | |
| 191 | |
| 192 | /* |
no outgoing calls
no test coverage detected