From 4b061b1658a53c202bf3d05d5babc697c2980f86 Mon Sep 17 00:00:00 2001 From: daurnimator Date: Mon, 29 Jan 2018 15:10:50 +1100 Subject: src/llex.js: Store luaX_tokens in lua string form --- src/llex.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/llex.js b/src/llex.js index c61981f..323ea73 100644 --- a/src/llex.js +++ b/src/llex.js @@ -118,7 +118,7 @@ const luaX_tokens = [ "//", "..", "...", "==", ">=", "<=", "~=", "<<", ">>", "::", "", "", "", "", "" -]; +].map((e, i)=>to_luastring(e)); class SemInfo { constructor() { @@ -172,9 +172,9 @@ const luaX_token2str = function(ls, token) { } else { let s = luaX_tokens[token - FIRST_RESERVED]; if (token < TK_EOS) /* fixed format (symbols and reserved words)? */ - return lobject.luaO_pushfstring(ls.L, to_luastring("'%s'", true), to_luastring(s)); + return lobject.luaO_pushfstring(ls.L, to_luastring("'%s'", true), s); else /* names, strings, and numerals */ - return to_luastring(s); + return s; } }; @@ -509,7 +509,7 @@ 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[luaS_hash(to_luastring(e))] = i); +luaX_tokens.forEach((e, i)=>token_to_index[luaS_hash(e)] = i); const isreserved = function(w) { let kidx = token_to_index[luaS_hashlongstr(w)]; -- cgit v1.2.3-54-g00ecf