MCPcopy Create free account
hub / github.com/F-Stack/f-stack / luaX_newstring

Function luaX_newstring

freebsd/contrib/openzfs/module/lua/llex.c:121–138  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

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

Callers 5

read_long_stringFunction · 0.70
read_stringFunction · 0.70
llexFunction · 0.70
anchor_tokenFunction · 0.70
new_localvarliteral_Function · 0.70

Calls 2

luaS_newlstrFunction · 0.70
luaH_setFunction · 0.70

Tested by

no test coverage detected