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
12 changes: 6 additions & 6 deletions src/compiler/lcode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ static int tonumeral (const expdesc *e, TValue *v) {
return 0; /* not a numeral */
switch (e->getKind()) {
case VKINT:
if (v) setivalue(v, e->getIntValue());
if (v) v->setInt(e->getIntValue());
return 1;
case VKFLT:
if (v) setfltvalue(v, e->getFloatValue());
if (v) v->setFloat(e->getFloatValue());
return 1;
default: return 0;
}
Expand Down Expand Up @@ -348,7 +348,7 @@ int FuncState::k2proto(TValue *key, TValue *v) {
int k = addk(proto, v);
/* cache it for reuse; numerical value does not need GC barrier;
table is not a metatable, so it does not need to invalidate cache */
setivalue(&val, k);
val.setInt(k);
luaH_set(getLexState()->getLuaState(), getKCache(), key, &val);
return k;
}
Expand All @@ -368,7 +368,7 @@ int FuncState::stringK(TString *s) {
*/
int FuncState::intK(lua_Integer n) {
TValue o;
setivalue(&o, n);
o.setInt(n);
return k2proto(&o, &o); /* use integer itself as key */
}

Expand All @@ -386,7 +386,7 @@ int FuncState::intK(lua_Integer n) {
*/
int FuncState::numberK(lua_Number r) {
TValue o, kv;
setfltvalue(&o, r); /* value as a TValue */
o.setFloat(r); /* value as a TValue */
if (r == 0) { /* handle zero as a special case */
setpvalue(&kv, this); /* use FuncState as index */
return k2proto(&kv, &o); /* cannot collide */
Expand All @@ -396,7 +396,7 @@ int FuncState::numberK(lua_Number r) {
const lua_Number q = l_mathop(ldexp)(l_mathop(1.0), -nbm + 1);
const lua_Number k = r * (1 + q); /* key */
lua_Integer ik;
setfltvalue(&kv, k); /* key as a TValue */
kv.setFloat(k); /* key as a TValue */
if (!luaV_flttointeger(k, &ik, F2Imod::F2Ieq)) { /* not an integer value? */
int n = k2proto(&kv, &o); /* use key */
if (luaV_rawequalobj(&getProto()->getConstants()[n], &o)) /* correct value? */
Expand Down
8 changes: 4 additions & 4 deletions src/core/lapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -467,15 +467,15 @@ LUA_API void lua_pushnil (lua_State *L) {

LUA_API void lua_pushnumber (lua_State *L, lua_Number n) {
lua_lock(L);
setfltvalue(s2v(L->getTop().p), n);
s2v(L->getTop().p)->setFloat(n);
api_incr_top(L);
lua_unlock(L);
}


LUA_API void lua_pushinteger (lua_State *L, lua_Integer n) {
lua_lock(L);
setivalue(s2v(L->getTop().p), n);
s2v(L->getTop().p)->setInt(n);
api_incr_top(L);
lua_unlock(L);
}
Expand Down Expand Up @@ -673,7 +673,7 @@ LUA_API int lua_geti (lua_State *L, int idx, lua_Integer n) {
luaV_fastgeti(t, n, s2v(L->getTop().p), tag);
if (tagisempty(tag)) {
TValue key;
setivalue(&key, n);
key.setInt(n);
tag = luaV_finishget(L, t, &key, L->getTop().p, tag);
}
api_incr_top(L);
Expand Down Expand Up @@ -849,7 +849,7 @@ LUA_API void lua_seti (lua_State *L, int idx, lua_Integer n) {
luaV_finishfastset(L, t, s2v(L->getTop().p - 1));
else {
TValue temp;
setivalue(&temp, n);
temp.setInt(n);
luaV_finishset(L, t, &temp, s2v(L->getTop().p - 1), hres);
}
L->getStackSubsystem().pop(); /* pop value */
Expand Down
2 changes: 1 addition & 1 deletion src/core/lstate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ LUA_API lua_State *lua_newstate (lua_Alloc f, void *ud, unsigned seed) {
g->setGCTotalBytes(sizeof(global_State));
g->setGCMarked(0);
g->setGCDebt(0);
setivalue(g->getNilValue(), 0); /* to signal that state is not yet built */
g->getNilValue()->setInt(0); /* to signal that state is not yet built */
setgcparam(g, PAUSE, LUAI_GCPAUSE);
setgcparam(g, STEPMUL, LUAI_GCMUL);
setgcparam(g, STEPSIZE, LUAI_GCSTEPSIZE);
Expand Down
6 changes: 3 additions & 3 deletions src/core/ltm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ void luaT_trybinassocTM (lua_State *L, const TValue *p1, const TValue *p2,
void luaT_trybiniTM (lua_State *L, const TValue *p1, lua_Integer i2,
int flip, StkId res, TMS event) {
TValue aux;
setivalue(&aux, i2);
aux.setInt(i2);
luaT_trybinassocTM(L, p1, &aux, flip, res, event);
}

Expand All @@ -212,10 +212,10 @@ int luaT_callorderiTM (lua_State *L, const TValue *p1, int v2,
int flip, int isfloat, TMS event) {
TValue aux; const TValue *p2;
if (isfloat) {
setfltvalue(&aux, cast_num(v2));
aux.setFloat(cast_num(v2));
}
else
setivalue(&aux, v2);
aux.setInt(v2);
if (flip) { /* arguments were exchanged? */
p2 = p1; p1 = &aux; /* correct them */
}
Expand Down
18 changes: 9 additions & 9 deletions src/objects/lobject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,27 +159,27 @@ int luaO_rawarith (lua_State *L, int op, const TValue *p1, const TValue *p2,
case LUA_OPBNOT: { /* operate only on integers */
lua_Integer i1; lua_Integer i2;
if (tointegerns(p1, &i1) && tointegerns(p2, &i2)) {
setivalue(res, intarith(L, op, i1, i2));
res->setInt(intarith(L, op, i1, i2));
return 1;
}
else return 0; /* fail */
}
case LUA_OPDIV: case LUA_OPPOW: { /* operate only on floats */
lua_Number n1; lua_Number n2;
if (tonumberns(p1, n1) && tonumberns(p2, n2)) {
setfltvalue(res, numarith(L, op, n1, n2));
res->setFloat(numarith(L, op, n1, n2));
return 1;
}
else return 0; /* fail */
}
default: { /* other operations */
lua_Number n1; lua_Number n2;
if (ttisinteger(p1) && ttisinteger(p2)) {
setivalue(res, intarith(L, op, ivalue(p1), ivalue(p2)));
res->setInt(intarith(L, op, ivalue(p1), ivalue(p2)));
return 1;
}
else if (tonumberns(p1, n1) && tonumberns(p2, n2)) {
setfltvalue(res, numarith(L, op, n1, n2));
res->setFloat(numarith(L, op, n1, n2));
return 1;
}
else return 0; /* fail */
Expand Down Expand Up @@ -372,10 +372,10 @@ size_t luaO_str2num (const char *s, TValue *o) {
lua_Integer i; lua_Number n;
const char *e;
if ((e = l_str2int(s, &i)) != nullptr) { /* try as an integer */
setivalue(o, i);
o->setInt(i);
}
else if ((e = l_str2d(s, &n)) != nullptr) { /* else try as a float */
setfltvalue(o, n);
o->setFloat(n);
}
else
return 0; /* conversion failed */
Expand Down Expand Up @@ -608,19 +608,19 @@ const char *luaO_pushvfstring (lua_State *L, const char *fmt, va_list argp) {
}
case 'd': { /* an 'int' */
TValue num;
setivalue(&num, va_arg(argp, int));
num.setInt(va_arg(argp, int));
addnum2buff(&buff, &num);
break;
}
case 'I': { /* a 'lua_Integer' */
TValue num;
setivalue(&num, cast_Integer(va_arg(argp, l_uacInt)));
num.setInt(cast_Integer(va_arg(argp, l_uacInt)));
addnum2buff(&buff, &num);
break;
}
case 'f': { /* a 'lua_Number' */
TValue num;
setfltvalue(&num, cast_num(va_arg(argp, l_uacNumber)));
num.setFloat(cast_num(va_arg(argp, l_uacNumber)));
addnum2buff(&buff, &num);
break;
}
Expand Down
5 changes: 0 additions & 5 deletions src/objects/lobject_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -192,11 +192,6 @@ inline lua_Integer ivalue(const TValue* o) noexcept { return o->intValue(); }
constexpr lua_Number fltvalueraw(const Value& v) noexcept { return v.n; }
constexpr lua_Integer ivalueraw(const Value& v) noexcept { return v.i; }

inline void setfltvalue(TValue* obj, lua_Number x) noexcept { obj->setFloat(x); }
inline void chgfltvalue(TValue* obj, lua_Number x) noexcept { obj->changeFloat(x); }
inline void setivalue(TValue* obj, lua_Integer x) noexcept { obj->setInt(x); }
inline void chgivalue(TValue* obj, lua_Integer x) noexcept { obj->changeInt(x); }

/* }================================================================== */


Expand Down
8 changes: 4 additions & 4 deletions src/objects/ltable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ int luaH_next (lua_State *L, Table *t, StkId key) {
for (; i < asize; i++) { /* try first array part */
lu_byte tag = *t->getArrayTag(i);
if (!tagisempty(tag)) { /* a non-empty entry? */
setivalue(s2v(key), cast_int(i) + 1);
s2v(key)->setInt(cast_int(i) + 1);
farr2val(t, i, tag, s2v(key + 1));
return 1;
}
Expand Down Expand Up @@ -816,7 +816,7 @@ static void reinsertOldSlice (Table *t, unsigned oldasize,
lu_byte tag = *t->getArrayTag(i);
if (!tagisempty(tag)) { /* a non-empty entry? */
TValue key, aux;
setivalue(&key, l_castU2S(i) + 1); /* make the key */
key.setInt(l_castU2S(i) + 1); /* make the key */
farr2val(t, i, tag, &aux); /* copy value into 'aux' */
insertkey(t, &key, &aux); /* insert entry into the hash part */
}
Expand Down Expand Up @@ -1513,7 +1513,7 @@ void Table::setInt(lua_State* L, lua_Integer key, TValue* value) {
bool ok = rawfinishnodeset(getintfromhash(this, key), value);
if (!ok) {
TValue k;
setivalue(&k, key);
k.setInt(key);
luaH_newkey(L, this, &k, value);
}
}
Expand All @@ -1529,7 +1529,7 @@ void Table::finishSet(lua_State* L, const TValue* key, TValue* value, int hres)
lua_Number f = fltvalue(key);
lua_Integer k;
if (luaV_flttointeger(f, &k, F2Imod::F2Ieq)) {
setivalue(&aux, k); /* key is equal to an integer */
aux.setInt(k); /* key is equal to an integer */
key = &aux; /* insert it as an integer */
}
else if (l_unlikely(luai_numisnan(f)))
Expand Down
2 changes: 1 addition & 1 deletion src/serialization/ldump.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ static void dumpString (DumpState *D, TString *ts) {
dumpVector(D, s, size + 1); /* include ending '\0' */
D->nstr++; /* one more saved string */
setsvalue(D->L, &key, ts); /* the string is the key */
setivalue(&value, l_castU2S(D->nstr)); /* its index is the value */
value.setInt(l_castU2S(D->nstr)); /* its index is the value */
luaH_set(D->L, D->h, &key, &value); /* h[ts] = nstr */
/* integer value does not need barrier */
}
Expand Down
4 changes: 2 additions & 2 deletions src/serialization/lundump.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,10 +235,10 @@ static void loadConstants (LoadState *S, Proto *f) {
setbtvalue(o);
break;
case LUA_VNUMFLT:
setfltvalue(o, loadNumber(S));
o->setFloat(loadNumber(S));
break;
case LUA_VNUMINT:
setivalue(o, loadInteger(S));
o->setInt(loadInteger(S));
break;
case LUA_VSHRSTR:
case LUA_VLNGSTR: {
Expand Down
34 changes: 17 additions & 17 deletions src/vm/lvm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -603,12 +603,12 @@ void luaV_execute (lua_State *L, CallInfo *ci) {
int imm = InstructionView(i).sc();
if (ttisinteger(v1)) {
lua_Integer iv1 = ivalue(v1);
pc++; setivalue(ra, iop(L, iv1, imm));
pc++; ra->setInt(iop(L, iv1, imm));
}
else if (ttisfloat(v1)) {
lua_Number nb = fltvalue(v1);
lua_Number fimm = cast_num(imm);
pc++; setfltvalue(ra, fop(L, nb, fimm));
pc++; ra->setFloat(fop(L, nb, fimm));
}
};

Expand All @@ -617,7 +617,7 @@ void luaV_execute (lua_State *L, CallInfo *ci) {
lua_Number n1, n2;
if (tonumberns(v1, n1) && tonumberns(v2, n2)) {
StkId ra = RA(i);
pc++; setfltvalue(s2v(ra), fop(L, n1, n2));
pc++; s2v(ra)->setFloat(fop(L, n1, n2));
}
};

Expand All @@ -642,7 +642,7 @@ void luaV_execute (lua_State *L, CallInfo *ci) {
StkId ra = RA(i);
lua_Integer i1 = ivalue(v1);
lua_Integer i2 = ivalue(v2);
pc++; setivalue(s2v(ra), iop(L, i1, i2));
pc++; s2v(ra)->setInt(iop(L, i1, i2));
}
else {
op_arithf_aux(v1, v2, fop, i);
Expand Down Expand Up @@ -672,7 +672,7 @@ void luaV_execute (lua_State *L, CallInfo *ci) {
lua_Integer i2 = ivalue(v2);
if (tointegerns(v1, &i1)) {
StkId ra = RA(i);
pc++; setivalue(s2v(ra), op(i1, i2));
pc++; s2v(ra)->setInt(op(i1, i2));
}
};

Expand All @@ -683,7 +683,7 @@ void luaV_execute (lua_State *L, CallInfo *ci) {
lua_Integer i1, i2;
if (tointegerns(v1, &i1) && tointegerns(v2, &i2)) {
StkId ra = RA(i);
pc++; setivalue(s2v(ra), op(i1, i2));
pc++; s2v(ra)->setInt(op(i1, i2));
}
};

Expand Down Expand Up @@ -768,13 +768,13 @@ void luaV_execute (lua_State *L, CallInfo *ci) {
vmcase(OP_LOADI) {
StkId ra = RA(i);
lua_Integer b = InstructionView(i).sbx();
setivalue(s2v(ra), b);
s2v(ra)->setInt(b);
vmbreak;
}
vmcase(OP_LOADF) {
StkId ra = RA(i);
int b = InstructionView(i).sbx();
setfltvalue(s2v(ra), cast_num(b));
s2v(ra)->setFloat(cast_num(b));
vmbreak;
}
vmcase(OP_LOADK) {
Expand Down Expand Up @@ -859,7 +859,7 @@ void luaV_execute (lua_State *L, CallInfo *ci) {
luaV_fastgeti(rb, c, s2v(ra), tag);
if (tagisempty(tag)) {
TValue key;
setivalue(&key, c);
key.setInt(c);
Protect([&]() { luaV_finishget(L, rb, &key, ra, tag); });
}
vmbreak;
Expand Down Expand Up @@ -915,7 +915,7 @@ void luaV_execute (lua_State *L, CallInfo *ci) {
luaV_finishfastset(L, s2v(ra), rc);
else {
TValue key;
setivalue(&key, b);
key.setInt(b);
Protect([&]() { luaV_finishset(L, s2v(ra), &key, rc, hres); });
}
vmbreak;
Expand Down Expand Up @@ -1018,7 +1018,7 @@ void luaV_execute (lua_State *L, CallInfo *ci) {
int ic = InstructionView(i).sc();
lua_Integer ib;
if (tointegerns(rb, &ib)) {
pc++; setivalue(s2v(ra), luaV_shiftl(ic, ib));
pc++; s2v(ra)->setInt(luaV_shiftl(ic, ib));
}
vmbreak;
}
Expand All @@ -1028,7 +1028,7 @@ void luaV_execute (lua_State *L, CallInfo *ci) {
int ic = InstructionView(i).sc();
lua_Integer ib;
if (tointegerns(rb, &ib)) {
pc++; setivalue(s2v(ra), luaV_shiftl(ib, -ic));
pc++; s2v(ra)->setInt(luaV_shiftl(ib, -ic));
}
vmbreak;
}
Expand Down Expand Up @@ -1118,10 +1118,10 @@ void luaV_execute (lua_State *L, CallInfo *ci) {
lua_Number nb;
if (ttisinteger(rb)) {
lua_Integer ib = ivalue(rb);
setivalue(s2v(ra), intop(-, 0, ib));
s2v(ra)->setInt(intop(-, 0, ib));
}
else if (tonumberns(rb, nb)) {
setfltvalue(s2v(ra), luai_numunm(L, nb));
s2v(ra)->setFloat(luai_numunm(L, nb));
}
else
Protect([&]() { luaT_trybinTM(L, rb, rb, ra, TMS::TM_UNM); });
Expand All @@ -1132,7 +1132,7 @@ void luaV_execute (lua_State *L, CallInfo *ci) {
TValue *rb = vRB(i);
lua_Integer ib;
if (tointegerns(rb, &ib)) {
setivalue(s2v(ra), intop(^, ~l_castS2U(0), ib));
s2v(ra)->setInt(intop(^, ~l_castS2U(0), ib));
}
else
Protect([&]() { luaT_trybinTM(L, rb, rb, ra, TMS::TM_BNOT); });
Expand Down Expand Up @@ -1368,9 +1368,9 @@ void luaV_execute (lua_State *L, CallInfo *ci) {
if (count > 0) { /* still more iterations? */
lua_Integer step = ivalue(s2v(ra + 1));
lua_Integer idx = ivalue(s2v(ra + 2)); /* control variable */
chgivalue(s2v(ra), l_castU2S(count - 1)); /* update counter */
s2v(ra)->changeInt(l_castU2S(count - 1)); /* update counter */
idx = intop(+, idx, step); /* add step to index */
chgivalue(s2v(ra + 2), idx); /* update control variable */
s2v(ra + 2)->changeInt(idx); /* update control variable */
pc -= InstructionView(i).bx(); /* jump back */
}
}
Expand Down
Loading
Loading