Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/compiler/llex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ void luaX_init (lua_State *L) {
TString *e = luaS_newliteral(L, LUA_ENV); /* create env name */
obj2gco(e)->fix(L); /* Phase 25c: never collect this name */
for (int i=0; i<NUM_RESERVED; i++) {
TString *ts = luaS_new(L, luaX_tokens[i]);
TString *ts = TString::create(L, luaX_tokens[i]);
obj2gco(ts)->fix(L); /* Phase 25c: reserved words are never collected */
ts->setExtra(cast_byte(i+1)); /* reserved word */
}
Expand Down Expand Up @@ -138,7 +138,7 @@ TString* LexState::anchorStr(TString *ts) {
** Creates a new string and anchors it in scanner's table.
*/
TString *LexState::newString(const char *str, size_t l) {
return anchorStr(luaS_newlstr(getLuaState(), str, l));
return anchorStr(TString::create(getLuaState(), str, l));
}

/*
Expand Down Expand Up @@ -542,7 +542,7 @@ int LexState::lex(SemInfo *seminfo) {
saveAndNext();
} while (lislalnum(getCurrentChar()));
/* find or create string */
ts = luaS_newlstr(getLuaState(), luaZ_buffer(getBuffer()),
ts = TString::create(getLuaState(), luaZ_buffer(getBuffer()),
luaZ_bufflen(getBuffer()));
if (isreserved(ts)) /* reserved word? */
return ts->getExtra() - 1 + FIRST_RESERVED;
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/parseutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ LClosure *luaY_parser (lua_State *L, ZIO *z, Mbuffer *buff,
funcstate.setProto(luaF_newproto(L));
cl->setProto(funcstate.getProto());
luaC_objbarrier(L, cl, cl->getProto());
funcstate.getProto()->setSource(luaS_new(L, name)); /* create and anchor TString */
funcstate.getProto()->setSource(TString::create(L, name)); /* create and anchor TString */
luaC_objbarrier(L, funcstate.getProto(), funcstate.getProto()->getSource());
lexstate.setBuffer(buff);
lexstate.setDyndata(dyd);
Expand Down
12 changes: 6 additions & 6 deletions src/core/lapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ LUA_API void lua_pushinteger (lua_State *L, lua_Integer n) {
LUA_API const char *lua_pushlstring (lua_State *L, const char *s, size_t len) {
TString *ts;
lua_lock(L);
ts = (len == 0) ? luaS_new(L, "") : luaS_newlstr(L, s, len);
ts = (len == 0) ? TString::create(L, "") : TString::create(L, s, len);
setsvalue2s(L, L->getTop().p, ts);
api_incr_top(L);
luaC_checkGC(L);
Expand All @@ -504,7 +504,7 @@ LUA_API const char *lua_pushexternalstring (lua_State *L,
lua_lock(L);
api_check(L, len <= MAX_SIZE, "string too large");
api_check(L, s[len] == '\0', "string not ending with zero");
ts = luaS_newextlstr (L, s, len, falloc, ud);
ts = TString::createExternal(L, s, len, falloc, ud);
setsvalue2s(L, L->getTop().p, ts);
api_incr_top(L);
luaC_checkGC(L);
Expand All @@ -519,7 +519,7 @@ LUA_API const char *lua_pushstring (lua_State *L, const char *s) {
setnilvalue(s2v(L->getTop().p));
else {
TString *ts;
ts = luaS_new(L, s);
ts = TString::create(L, s);
setsvalue2s(L, L->getTop().p, ts);
s = getstr(ts); /* internal copy's address */
}
Expand Down Expand Up @@ -613,7 +613,7 @@ LUA_API int lua_pushthread (lua_State *L) {

static int auxgetstr (lua_State *L, const TValue *t, const char *k) {
lu_byte tag;
TString *str = luaS_new(L, k);
TString *str = TString::create(L, k);
tag = luaV_fastget(t, str, s2v(L->getTop().p), luaH_getstr);
if (!tagisempty(tag))
api_incr_top(L);
Expand Down Expand Up @@ -794,7 +794,7 @@ LUA_API int lua_getiuservalue (lua_State *L, int idx, int n) {
*/
static void auxsetstr (lua_State *L, const TValue *t, const char *k) {
int hres;
TString *str = luaS_new(L, k);
TString *str = TString::create(L, k);
api_checkpop(L, 1);
hres = luaV_fastset(t, str, s2v(L->getTop().p - 1), luaH_psetstr);
if (hres == HOK) {
Expand Down Expand Up @@ -1225,7 +1225,7 @@ LUA_API void lua_concat (lua_State *L, int n) {
luaC_checkGC(L);
}
else { /* nothing to concatenate */
setsvalue2s(L, L->getTop().p, luaS_newlstr(L, "", 0)); /* push empty string */
setsvalue2s(L, L->getTop().p, TString::create(L, "", 0)); /* push empty string */
api_incr_top(L);
}
lua_unlock(L);
Expand Down
2 changes: 1 addition & 1 deletion src/core/ldebug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -895,7 +895,7 @@ l_noret lua_State::errorMsg() {
}
if (ttisnil(s2v(getTop().p - 1))) { /* error object is nil? */
/* change it to a proper message */
setsvalue2s(this, getTop().p - 1, luaS_newliteral(this, "<no error object>"));
setsvalue2s(this, getTop().p - 1, TString::create(this, "<no error object>", 17));
}
doThrow(LUA_ERRRUN);
}
Expand Down
4 changes: 2 additions & 2 deletions src/core/ldo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ TStatus lua_State::rawRunProtected(Pfunc f, void *ud) {
/* raise a stack error while running the message handler */
// Convert to lua_State method
l_noret lua_State::errorError() {
TString *msg = luaS_newliteral(this, "error in error handling");
TString *msg = TString::create(this, "error in error handling", 23);
setsvalue2s(this, getTop().p, msg);
getStackSubsystem().push(); /* assume EXTRA_STACK */
doThrow(LUA_ERRERR);
Expand Down Expand Up @@ -826,7 +826,7 @@ CallInfo* lua_State::findPCall() {
static int resume_error (lua_State *L, const char *msg, int narg) {
api_checkpop(L, narg);
L->getStackSubsystem().popN(narg); /* remove args from the stack */
setsvalue2s(L, L->getTop().p, luaS_new(L, msg)); /* push error message */
setsvalue2s(L, L->getTop().p, TString::create(L, msg)); /* push error message */
api_incr_top(L);
lua_unlock(L);
return LUA_ERRRUN;
Expand Down
2 changes: 1 addition & 1 deletion src/core/lstate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ static void f_luaopen (lua_State *L, void *ud) {
UNUSED(ud);
stack_init(L, L); /* init stack */
init_registry(L, g);
luaS_init(L);
TString::init(L);
luaT_init(L);
luaX_init(L);
g->setGCStp(0); /* allow gc */
Expand Down
4 changes: 2 additions & 2 deletions src/core/ltm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ void luaT_init (lua_State *L) {
};
int i;
for (i=0; i<static_cast<int>(TMS::TM_N); i++) {
G(L)->setTMName(i, luaS_new(L, luaT_eventname[i]));
G(L)->setTMName(i, TString::create(L, luaT_eventname[i]));
obj2gco(G(L)->getTMName(i))->fix(L); /* never collect these names */
}
}
Expand Down Expand Up @@ -93,7 +93,7 @@ const char *luaT_objtypename (lua_State *L, const TValue *o) {
Table *mt;
if ((ttistable(o) && (mt = hvalue(o)->getMetatable()) != nullptr) ||
(ttisfulluserdata(o) && (mt = uvalue(o)->getMetatable()) != nullptr)) {
const TValue *name = luaH_Hgetshortstr(mt, luaS_new(L, "__name"));
const TValue *name = luaH_Hgetshortstr(mt, TString::create(L, "__name"));
if (ttisstring(name)) /* is '__name' a string? */
return getstr(tsvalue(name)); /* use it as type name */
}
Expand Down
2 changes: 1 addition & 1 deletion src/memory/gc/gc_collector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ void GCCollector::atomic(lua_State* L) {
/* clear values from resurrected weak tables */
GCWeak::clearbyvalues(g, g->getWeak(), origweak);
GCWeak::clearbyvalues(g, g->getAllWeak(), origall);
luaS_clearcache(g);
TString::clearCache(g);
g->setCurrentWhite(cast_byte(otherwhite(g))); /* flip current white */
lua_assert(g->getGray() == nullptr);
}
Expand Down
2 changes: 1 addition & 1 deletion src/memory/gc/gc_core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ l_mem GCCore::objsize(GCObject* o) {
}
case LUA_VLNGSTR: {
TString* ts = gco2ts(o);
res = luaS_sizelngstr(ts->getLnglen(), ts->getShrlen());
res = TString::calculateLongStringSize(ts->getLnglen(), ts->getShrlen());
break;
}
case LUA_VUPVAL: {
Expand Down
2 changes: 1 addition & 1 deletion src/memory/gc/gc_finalizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
void GCFinalizer::checkSizes(lua_State* L, global_State* g) {
if (!g->getGCEmergency()) {
if (g->getStringTable()->getNumElements() < g->getStringTable()->getSize() / 4)
luaS_resize(L, g->getStringTable()->getSize() / 2);
TString::resize(L, g->getStringTable()->getSize() / 2);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/memory/lgc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ void freeobj (lua_State *L, GCObject *o) {
if (ts->getShrlen() == LSTRMEM) /* must free external string? */
(*ts->getFalloc())(ts->getUserData(), ts->getContentsField(), ts->getLnglen() + 1, 0);
ts->~TString(); // Call destructor
luaM_freemem(L, ts, luaS_sizelngstr(ts->getLnglen(), ts->getShrlen()));
luaM_freemem(L, ts, TString::calculateLongStringSize(ts->getLnglen(), ts->getShrlen()));
break;
}
default: lua_assert(0);
Expand Down
4 changes: 2 additions & 2 deletions src/objects/lobject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ unsigned luaO_tostringbuff (const TValue *obj, char *buff) {
void luaO_tostring (lua_State *L, TValue *obj) {
char buff[LUA_N2SBUFFSZ];
unsigned len = luaO_tostringbuff(obj, buff);
setsvalue(L, obj, luaS_newlstr(L, buff, len));
setsvalue(L, obj, TString::create(L, buff, len));
}


Expand Down Expand Up @@ -519,7 +519,7 @@ static void pushbuff (lua_State *L, void *ud) {
}
/* FALLTHROUGH */
default: { /* no errors, but it can raise one creating the new string */
TString *ts = luaS_newlstr(L, buff->b, buff->blen);
TString *ts = TString::create(L, buff->b, buff->blen);
setsvalue2s(L, L->getTop().p, ts);
L->getStackSubsystem().push();
}
Expand Down
Loading
Loading