summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/llex.js134
-rw-r--r--src/lobject.js64
-rw-r--r--src/lparser.js117
3 files changed, 167 insertions, 148 deletions
diff --git a/src/llex.js b/src/llex.js
index 257042f..b09aa93 100644
--- a/src/llex.js
+++ b/src/llex.js
@@ -2,7 +2,6 @@
const {
constant_types: { LUA_TLNGSTR },
- char,
thread_status: { LUA_ERRSYNTAX },
to_luastring
} = require('./defs.js');
@@ -138,7 +137,7 @@ const luaX_token2str = function(ls, token) {
};
const currIsNewline = function(ls) {
- return ls.current === char['\n'] || ls.current === char['\r'];
+ return ls.current === 10 /* ('\n').charCodeAt(0) */ || ls.current === 13 /* ('\r').charCodeAt(0) */;
};
const next = function(ls) {
@@ -205,7 +204,7 @@ const luaX_setinput = function(L, ls, z, source, firstchar) {
};
const check_next1 = function(ls, c) {
- if (ls.current === c.charCodeAt(0)) {
+ if (ls.current === c) {
next(ls);
return true;
}
@@ -231,7 +230,7 @@ const read_numeral = function(ls, seminfo) {
let first = ls.current;
lua_assert(ljstype.lisdigit(ls.current));
save_and_next(ls);
- if (first === char['0'] && check_next2(ls, "xX")) /* hexadecimal? */
+ if (first === 48 /* ('0').charCodeAt(0) */ && check_next2(ls, "xX")) /* hexadecimal? */
expo = "Pp";
for (;;) {
@@ -239,7 +238,7 @@ const read_numeral = function(ls, seminfo) {
check_next2(ls, "-+"); /* optional exponent sign */
if (ljstype.lisxdigit(ls.current))
save_and_next(ls);
- else if (ls.current === char['.'])
+ else if (ls.current === 46 /* ('.').charCodeAt(0) */)
save_and_next(ls);
else break;
}
@@ -289,9 +288,9 @@ const luaX_syntaxerror = function(ls, msg) {
const skip_sep = function(ls) {
let count = 0;
let s = ls.current;
- lua_assert(s === char['['] || s === char[']']);
+ lua_assert(s === 91 /* ('[').charCodeAt(0) */ || s === 93 /* (']').charCodeAt(0) */);
save_and_next(ls);
- while (ls.current === char['=']) {
+ while (ls.current === 61 /* ('=').charCodeAt(0) */) {
save_and_next(ls);
count++;
}
@@ -314,15 +313,16 @@ const read_long_string = function(ls, seminfo, sep) {
lexerror(ls, to_luastring(msg), R.TK_EOS);
break;
}
- case char[']']: {
+ case 93 /* (']').charCodeAt(0) */: {
if (skip_sep(ls) === sep) {
save_and_next(ls); /* skip 2nd ']' */
skip = true;
}
break;
}
- case char['\n']: case char['\r']: {
- save(ls, char['\n']);
+ case 10 /* ('\n').charCodeAt(0) */:
+ case 13 /* ('\r').charCodeAt(0) */: {
+ save(ls, 10 /* ('\n').charCodeAt(0) */);
inclinenumber(ls);
if (!seminfo) lzio.luaZ_resetbuffer(ls.buff);
break;
@@ -362,7 +362,7 @@ const readhexaesc = function(ls) {
const readutf8desc = function(ls) {
let i = 4; /* chars to be removed: '\', 'u', '{', and first digit */
save_and_next(ls); /* skip 'u' */
- esccheck(ls, ls.current === char['{'], to_luastring("missing '{'", true));
+ esccheck(ls, ls.current === 123 /* ('{').charCodeAt(0) */, to_luastring("missing '{'", true));
let r = gethexa(ls); /* must have at least one digit */
save_and_next(ls);
@@ -372,7 +372,7 @@ const readutf8desc = function(ls) {
esccheck(ls, r <= 0x10FFFF, to_luastring("UTF-8 value too large", true));
save_and_next(ls);
}
- esccheck(ls, ls.current === char['}'], to_luastring("missing '}'", true));
+ esccheck(ls, ls.current === 125 /* ('}').charCodeAt(0) */, to_luastring("missing '}'", true));
next(ls); /* skip '}' */
lzio.luaZ_buffremove(ls.buff, i); /* remove saved chars from buffer */
return r;
@@ -389,7 +389,7 @@ const readdecesc = function(ls) {
let r = 0; /* result accumulator */
let i;
for (i = 0; i < 3 && ljstype.lisdigit(ls.current); i++) { /* read up to 3 digits */
- r = 10 * r + ls.current - char['0'];
+ r = 10 * r + ls.current - 48 /* ('0').charCodeAt(0) */;
save_and_next(ls);
}
esccheck(ls, r <= 255, to_luastring("decimal escape too large", true));
@@ -405,30 +405,33 @@ const read_string = function(ls, del, seminfo) {
case lzio.EOZ:
lexerror(ls, to_luastring("unfinished string", true), R.TK_EOS);
break;
- case char['\n']:
- case char['\r']:
+ case 10 /* ('\n').charCodeAt(0) */:
+ case 13 /* ('\r').charCodeAt(0) */:
lexerror(ls, to_luastring("unfinished string", true), R.TK_STRING);
break;
- case char['\\']: { /* escape sequences */
+ case 92 /* ('\\').charCodeAt(0) */: { /* escape sequences */
save_and_next(ls); /* keep '\\' for error messages */
let will;
let c;
switch(ls.current) {
- case char['a']: c = 7 /* \a isn't valid JS */; will = 'read_save'; break;
- case char['b']: c = char['\b']; will = 'read_save'; break;
- case char['f']: c = char['\f']; will = 'read_save'; break;
- case char['n']: c = char['\n']; will = 'read_save'; break;
- case char['r']: c = char['\r']; will = 'read_save'; break;
- case char['t']: c = char['\t']; will = 'read_save'; break;
- case char['v']: c = char['\v']; will = 'read_save'; break;
- case char['x']: c = readhexaesc(ls); will = 'read_save'; break;
- case char['u']: utf8esc(ls); will = 'no_save'; break;
- case char['\n']: case char['\r']:
- inclinenumber(ls); c = char['\n']; will = 'only_save'; break;
- case char['\\']: case char['"']: case char['\'']:
+ case 97 /* ('a').charCodeAt(0) */: c = 7 /* \a isn't valid JS */; will = 'read_save'; break;
+ case 98 /* ('b').charCodeAt(0) */: c = 8 /* ('\b').charCodeAt(0) */; will = 'read_save'; break;
+ case 102 /* ('f').charCodeAt(0) */: c = 12 /* ('\f').charCodeAt(0) */; will = 'read_save'; break;
+ case 110 /* ('n').charCodeAt(0) */: c = 10 /* ('\n').charCodeAt(0) */; will = 'read_save'; break;
+ case 114 /* ('r').charCodeAt(0) */: c = 13 /* ('\r').charCodeAt(0) */; will = 'read_save'; break;
+ case 116 /* ('t').charCodeAt(0) */: c = 9 /* ('\t').charCodeAt(0) */; will = 'read_save'; break;
+ case 118 /* ('v').charCodeAt(0) */: c = 11 /* ('\v').charCodeAt(0) */; will = 'read_save'; break;
+ case 120 /* ('x').charCodeAt(0) */: c = readhexaesc(ls); will = 'read_save'; break;
+ case 117 /* ('u').charCodeAt(0) */: utf8esc(ls); will = 'no_save'; break;
+ case 10 /* ('\n').charCodeAt(0) */:
+ case 13 /* ('\r').charCodeAt(0) */:
+ inclinenumber(ls); c = 10 /* ('\n').charCodeAt(0) */; will = 'only_save'; break;
+ case 92 /* ('\\').charCodeAt(0) */:
+ case 34 /* ('"').charCodeAt(0) */:
+ case 39 /* ('\'').charCodeAt(0) */:
c = ls.current; will = 'read_save'; break;
case lzio.EOZ: will = 'no_save'; break; /* will raise an error next loop */
- case char['z']: { /* zap following span of spaces */
+ case 122 /* ('z').charCodeAt(0) */: { /* zap following span of spaces */
lzio.luaZ_buffremove(ls.buff, 1); /* remove '\\' */
next(ls); /* skip the 'z' */
while (ljstype.lisspace(ls.current)) {
@@ -476,20 +479,24 @@ const llex = function(ls, seminfo) {
for (;;) {
lua_assert(typeof ls.current == "number"); /* fengari addition */
switch (ls.current) {
- case char['\n']: case char['\r']: { /* line breaks */
+ case 10 /* ('\n').charCodeAt(0) */:
+ case 13 /* ('\r').charCodeAt(0) */: { /* line breaks */
inclinenumber(ls);
break;
}
- case char[' ']: case char['\f']: case char['\t']: case char['\v']: { /* spaces */
+ case 32 /* (' ').charCodeAt(0) */:
+ case 12 /* ('\f').charCodeAt(0) */:
+ case 9 /* ('\t').charCodeAt(0) */:
+ case 11 /* ('\v').charCodeAt(0) */: { /* spaces */
next(ls);
break;
}
- case char['-']: { /* '-' or '--' (comment) */
+ case 45 /* ('-').charCodeAt(0) */: { /* '-' or '--' (comment) */
next(ls);
- if (ls.current !== char['-']) return char['-'];
+ if (ls.current !== 45 /* ('-').charCodeAt(0) */) return 45 /* ('-').charCodeAt(0) */;
/* else is a comment */
next(ls);
- if (ls.current === char['[']) { /* long comment? */
+ if (ls.current === 91 /* ('[').charCodeAt(0) */) { /* long comment? */
let sep = skip_sep(ls);
lzio.luaZ_resetbuffer(ls.buff); /* 'skip_sep' may dirty the buffer */
if (sep >= 0) {
@@ -504,63 +511,64 @@ const llex = function(ls, seminfo) {
next(ls); /* skip until end of line (or end of file) */
break;
}
- case char['[']: { /* long string or simply '[' */
+ case 91 /* ('[').charCodeAt(0) */: { /* long string or simply '[' */
let sep = skip_sep(ls);
if (sep >= 0) {
read_long_string(ls, seminfo, sep);
return R.TK_STRING;
} else if (sep !== -1) /* '[=...' missing second bracket */
lexerror(ls, to_luastring("invalid long string delimiter", true), R.TK_STRING);
- return char['['];
+ return 91 /* ('[').charCodeAt(0) */;
}
- case char['=']: {
+ case 61 /* ('=').charCodeAt(0) */: {
next(ls);
- if (check_next1(ls, '=')) return R.TK_EQ;
- else return char['='];
+ if (check_next1(ls, 61 /* ('=').charCodeAt(0) */)) return R.TK_EQ;
+ else return 61 /* ('=').charCodeAt(0) */;
}
- case char['<']: {
+ case 60 /* ('<').charCodeAt(0) */: {
next(ls);
- if (check_next1(ls, '=')) return R.TK_LE;
- else if (check_next1(ls, '<')) return R.TK_SHL;
- else return char['<'];
+ if (check_next1(ls, 61 /* ('=').charCodeAt(0) */)) return R.TK_LE;
+ else if (check_next1(ls, 60 /* ('<').charCodeAt(0) */)) return R.TK_SHL;
+ else return 60 /* ('<').charCodeAt(0) */;
}
- case char['>']: {
+ case 62 /* ('>').charCodeAt(0) */: {
next(ls);
- if (check_next1(ls, '=')) return R.TK_GE;
- else if (check_next1(ls, '>')) return R.TK_SHR;
- else return char['>'];
+ if (check_next1(ls, 61 /* ('=').charCodeAt(0) */)) return R.TK_GE;
+ else if (check_next1(ls, 62 /* ('>').charCodeAt(0) */)) return R.TK_SHR;
+ else return 62 /* ('>').charCodeAt(0) */;
}
- case char['/']: {
+ case 47 /* ('/').charCodeAt(0) */: {
next(ls);
- if (check_next1(ls, '/')) return R.TK_IDIV;
- else return char['/'];
+ if (check_next1(ls, 47 /* ('/').charCodeAt(0) */)) return R.TK_IDIV;
+ else return 47 /* ('/').charCodeAt(0) */;
}
- case char['~']: {
+ case 126 /* ('~').charCodeAt(0) */: {
next(ls);
- if (check_next1(ls, '=')) return R.TK_NE;
- else return char['~'];
+ if (check_next1(ls, 61 /* ('=').charCodeAt(0) */)) return R.TK_NE;
+ else return 126 /* ('~').charCodeAt(0) */;
}
- case char[':']: {
+ case 58 /* (':').charCodeAt(0) */: {
next(ls);
- if (check_next1(ls, ':')) return R.TK_DBCOLON;
- else return char[':'];
+ if (check_next1(ls, 58 /* (':').charCodeAt(0) */)) return R.TK_DBCOLON;
+ else return 58 /* (':').charCodeAt(0) */;
}
- case char['"']: case char['\'']: { /* short literal strings */
+ case 34 /* ('"').charCodeAt(0) */:
+ case 39 /* ('\'').charCodeAt(0) */: { /* short literal strings */
read_string(ls, ls.current, seminfo);
return R.TK_STRING;
}
- case char['.']: { /* '.', '..', '...', or number */
+ case 46 /* ('.').charCodeAt(0) */: { /* '.', '..', '...', or number */
save_and_next(ls);
- if (check_next1(ls, '.')) {
- if (check_next1(ls, '.'))
+ if (check_next1(ls, 46 /* ('.').charCodeAt(0) */)) {
+ if (check_next1(ls, 46 /* ('.').charCodeAt(0) */))
return R.TK_DOTS; /* '...' */
else return R.TK_CONCAT; /* '..' */
}
- else if (!ljstype.lisdigit(ls.current)) return char['.'];
+ else if (!ljstype.lisdigit(ls.current)) return 46 /* ('.').charCodeAt(0) */;
else return read_numeral(ls, seminfo);
}
- case char['0']: case char['1']: case char['2']: case char['3']: case char['4']:
- case char['5']: case char['6']: case char['7']: case char['8']: case char['9']: {
+ case 48 /* ('0').charCodeAt(0) */: case 49 /* ('1').charCodeAt(0) */: case 50 /* ('2').charCodeAt(0) */: case 51 /* ('3').charCodeAt(0) */: case 52 /* ('4').charCodeAt(0) */:
+ case 53 /* ('5').charCodeAt(0) */: case 54 /* ('6').charCodeAt(0) */: case 55 /* ('7').charCodeAt(0) */: case 56 /* ('8').charCodeAt(0) */: case 57 /* ('9').charCodeAt(0) */: {
return read_numeral(ls, seminfo);
}
case lzio.EOZ: {
diff --git a/src/lobject.js b/src/lobject.js
index bd0f1b2..1f26b96 100644
--- a/src/lobject.js
+++ b/src/lobject.js
@@ -354,7 +354,7 @@ const POS = to_luastring("\"]");
const luaO_chunkid = function(source, bufflen) {
let l = source.length;
let out;
- if (source[0] === char['=']) { /* 'literal' source */
+ if (source[0] === 61 /* ('=').charCodeAt(0) */) { /* 'literal' source */
if (l < bufflen) { /* small enough? */
out = new Uint8Array(l-1);
out.set(source.subarray(1));
@@ -362,7 +362,7 @@ const luaO_chunkid = function(source, bufflen) {
out = new Uint8Array(bufflen);
out.set(source.subarray(1, bufflen+1));
}
- } else if (source[0] === char['@']) { /* file name */
+ } else if (source[0] === 64 /* ('@').charCodeAt(0) */) { /* file name */
if (l <= bufflen) { /* small enough? */
out = new Uint8Array(l-1);
out.set(source.subarray(1));
@@ -374,7 +374,7 @@ const luaO_chunkid = function(source, bufflen) {
}
} else { /* string; format as [string "source"] */
out = new Uint8Array(bufflen);
- let nli = luastring_indexOf(source, char['\n']); /* find first new line (if any) */
+ let nli = luastring_indexOf(source, 10 /* ('\n').charCodeAt(0) */); /* find first new line (if any) */
out.set(PRE); /* add prefix */
let out_i = PRE.length;
bufflen -= PRE.length + RETS.length + POS.length; /* save space for prefix+suffix */
@@ -438,16 +438,16 @@ const lua_strx2number = function(s) {
let neg; /* 1 if number is negative */
let hasdot = false; /* true after seen a dot */
while (lisspace(s[i])) i++; /* skip initial spaces */
- if ((neg = (s[i] === char['-']))) i++; /* check signal */
- else if (s[i] === char['+']) i++;
- if (!(s[i] === char['0'] && (s[i+1] === char['x'] || s[i+1] === char['X']))) /* check '0x' */
+ if ((neg = (s[i] === 45 /* ('-').charCodeAt(0) */))) i++; /* check signal */
+ else if (s[i] === 43 /* ('+').charCodeAt(0) */) i++;
+ if (!(s[i] === 48 /* ('0').charCodeAt(0) */ && (s[i+1] === 120 /* ('x').charCodeAt(0) */ || s[i+1] === 88 /* ('X').charCodeAt(0) */))) /* check '0x' */
return null; /* invalid format (no '0x') */
for (i += 2; ; i++) { /* skip '0x' and read numeral */
if (s[i] === dot) {
if (hasdot) break; /* second dot? stop loop */
else hasdot = true;
} else if (lisxdigit(s[i])) {
- if (sigdig === 0 && s[i] === char['0']) /* non-significant digit (zero)? */
+ if (sigdig === 0 && s[i] === 48 /* ('0').charCodeAt(0) */) /* non-significant digit (zero)? */
nosigdig++;
else if (++sigdig <= MAXSIGDIG) /* can read it without overflow? */
r = (r * 16) + luaO_hexavalue(s[i]);
@@ -459,16 +459,16 @@ const lua_strx2number = function(s) {
if (nosigdig + sigdig === 0) /* no digits? */
return null; /* invalid format */
e *= 4; /* each digit multiplies/divides value by 2^4 */
- if (s[i] === char['p'] || s[i] === char['P']) { /* exponent part? */
+ if (s[i] === 112 /* ('p').charCodeAt(0) */ || s[i] === 80 /* ('P').charCodeAt(0) */) { /* exponent part? */
let exp1 = 0; /* exponent value */
let neg1; /* exponent signal */
i++; /* skip 'p' */
- if ((neg1 = (s[i] === char['-']))) i++; /* signal */
- else if (s[i] === char['+']) i++;
+ if ((neg1 = (s[i] === 45 /* ('-').charCodeAt(0) */))) i++; /* signal */
+ else if (s[i] === 43 /* ('+').charCodeAt(0) */) i++;
if (!lisdigit(s[i]))
return null; /* invalid; must have at least one digit */
while (lisdigit(s[i])) /* read exponent */
- exp1 = exp1 * 10 + s[i++] - char['0'];
+ exp1 = exp1 * 10 + s[i++] - 48 /* ('0').charCodeAt(0) */;
if (neg1) exp1 = -exp1;
e += exp1;
}
@@ -501,8 +501,20 @@ const l_str2dloc = function(s, mode) {
return (result.i === s.length || s[result.i] === 0) ? result : null; /* OK if no trailing characters */
};
-const SIGILS = [char["."], char["x"], char["X"], char["n"], char["N"]];
-const modes = {[char["."]]: ".", [char["x"]]: "x", [char["X"]]: "x", [char["n"]]: "n", [char["N"]]: "n"};
+const SIGILS = [
+ 46 /* (".").charCodeAt(0) */,
+ 120 /* ("x").charCodeAt(0) */,
+ 88 /* ("X").charCodeAt(0) */,
+ 110 /* ("n").charCodeAt(0) */,
+ 78 /* ("N").charCodeAt(0) */
+];
+const modes = {
+ [ 46]: ".",
+ [120]: "x",
+ [ 88]: "x",
+ [110]: "n",
+ [ 78]: "n"
+};
const l_str2d = function(s) {
let l = s.length;
let pmode = 0;
@@ -533,9 +545,9 @@ const l_str2int = function(s) {
let neg;
while (lisspace(s[i])) i++; /* skip initial spaces */
- if ((neg = (s[i] === char['-']))) i++;
- else if (s[i] === char['+']) i++;
- if (s[i] === char['0'] && (s[i+1] === char['x'] || s[i+1] === char['X'])) { /* hex? */
+ if ((neg = (s[i] === 45 /* ('-').charCodeAt(0) */))) i++;
+ else if (s[i] === 43 /* ('+').charCodeAt(0) */) i++;
+ if (s[i] === 48 /* ('0').charCodeAt(0) */ && (s[i+1] === 120 /* ('x').charCodeAt(0) */ || s[i+1] === 88 /* ('X').charCodeAt(0) */)) { /* hex? */
i += 2; /* skip '0x' */
for (; lisxdigit(s[i]); i++) {
@@ -544,7 +556,7 @@ const l_str2int = function(s) {
}
} else { /* decimal */
for (; lisdigit(s[i]); i++) {
- let d = s[i] - char['0'];
+ let d = s[i] - 48 /* ('0').charCodeAt(0) */;
if (a >= MAXBY10 && (a > MAXBY10 || d > MAXLASTD + neg)) /* overflow? */
return null; /* do not accept it (as integer) */
a = (a * 10 + d)|0;
@@ -603,11 +615,11 @@ const luaO_pushvfstring = function(L, fmt, argp) {
let a = 0;
let e;
for (;;) {
- e = luastring_indexOf(fmt, char['%'], i);
+ e = luastring_indexOf(fmt, 37 /* ('%').charCodeAt(0) */, i);
if (e == -1) break;
pushstr(L, fmt.subarray(i, e));
switch(fmt[e+1]) {
- case char['s']: {
+ case 115 /* ('s').charCodeAt(0) */: {
let s = argp[a++];
if (s === null) s = to_luastring("(null)", true);
else {
@@ -620,7 +632,7 @@ const luaO_pushvfstring = function(L, fmt, argp) {
pushstr(L, s);
break;
}
- case char['c']: {
+ case 99 /* ('c').charCodeAt(0) */: {
let buff = argp[a++];
if (lisprint(buff))
pushstr(L, luastring_of(buff));
@@ -628,18 +640,18 @@ const luaO_pushvfstring = function(L, fmt, argp) {
luaO_pushfstring(L, to_luastring("<\\%d>", true), buff);
break;
}
- case char['d']:
- case char['I']:
+ case 100 /* ('d').charCodeAt(0) */:
+ case 73 /* ('I').charCodeAt(0) */:
ldo.luaD_inctop(L);
L.stack[L.top-1].setivalue(argp[a++]);
luaO_tostring(L, L.stack[L.top-1]);
break;
- case char['f']:
+ case 102 /* ('f').charCodeAt(0) */:
ldo.luaD_inctop(L);
L.stack[L.top-1].setfltvalue(argp[a++]);
luaO_tostring(L, L.stack[L.top-1]);
break;
- case char['p']: {
+ case 112 /* ('p').charCodeAt(0) */: {
let v = argp[a++];
if (v instanceof lstate.lua_State ||
v instanceof ltable.Table ||
@@ -671,13 +683,13 @@ const luaO_pushvfstring = function(L, fmt, argp) {
}
break;
}
- case char['U']: {
+ case 85 /* ('U').charCodeAt(0) */: {
let buff = new Uint8Array(UTF8BUFFSZ);
let l = luaO_utf8esc(buff, argp[a++]);
pushstr(L, buff.subarray(UTF8BUFFSZ - l));
break;
}
- case char['%']:
+ case 37 /* ('%').charCodeAt(0) */:
pushstr(L, to_luastring("%", true));
break;
default:
diff --git a/src/lparser.js b/src/lparser.js
index b235367..a427424 100644
--- a/src/lparser.js
+++ b/src/lparser.js
@@ -2,7 +2,6 @@
const {
LUA_MULTRET,
- char,
to_luastring
} = require('./defs.js');
const {
@@ -720,7 +719,7 @@ const yindex = function(ls, v) {
llex.luaX_next(ls); /* skip the '[' */
expr(ls, v);
luaK_exp2val(ls.fs, v);
- checknext(ls, char[']']);
+ checknext(ls, 93 /* (']').charCodeAt(0) */);
};
/*
@@ -752,7 +751,7 @@ const recfield = function(ls, cc) {
} else /* ls->t.token === '[' */
yindex(ls, key);
cc.nh++;
- checknext(ls, char['=']);
+ checknext(ls, 61 /* ('=').charCodeAt(0) */);
let rkkey = luaK_exp2RK(fs, key);
expr(ls, val);
luaK_codeABC(fs, OP_SETTABLE, cc.t.u.info, rkkey, luaK_exp2RK(fs, val));
@@ -794,13 +793,13 @@ const field = function(ls, cc) {
/* field -> listfield | recfield */
switch (ls.t.token) {
case R.TK_NAME: { /* may be 'listfield' or 'recfield' */
- if (llex.luaX_lookahead(ls) !== char['=']) /* expression? */
+ if (llex.luaX_lookahead(ls) !== 61 /* ('=').charCodeAt(0) */) /* expression? */
listfield(ls, cc);
else
recfield(ls, cc);
break;
}
- case char['[']: {
+ case 91 /* ('[').charCodeAt(0) */: {
recfield(ls, cc);
break;
}
@@ -823,14 +822,14 @@ const constructor = function(ls, t) {
init_exp(t, expkind.VRELOCABLE, pc);
init_exp(cc.v, expkind.VVOID, 0); /* no value (yet) */
luaK_exp2nextreg(ls.fs, t); /* fix it at stack top */
- checknext(ls, char['{']);
+ checknext(ls, 123 /* ('{').charCodeAt(0) */);
do {
lua_assert(cc.v.k === expkind.VVOID || cc.tostore > 0);
- if (ls.t.token === char['}']) break;
+ if (ls.t.token === 125 /* ('}').charCodeAt(0) */) break;
closelistfield(fs, cc);
field(ls, cc);
- } while (testnext(ls, char[',']) || testnext(ls, char[';']));
- check_match(ls, char['}'], char['{'], line);
+ } while (testnext(ls, 44 /* (',').charCodeAt(0) */) || testnext(ls, 59 /* (';').charCodeAt(0) */));
+ check_match(ls, 125 /* ('}').charCodeAt(0) */, 123 /* ('{').charCodeAt(0) */, line);
lastlistfield(fs, cc);
SETARG_B(fs.f.code[pc], lobject.luaO_int2fb(cc.na)); /* set initial array size */
SETARG_C(fs.f.code[pc], lobject.luaO_int2fb(cc.nh)); /* set initial table size */
@@ -844,7 +843,7 @@ const parlist = function(ls) {
let f = fs.f;
let nparams = 0;
f.is_vararg = false;
- if (ls.t.token !== char[')']) { /* is 'parlist' not empty? */
+ if (ls.t.token !== 41 /* (')').charCodeAt(0) */) { /* is 'parlist' not empty? */
do {
switch (ls.t.token) {
case R.TK_NAME: { /* param -> NAME */
@@ -859,7 +858,7 @@ const parlist = function(ls) {
}
default: llex.luaX_syntaxerror(ls, to_luastring("<name> or '...' expected", true));
}
- } while(!f.is_vararg && testnext(ls, char[',']));
+ } while(!f.is_vararg && testnext(ls, 44 /* (',').charCodeAt(0) */));
}
adjustlocalvars(ls, nparams);
f.numparams = fs.nactvar;
@@ -873,13 +872,13 @@ const body = function(ls, e, ismethod, line) {
new_fs.f = addprototype(ls);
new_fs.f.linedefined = line;
open_func(ls, new_fs, bl);
- checknext(ls, char['(']);
+ checknext(ls, 40 /* ('(').charCodeAt(0) */);
if (ismethod) {
new_localvarliteral(ls, "self"); /* create 'self' parameter */
adjustlocalvars(ls, 1);
}
parlist(ls);
- checknext(ls, char[')']);
+ checknext(ls, 41 /* (')').charCodeAt(0) */);
statlist(ls);
new_fs.f.lastlinedefined = ls.linenumber;
check_match(ls, R.TK_END, R.TK_FUNCTION, line);
@@ -891,7 +890,7 @@ const explist = function(ls, v) {
/* explist -> expr { ',' expr } */
let n = 1; /* at least one expression */
expr(ls, v);
- while (testnext(ls, char[','])) {
+ while (testnext(ls, 44 /* (',').charCodeAt(0) */)) {
luaK_exp2nextreg(ls.fs, v);
expr(ls, v);
n++;
@@ -903,18 +902,18 @@ const funcargs = function(ls, f, line) {
let fs = ls.fs;
let args = new expdesc();
switch (ls.t.token) {
- case char['(']: { /* funcargs -> '(' [ explist ] ')' */
+ case 40 /* ('(').charCodeAt(0) */: { /* funcargs -> '(' [ explist ] ')' */
llex.luaX_next(ls);
- if (ls.t.token === char[')']) /* arg list is empty? */
+ if (ls.t.token === 41 /* (')').charCodeAt(0) */) /* arg list is empty? */
args.k = expkind.VVOID;
else {
explist(ls, args);
luaK_setmultret(fs, args);
}
- check_match(ls, char[')'], char['('], line);
+ check_match(ls, 41 /* (')').charCodeAt(0) */, 40 /* ('(').charCodeAt(0) */, line);
break;
}
- case char['{']: { /* funcargs -> constructor */
+ case 123 /* ('{').charCodeAt(0) */: { /* funcargs -> constructor */
constructor(ls, args);
break;
}
@@ -951,11 +950,11 @@ const funcargs = function(ls, f, line) {
const primaryexp = function(ls, v) {
/* primaryexp -> NAME | '(' expr ')' */
switch (ls.t.token) {
- case char['(']: {
+ case 40 /* ('(').charCodeAt(0) */: {
let line = ls.linenumber;
llex.luaX_next(ls);
expr(ls, v);
- check_match(ls, char[')'], char['('], line);
+ check_match(ls, 41 /* (')').charCodeAt(0) */, 40 /* ('(').charCodeAt(0) */, line);
luaK_dischargevars(ls.fs, v);
return;
}
@@ -977,18 +976,18 @@ const suffixedexp = function(ls, v) {
primaryexp(ls, v);
for (;;) {
switch (ls.t.token) {
- case char['.']: { /* fieldsel */
+ case 46 /* ('.').charCodeAt(0) */: { /* fieldsel */
fieldsel(ls, v);
break;
}
- case char['[']: { /* '[' exp1 ']' */
+ case 91 /* ('[').charCodeAt(0) */: { /* '[' exp1 ']' */
let key = new expdesc();
luaK_exp2anyregup(fs, v);
yindex(ls, key);
luaK_indexed(fs, v, key);
break;
}
- case char[':']: { /* ':' NAME funcargs */
+ case 58 /* (':').charCodeAt(0) */: { /* ':' NAME funcargs */
let key = new expdesc();
llex.luaX_next(ls);
checkname(ls, key);
@@ -996,7 +995,7 @@ const suffixedexp = function(ls, v) {
funcargs(ls, v, line);
break;
}
- case char['(']: case R.TK_STRING: case char['{']: { /* funcargs */
+ case 40 /* ('(').charCodeAt(0) */: case R.TK_STRING: case 123 /* ('{').charCodeAt(0) */: { /* funcargs */
luaK_exp2nextreg(fs, v);
funcargs(ls, v, line);
break;
@@ -1042,7 +1041,7 @@ const simpleexp = function(ls, v) {
init_exp(v, expkind.VVARARG, luaK_codeABC(fs, OP_VARARG, 0, 1, 0));
break;
}
- case char['{']: { /* constructor */
+ case 123 /* ('{').charCodeAt(0) */: { /* constructor */
constructor(ls, v);
return;
}
@@ -1061,34 +1060,34 @@ const simpleexp = function(ls, v) {
const getunopr = function(op) {
switch (op) {
- case R.TK_NOT: return OPR_NOT;
- case char['-']: return OPR_MINUS;
- case char['~']: return OPR_BNOT;
- case char['#']: return OPR_LEN;
- default: return OPR_NOUNOPR;
+ case R.TK_NOT: return OPR_NOT;
+ case 45 /* ('-').charCodeAt(0) */: return OPR_MINUS;
+ case 126 /* ('~').charCodeAt(0) */: return OPR_BNOT;
+ case 35 /* ('#').charCodeAt(0) */: return OPR_LEN;
+ default: return OPR_NOUNOPR;
}
};
const getbinopr = function(op) {
switch (op) {
- case char['+']: return OPR_ADD;
- case char['-']: return OPR_SUB;
- case char['*']: return OPR_MUL;
- case char['%']: return OPR_MOD;
- case char['^']: return OPR_POW;
- case char['/']: return OPR_DIV;
+ case 43 /* ('+').charCodeAt(0) */: return OPR_ADD;
+ case 45 /* ('-').charCodeAt(0) */: return OPR_SUB;
+ case 42 /* ('*').charCodeAt(0) */: return OPR_MUL;
+ case 37 /* ('%').charCodeAt(0) */: return OPR_MOD;
+ case 94 /* ('^').charCodeAt(0) */: return OPR_POW;
+ case 47 /* ('/').charCodeAt(0) */: return OPR_DIV;
case R.TK_IDIV: return OPR_IDIV;
- case char['&']: return OPR_BAND;
- case char['|']: return OPR_BOR;
- case char['~']: return OPR_BXOR;
+ case 38 /* ('&').charCodeAt(0) */: return OPR_BAND;
+ case 124 /* ('|').charCodeAt(0) */: return OPR_BOR;
+ case 126 /* ('~').charCodeAt(0) */: return OPR_BXOR;
case R.TK_SHL: return OPR_SHL;
case R.TK_SHR: return OPR_SHR;
case R.TK_CONCAT: return OPR_CONCAT;
case R.TK_NE: return OPR_NE;
case R.TK_EQ: return OPR_EQ;
- case char['<']: return OPR_LT;
+ case 60 /* ('<').charCodeAt(0) */: return OPR_LT;
case R.TK_LE: return OPR_LE;
- case char['>']: return OPR_GT;
+ case 62 /* ('>').charCodeAt(0) */: return OPR_GT;
case R.TK_GE: return OPR_GE;
case R.TK_AND: return OPR_AND;
case R.TK_OR: return OPR_OR;
@@ -1211,7 +1210,7 @@ const check_conflict = function(ls, lh, v) {
const assignment = function(ls, lh, nvars) {
let e = new expdesc();
check_condition(ls, vkisvar(lh.v.k), to_luastring("syntax error", true));
- if (testnext(ls, char[','])) { /* assignment -> ',' suffixedexp assignment */
+ if (testnext(ls, 44 /* (',').charCodeAt(0) */)) { /* assignment -> ',' suffixedexp assignment */
let nv = new LHS_assign();
nv.prev = lh;
suffixedexp(ls, nv.v);
@@ -1220,7 +1219,7 @@ const assignment = function(ls, lh, nvars) {
checklimit(ls.fs, nvars + ls.L.nCcalls, LUAI_MAXCCALLS, to_luastring("JS levels", true));
assignment(ls, nv, nvars + 1);
} else { /* assignment -> '=' explist */
- checknext(ls, char['=']);
+ checknext(ls, 61 /* ('=').charCodeAt(0) */);
let nexps = explist(ls, e);
if (nexps !== nvars)
adjust_assign(ls, nvars, nexps, e);
@@ -1270,7 +1269,7 @@ const checkrepeated = function(fs, ll, label) {
/* skip no-op statements */
const skipnoopstat = function(ls) {
- while (ls.t.token === char[';'] || ls.t.token === R.TK_DBCOLON)
+ while (ls.t.token === 59 /* (';').charCodeAt(0) */ || ls.t.token === R.TK_DBCOLON)
statement(ls);
};
@@ -1368,11 +1367,11 @@ const fornum = function(ls, varname, line) {
new_localvarliteral(ls, "(for limit)");
new_localvarliteral(ls, "(for step)");
new_localvar(ls, varname);
- checknext(ls, char['=']);
+ checknext(ls, 61 /* ('=').charCodeAt(0) */);
exp1(ls); /* initial value */
- checknext(ls, char[',']);
+ checknext(ls, 44 /* (',').charCodeAt(0) */);
exp1(ls); /* limit */
- if (testnext(ls, char[',']))
+ if (testnext(ls, 44 /* (',').charCodeAt(0) */))
exp1(ls); /* optional step */
else { /* default step = 1 */
luaK_codek(fs, fs.freereg, luaK_intK(fs, 1));
@@ -1393,7 +1392,7 @@ const forlist = function(ls, indexname) {
new_localvarliteral(ls, "(for control)");
/* create declared variables */
new_localvar(ls, indexname);
- while (testnext(ls, char[','])) {
+ while (testnext(ls, 44 /* (',').charCodeAt(0) */)) {
new_localvar(ls, str_checkname(ls));
nvars++;
}
@@ -1412,8 +1411,8 @@ const forstat = function(ls, line) {
llex.luaX_next(ls); /* skip 'for' */
let varname = str_checkname(ls); /* first variable name */
switch (ls.t.token) {
- case char['=']: fornum(ls, varname, line); break;
- case char[',']: case R.TK_IN: forlist(ls, varname); break;
+ case 61 /* ('=').charCodeAt(0) */: fornum(ls, varname, line); break;
+ case 44 /* (',').charCodeAt(0) */: case R.TK_IN: forlist(ls, varname); break;
default: llex.luaX_syntaxerror(ls, to_luastring("'=' or 'in' expected", true));
}
check_match(ls, R.TK_END, R.TK_FOR, line);
@@ -1435,7 +1434,7 @@ const test_then_block = function(ls, escapelist) {
luaK_goiffalse(ls.fs, v); /* will jump to label if condition is true */
enterblock(fs, bl, false); /* must enter block before 'goto' */
gotostat(ls, v.t); /* handle goto/break */
- while (testnext(ls, char[';'])); /* skip colons */
+ while (testnext(ls, 59 /* (';').charCodeAt(0) */)); /* skip colons */
if (block_follow(ls, 0)) { /* 'goto' is the entire block? */
leaveblock(fs);
return escapelist; /* and that is it */
@@ -1487,8 +1486,8 @@ const localstat = function(ls) {
do {
new_localvar(ls, str_checkname(ls));
nvars++;
- } while (testnext(ls, char[',']));
- if (testnext(ls, char['=']))
+ } while (testnext(ls, 44 /* (',').charCodeAt(0) */));
+ if (testnext(ls, 61 /* ('=').charCodeAt(0) */))
nexps = explist(ls, e);
else {
e.k = expkind.VVOID;
@@ -1502,9 +1501,9 @@ const funcname = function(ls, v) {
/* funcname -> NAME {fieldsel} [':' NAME] */
let ismethod = 0;
singlevar(ls, v);
- while (ls.t.token === char['.'])
+ while (ls.t.token === 46 /* ('.').charCodeAt(0) */)
fieldsel(ls, v);
- if (ls.t.token === char[':']) {
+ if (ls.t.token === 58 /* (':').charCodeAt(0) */) {
ismethod = 1;
fieldsel(ls, v);
}
@@ -1527,7 +1526,7 @@ const exprstat= function(ls) {
let fs = ls.fs;
let v = new LHS_assign();
suffixedexp(ls, v.v);
- if (ls.t.token === char['='] || ls.t.token === char[',']) { /* stat . assignment ? */
+ if (ls.t.token === 61 /* ('=').charCodeAt(0) */ || ls.t.token === 44 /* (',').charCodeAt(0) */) { /* stat . assignment ? */
v.prev = null;
assignment(ls, v, 1);
}
@@ -1542,7 +1541,7 @@ const retstat = function(ls) {
let fs = ls.fs;
let e = new expdesc();
let first, nret; /* registers with returned values */
- if (block_follow(ls, 1) || ls.t.token === char[';'])
+ if (block_follow(ls, 1) || ls.t.token === 59 /* (';').charCodeAt(0) */)
first = nret = 0; /* return no values */
else {
nret = explist(ls, e); /* optional return values */
@@ -1565,14 +1564,14 @@ const retstat = function(ls) {
}
}
luaK_ret(fs, first, nret);
- testnext(ls, char[';']); /* skip optional semicolon */
+ testnext(ls, 59 /* (';').charCodeAt(0) */); /* skip optional semicolon */
};
const statement = function(ls) {
let line = ls.linenumber; /* may be needed for error messages */
enterlevel(ls);
switch(ls.t.token) {
- case char[';']: { /* stat -> ';' (empty statement) */
+ case 59 /* (';').charCodeAt(0) */: { /* stat -> ';' (empty statement) */
llex.luaX_next(ls); /* skip ';' */
break;
}