MCPcopy Create free account
hub / github.com/BigPig0/RelayLive / luaX_newstring

Function luaX_newstring

ThirdParty/lua/lua/llex.c:128–145  ·  view source on GitHub ↗

** creates a new string and anchors it in scanner's table so that ** it will not be collected until the end of the compilation ** (by that time it should be anchored somewhere) */

Source from the content-addressed store, hash-verified

126** (by that time it should be anchored somewhere)
127*/
128TString *luaX_newstring (LexState *ls, const char *str, size_t l) {
129 lua_State *L = ls->L;
130 TValue *o; /* entry for 'str' */
131 TString *ts = luaS_newlstr(L, str, l); /* create new string */
132 setsvalue2s(L, L->top++, ts); /* temporarily anchor it in stack */
133 o = luaH_set(L, ls->h, L->top - 1);
134 if (ttisnil(o)) { /* not in use yet? */
135 /* boolean value does not need GC barrier;
136 table has no metatable, so it does not need to invalidate cache */
137 setbvalue(o, 1); /* t[string] = true */
138 luaC_checkGC(L);
139 }
140 else { /* string already present */
141 ts = tsvalue(keyfromval(o)); /* re-use value previously stored */
142 }
143 L->top--; /* remove string from stack */
144 return ts;
145}
146
147
148/*

Callers 4

read_long_stringFunction · 0.85
read_stringFunction · 0.85
llexFunction · 0.85
new_localvarliteral_Function · 0.85

Calls 2

luaS_newlstrFunction · 0.85
luaH_setFunction · 0.85

Tested by

no test coverage detected