MCPcopy Create free account
hub / github.com/EmmyLua/EmmyLuaDebugger / luaX_newstring

Function luaX_newstring

third-party/lua-5.2.4/src/llex.c:124–141  ·  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

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

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