summaryrefslogtreecommitdiff
path: root/src/lobject.js
diff options
context:
space:
mode:
authordaurnimator <quae@daurnimator.com>2017-05-23 18:02:28 +1000
committerdaurnimator <quae@daurnimator.com>2017-05-27 22:14:38 +1000
commit78f764030414e5c45ea059a5f582885da0282e39 (patch)
treea82fa0e267d91a8e7cb3a5df5444dc276945ddca /src/lobject.js
parent941e38fe2360fc0b4fa6f4ef5c9a9a43c172d528 (diff)
downloadfengari-78f764030414e5c45ea059a5f582885da0282e39.tar.gz
fengari-78f764030414e5c45ea059a5f582885da0282e39.tar.bz2
fengari-78f764030414e5c45ea059a5f582885da0282e39.zip
Introduce setsvalue2s
Diffstat (limited to 'src/lobject.js')
-rw-r--r--src/lobject.js12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/lobject.js b/src/lobject.js
index 3a442ee..ee7a51d 100644
--- a/src/lobject.js
+++ b/src/lobject.js
@@ -193,6 +193,9 @@ const setobjs2s = function(L, newidx, oldidx) {
const setobj2s = function(L, newidx, oldtv) {
L.stack[newidx] = new TValue(oldtv.type, oldtv.value);
};
+const setsvalue2s = function(L, newidx, ts) {
+ L.stack[newidx] = new TValue(CT.LUA_TLNGSTR, ts);
+};
const luaO_nilobject = new TValue(CT.LUA_TNIL, null);
Object.freeze(luaO_nilobject);
@@ -486,12 +489,12 @@ const luaO_tostring = function(L, obj) {
buff.push(char['0']); /* adds '.0' to result */
}
}
- return new TValue(CT.LUA_TLNGSTR, lstring.luaS_bless(L, buff));
+ return lstring.luaS_bless(L, buff);
};
const pushstr = function(L, str) {
+ setsvalue2s(L, L.top, lstring.luaS_new(L, str));
ldo.luaD_inctop(L);
- L.stack[L.top-1] = new TValue(CT.LUA_TLNGSTR, lstring.luaS_new(L, str));
};
const luaO_pushvfstring = function(L, fmt, argp) {
@@ -519,11 +522,11 @@ const luaO_pushvfstring = function(L, fmt, argp) {
case char['d']:
case char['I']:
ldo.luaD_inctop(L);
- L.stack[L.top-1] = luaO_tostring(L, new TValue(CT.LUA_TNUMINT, argp[a++]));
+ setsvalue2s(L, L.top-1, luaO_tostring(L, new TValue(CT.LUA_TNUMINT, argp[a++])));
break;
case char['f']:
ldo.luaD_inctop(L);
- L.stack[L.top-1] = luaO_tostring(L, new TValue(CT.LUA_TNUMFLT, argp[a++]));
+ setsvalue2s(L, L.top-1, luaO_tostring(L, new TValue(CT.LUA_TNUMFLT, argp[a++])));
break;
case char['p']:
let v = argp[a++];
@@ -678,3 +681,4 @@ module.exports.luaO_utf8esc = luaO_utf8esc;
module.exports.numarith = numarith;
module.exports.setobjs2s = setobjs2s;
module.exports.setobj2s = setobj2s;
+module.exports.setsvalue2s = setsvalue2s;