MCPcopy Create free account
hub / github.com/ObEngine/ObEngine / luaX_newstring

Function luaX_newstring

extlibs/lua/src/llex.c:130–147  ·  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

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

Callers 3

read_long_stringFunction · 0.85
read_stringFunction · 0.85
llexFunction · 0.85

Calls 2

luaS_newlstrFunction · 0.85
luaH_setFunction · 0.85

Tested by

no test coverage detected