summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordaurnimator <quae@daurnimator.com>2018-01-29 15:10:50 +1100
committerdaurnimator <quae@daurnimator.com>2018-01-29 22:05:53 +1100
commit4b061b1658a53c202bf3d05d5babc697c2980f86 (patch)
treeb0a3170ba4fa22468e9749fe5b0068b79e2e2359 /src
parent7e9d49a1dd3f7b60c1366a5380516665adc85812 (diff)
downloadfengari-4b061b1658a53c202bf3d05d5babc697c2980f86.tar.gz
fengari-4b061b1658a53c202bf3d05d5babc697c2980f86.tar.bz2
fengari-4b061b1658a53c202bf3d05d5babc697c2980f86.zip
src/llex.js: Store luaX_tokens in lua string form
Diffstat (limited to 'src')
-rw-r--r--src/llex.js8
1 files 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 = [
"//", "..", "...", "==", ">=", "<=", "~=",
"<<", ">>", "::", "<eof>",
"<number>", "<integer>", "<name>", "<string>"
-];
+].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)];