summaryrefslogtreecommitdiff
path: root/src/lparser.js
diff options
context:
space:
mode:
authorBenoit Giannangeli <giann008@gmail.com>2017-02-28 21:15:16 +0100
committerBenoit Giannangeli <benoit.giannangeli@boursorama.fr>2017-03-01 09:32:28 +0100
commit74dda64eab7951da520dc451a1f3bbb8c7d62706 (patch)
tree26930f74654a0be55cc418c64fa2ba2713e875c6 /src/lparser.js
parentdfac155a3f8b650222fa784303e599f4e50abe67 (diff)
downloadfengari-74dda64eab7951da520dc451a1f3bbb8c7d62706.tar.gz
fengari-74dda64eab7951da520dc451a1f3bbb8c7d62706.tar.bz2
fengari-74dda64eab7951da520dc451a1f3bbb8c7d62706.zip
Bytecode generation
Diffstat (limited to 'src/lparser.js')
-rw-r--r--src/lparser.js18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/lparser.js b/src/lparser.js
index 154310b..074542a 100644
--- a/src/lparser.js
+++ b/src/lparser.js
@@ -22,7 +22,7 @@ const UpVal = lfunc.UpVal;
const MAXVARS = 200;
const hasmultret = function(k) {
- return k == expkind.VCALL || k == expkind.VVARARG;
+ return k === expkind.VCALL || k === expkind.VVARARG;
};
class BlockCnt {
@@ -65,6 +65,10 @@ const vkisvar = function(k) {
return expkind.VLOCAL <= k && k <= expkind.VINDEXED;
};
+const vkisinreg = function(k) {
+ return k === expkind.VNONRELOC || k === expkind.VLOCAL;
+};
+
class expdesc {
constructor() {
this.k = NaN;
@@ -586,7 +590,7 @@ const recfield = function(ls, cc) {
if (ls.t.token === R.TK_NAME) {
checklimit(fs, cc.nh, Number.MAX_SAFE_INTEGER, "items in a constructor");
checkname(ls, key);
- } else /* ls->t.token == '[' */
+ } else /* ls->t.token === '[' */
yindex(ls, key);
cc.nh++;
checknext(ls, '=');
@@ -1334,9 +1338,9 @@ const funcname = function(ls, v) {
/* funcname -> NAME {fieldsel} [':' NAME] */
let ismethod = 0;
singlevar(ls, v);
- while (ls.t.token == '.')
+ while (ls.t.token === '.')
fieldsel(ls, v);
- if (ls.t.token == ':') {
+ if (ls.t.token === ':') {
ismethod = 1;
fieldsel(ls, v);
}
@@ -1392,7 +1396,7 @@ const retstat = function(ls) {
else {
lcode.luaK_exp2nextreg(fs, e); /* values must go to the stack */
first = fs.nactvar; /* return all active values */
- assert(nret == fs.freereg - first);
+ assert(nret === fs.freereg - first);
}
}
}
@@ -1507,4 +1511,6 @@ const luaY_parser = function(L, z, buff, dyd, name, firstchar) {
};
-module.exports.luaY_parser = luaY_parser; \ No newline at end of file
+module.exports.expkind = expkind;
+module.exports.luaY_parser = luaY_parser;
+module.exports.vkisinreg = vkisinreg; \ No newline at end of file