summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordaurnimator <quae@daurnimator.com>2017-05-24 14:18:59 +1000
committerdaurnimator <quae@daurnimator.com>2017-05-27 22:14:46 +1000
commitebbfaf9602a624e1c8eb39e88661fadc56996c4b (patch)
treee7b3399314665ed13a83a34bafa7e7f85f3d67ef /src
parent018f9cd8bbff126b7381bafa135e8127033c2faa (diff)
downloadfengari-ebbfaf9602a624e1c8eb39e88661fadc56996c4b.tar.gz
fengari-ebbfaf9602a624e1c8eb39e88661fadc56996c4b.tar.bz2
fengari-ebbfaf9602a624e1c8eb39e88661fadc56996c4b.zip
src/lapi.js: Sync lua_pushliteral implementation with lua_pushstring
Diffstat (limited to 'src')
-rw-r--r--src/lapi.js7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/lapi.js b/src/lapi.js
index 0cad44a..9b10d94 100644
--- a/src/lapi.js
+++ b/src/lapi.js
@@ -272,16 +272,17 @@ const lua_pushfstring = function (L, fmt, ...argp) {
return lobject.luaO_pushvfstring(L, fmt, argp);
};
+/* Similar to lua_pushstring, but takes a JS string */
const lua_pushliteral = function (L, s) {
assert(typeof s === "string" || s === undefined || s === null, "lua_pushliteral expects a JS string");
if (s === undefined || s === null)
L.stack[L.top] = new TValue(CT.LUA_TNIL, null);
else {
- let ts = new TValue(CT.LUA_TLNGSTR, lstring.luaS_newliteral(L, s));
- L.stack[L.top] = ts;
+ let ts = lstring.luaS_newliteral(L, s);
+ lobject.setsvalue2s(L, L.top, ts);
+ s = ts.getstr(); /* internal copy */
}
-
L.top++;
assert(L.top <= L.ci.top, "stack overflow");