MCPcopy Create free account
hub / github.com/CppCXY/EmmyLuaCodeStyle / auxsetstr

Function auxsetstr

3rd/lua-5.4.3/src/lapi.c:823–838  ·  view source on GitHub ↗

** t[k] = value at the top of the stack (where 'k' is a string) */

Source from the content-addressed store, hash-verified

821** t[k] = value at the top of the stack (where 'k' is a string)
822*/
823static void auxsetstr (lua_State *L, const TValue *t, const char *k) {
824 const TValue *slot;
825 TString *str = luaS_new(L, k);
826 api_checknelems(L, 1);
827 if (luaV_fastget(L, t, str, slot, luaH_getstr)) {
828 luaV_finishfastset(L, t, slot, s2v(L->top - 1));
829 L->top--; /* pop value */
830 }
831 else {
832 setsvalue2s(L, L->top, str); /* push 'str' (to make it a TValue) */
833 api_incr_top(L);
834 luaV_finishset(L, t, s2v(L->top - 1), s2v(L->top - 2), slot);
835 L->top -= 2; /* pop value and key */
836 }
837 lua_unlock(L); /* lock done by caller */
838}
839
840
841LUA_API void lua_setglobal (lua_State *L, const char *name) {

Callers 2

lua_setglobalFunction · 0.85
lua_setfieldFunction · 0.85

Calls 2

luaS_newFunction · 0.85
luaV_finishsetFunction · 0.85

Tested by

no test coverage detected