diff options
author | daurnimator <quae@daurnimator.com> | 2018-01-18 07:17:59 +1100 |
---|---|---|
committer | daurnimator <quae@daurnimator.com> | 2018-01-18 07:17:59 +1100 |
commit | ed7ac85c409ffec65aa86189f49e5d46e7a110bc (patch) | |
tree | 9a02ed29652757dcf0ebc81b7db2c7da82474ca5 /src/llex.js | |
parent | 8bedd949c894d61284b3ddd5b3bf989b651b95f8 (diff) | |
download | fengari-ed7ac85c409ffec65aa86189f49e5d46e7a110bc.tar.gz fengari-ed7ac85c409ffec65aa86189f49e5d46e7a110bc.tar.bz2 fengari-ed7ac85c409ffec65aa86189f49e5d46e7a110bc.zip |
src/: Destructure when requiring lstring.js
Diffstat (limited to 'src/llex.js')
-rw-r--r-- | src/llex.js | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/src/llex.js b/src/llex.js index a838158..257042f 100644 --- a/src/llex.js +++ b/src/llex.js @@ -11,7 +11,12 @@ const ldebug = require('./ldebug.js'); const ldo = require('./ldo.js'); const ljstype = require('./ljstype.js'); const lobject = require('./lobject.js'); -const lstring = require('./lstring.js'); +const { + luaS_bless, + luaS_hash, + luaS_hashlongstr, + luaS_new +} = require('./lstring.js'); const ltable = require('./ltable.js'); const llimits = require('./llimits.js'); const lzio = require('./lzio.js'); @@ -152,13 +157,13 @@ const save_and_next = function(ls) { */ const luaX_newstring = function(ls, str) { let L = ls.L; - let ts = lstring.luaS_new(L, str); + let ts = luaS_new(L, str); let o = ltable.luaH_set(L, ls.h, new lobject.TValue(LUA_TLNGSTR, ts)); if (o.ttisnil()) { /* not in use yet? */ o.setbvalue(true); } else { /* string already present */ /* HACK: Workaround lack of ltable 'keyfromval' */ - let tpair = ls.h.strong.get(lstring.luaS_hashlongstr(ts)); + let tpair = ls.h.strong.get(luaS_hashlongstr(ts)); lua_assert(tpair.value == o); /* fengari addition */ ts = tpair.key.tsvalue(); /* re-use value previously stored */ } @@ -195,7 +200,7 @@ const luaX_setinput = function(L, ls, z, source, firstchar) { ls.linenumber = 1; ls.lastline = 1; ls.source = source; - ls.envn = lstring.luaS_bless(L, LUA_ENV); + ls.envn = luaS_bless(L, LUA_ENV); lzio.luaZ_resizebuffer(L, ls.buff, llimits.LUA_MINBUFFER); /* initialize buffer */ }; @@ -459,10 +464,10 @@ const read_string = function(ls, del, seminfo) { }; const token_to_index = Object.create(null); /* don't want to return true for e.g. 'hasOwnProperty' */ -luaX_tokens.forEach((e, i)=>token_to_index[lstring.luaS_hash(to_luastring(e))] = i); +luaX_tokens.forEach((e, i)=>token_to_index[luaS_hash(to_luastring(e))] = i); const isreserved = function(w) { - let kidx = token_to_index[lstring.luaS_hashlongstr(w)]; + let kidx = token_to_index[luaS_hashlongstr(w)]; return kidx !== void 0 && kidx <= 22; }; @@ -568,7 +573,7 @@ const llex = function(ls, seminfo) { } while (ljstype.lislalnum(ls.current)); let ts = luaX_newstring(ls, lzio.luaZ_buffer(ls.buff)); seminfo.ts = ts; - let kidx = token_to_index[lstring.luaS_hashlongstr(ts)]; + let kidx = token_to_index[luaS_hashlongstr(ts)]; if (kidx !== void 0 && kidx <= 22) /* reserved word? */ return kidx + FIRST_RESERVED; else |