diff options
author | daurnimator <quae@daurnimator.com> | 2017-05-08 12:32:08 +1000 |
---|---|---|
committer | daurnimator <quae@daurnimator.com> | 2017-05-08 15:31:29 +1000 |
commit | 2977fe002407b6f86efa4ba5216f567082f33e45 (patch) | |
tree | da7e0127cd26534d01655e7b6a5c8732fb4920a0 /src/lapi.js | |
parent | 8c8585a0bba0e05b6382f2f4f063515b5988639c (diff) | |
download | fengari-2977fe002407b6f86efa4ba5216f567082f33e45.tar.gz fengari-2977fe002407b6f86efa4ba5216f567082f33e45.tar.bz2 fengari-2977fe002407b6f86efa4ba5216f567082f33e45.zip |
Move string functions to centralised lstring.js
Diffstat (limited to 'src/lapi.js')
-rw-r--r-- | src/lapi.js | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/lapi.js b/src/lapi.js index aa8cf04..fa6da20 100644 --- a/src/lapi.js +++ b/src/lapi.js @@ -10,6 +10,7 @@ const lfunc = require('./lfunc.js'); const llex = require('./llex.js'); const lobject = require('./lobject.js'); const lstate = require('./lstate.js'); +const lstring = require('./lstring.js'); const ltm = require('./ltm.js'); const luaconf = require('./luaconf.js'); const lvm = require('./lvm.js'); @@ -216,7 +217,7 @@ const lua_pushlstring = function(L, s, len) { assert(Array.isArray(s), "lua_pushlstring expects array of byte"); assert(typeof len === "number"); - let ts = len === 0 ? L.l_G.intern(defs.to_luastring("", true)) : new TValue(CT.LUA_TLNGSTR, s.slice(0, len)); + let ts = new TValue(CT.LUA_TLNGSTR, lstring.luaS_bless(L, s.slice(0, len))); L.stack[L.top++] = ts; assert(L.top <= L.ci.top, "stack overflow"); @@ -230,7 +231,7 @@ const lua_pushstring = function (L, s) { if (s === undefined || s === null) L.stack[L.top] = new TValue(CT.LUA_TNIL, null); else { - L.stack[L.top] = new TValue(CT.LUA_TLNGSTR, s); + L.stack[L.top] = new TValue(CT.LUA_TLNGSTR, lstring.luaS_new(L, s)); } L.top++; @@ -255,7 +256,7 @@ const lua_pushliteral = function (L, s) { if (s === undefined || s === null) L.stack[L.top] = new TValue(CT.LUA_TNIL, null); else { - let ts = L.l_G.intern(defs.to_luastring(s)); + let ts = new TValue(CT.LUA_TLNGSTR, lstring.luaS_newliteral(L, s)); L.stack[L.top] = ts; } @@ -330,7 +331,7 @@ const lua_pushglobaltable = function(L) { const auxsetstr = function(L, t, k) { assert(Array.isArray(k), "key must be an array of bytes"); - let str = L.l_G.intern(k); + let str = new TValue(CT.LUA_TLNGSTR, lstring.luaS_new(L, k)); assert(1 < L.top - L.ci.funcOff, "not enough elements in the stack"); @@ -429,7 +430,7 @@ const lua_rawsetp = function(L, idx, p) { const auxgetstr = function(L, t, k) { assert(Array.isArray(k), "key must be an array of bytes"); - let str = L.l_G.intern(k); + let str = new TValue(CT.LUA_TLNGSTR, lstring.luaS_new(L, k)); L.stack[L.top++] = str; assert(L.top <= L.ci.top, "stack overflow"); @@ -952,7 +953,7 @@ const lua_concat = function(L, n) { if (n >= 2) lvm.luaV_concat(L, n); else if (n === 0) { - L.stack[L.top++] = L.l_G.intern(defs.to_luastring("", true)); + L.stack[L.top++] = new TValue(CT.LUA_TLNGSTR, lstring.luaS_newliteral(L, [])); assert(L.top <= L.ci.top, "stack overflow"); } }; |