From 8d576081a53ee1a866491b423c5373951aa6a7c4 Mon Sep 17 00:00:00 2001 From: Benoit Giannangeli Date: Tue, 28 Feb 2017 11:29:37 +0100 Subject: jshint --- .jshintrc | 6 ++++++ src/lapi.js | 1 - src/lbaselib.js | 1 - src/lcode.js | 9 ++++----- src/lcorolib.js | 1 - src/linit.js | 1 - src/ljstype.js | 1 - src/llex.js | 3 +-- src/lmathlib.js | 1 - src/lparser.js | 42 +++++++++++++++++++++++++++++------------- src/ltablib.js | 1 - 11 files changed, 40 insertions(+), 27 deletions(-) create mode 100644 .jshintrc diff --git a/.jshintrc b/.jshintrc new file mode 100644 index 0000000..e64eb7e --- /dev/null +++ b/.jshintrc @@ -0,0 +1,6 @@ +{ + "node": true, + "esversion": 6, + "indent": false, + "white": false +} \ No newline at end of file diff --git a/src/lapi.js b/src/lapi.js index d0c099f..c4a7bbe 100644 --- a/src/lapi.js +++ b/src/lapi.js @@ -1,4 +1,3 @@ -/* jshint esversion: 6 */ "use strict"; const assert = require('assert'); diff --git a/src/lbaselib.js b/src/lbaselib.js index 012f5c3..b663b87 100644 --- a/src/lbaselib.js +++ b/src/lbaselib.js @@ -1,4 +1,3 @@ -/* jshint esversion: 6 */ "use strict"; const assert = require('assert'); diff --git a/src/lcode.js b/src/lcode.js index e64c0a9..9a5cda0 100644 --- a/src/lcode.js +++ b/src/lcode.js @@ -1,4 +1,3 @@ -/* jshint esversion: 6 */ "use strict"; const assert = require('assert'); @@ -203,7 +202,7 @@ const luaK_patchclose = function(fs, list, level) { level++; /* argument is +1 to reserve 0 as non-op */ for (; list !== NO_JUMP; list = getjump(fs, list)) { let ins = fs.f.code[list]; - assert(ins.opcode === OpCodesI.OP_JMP && (ins.A === 0 || i.A >= level); + assert(ins.opcode === OpCodesI.OP_JMP && (ins.A === 0 || ins.A >= level)); lopcode.SETARG_A(ins, level); } }; @@ -237,9 +236,9 @@ const luaK_codeABC = function(fs, o, a, b, c) { ** Format and emit an 'iABx' instruction. */ const luaK_codeABx = function(fs, o, a, bc) { - lua_assert(lopcode.getOpMode(o) == lopcode.iABx || getOpMode(o) == lopcode.iAsBx); - lua_assert(lopcode.getCMode(o) == lopcode.OpArgN); - lua_assert(a <= lopcode.MAXARG_A && bc <= lopcode.MAXARG_Bx); + assert(lopcode.getOpMode(o) == lopcode.iABx || lopcode.getOpMode(o) == lopcode.iAsBx); + assert(lopcode.getCMode(o) == lopcode.OpArgN); + assert(a <= lopcode.MAXARG_A && bc <= lopcode.MAXARG_Bx); return luaK_code(fs, lopcode.CREATE_ABx(o, a, bc)); }; diff --git a/src/lcorolib.js b/src/lcorolib.js index 05f3b00..b2d0de8 100644 --- a/src/lcorolib.js +++ b/src/lcorolib.js @@ -1,4 +1,3 @@ -/* jshint esversion: 6 */ "use strict"; const assert = require('assert'); diff --git a/src/linit.js b/src/linit.js index 36c0121..b926683 100644 --- a/src/linit.js +++ b/src/linit.js @@ -1,4 +1,3 @@ -/* jshint esversion: 6 */ "use strict"; const assert = require('assert'); diff --git a/src/ljstype.js b/src/ljstype.js index 192db6f..a92c8d0 100644 --- a/src/ljstype.js +++ b/src/ljstype.js @@ -1,4 +1,3 @@ -/* jshint esversion: 6 */ "use strict"; const assert = require('assert'); diff --git a/src/llex.js b/src/llex.js index 1992856..59bc4a4 100644 --- a/src/llex.js +++ b/src/llex.js @@ -1,4 +1,3 @@ -/* jshint esversion: 6 */ "use strict"; const assert = require('assert'); @@ -265,7 +264,7 @@ const lexerror = function(ls, msg, token) { const luaX_syntaxerror = function(ls, msg) { lexerror(ls, msg, ls.t.token); -} +}; /* ** skip a sequence '[=*[' or ']=*]'; if sequence is well formed, return diff --git a/src/lmathlib.js b/src/lmathlib.js index 54bdc46..55f8416 100644 --- a/src/lmathlib.js +++ b/src/lmathlib.js @@ -1,4 +1,3 @@ -/* jshint esversion: 6 */ "use strict"; const assert = require('assert'); diff --git a/src/lparser.js b/src/lparser.js index 807e8e7..a7e4209 100644 --- a/src/lparser.js +++ b/src/lparser.js @@ -1,4 +1,3 @@ -/* jshint esversion: 6 */ "use strict"; const assert = require('assert'); @@ -20,6 +19,12 @@ const Table = lobject.Table; const UnOpr = lcode.UnOpr; const UpVal = lfunc.UpVal; +const MAXVARS = 200; + +const hasmultret = function(k) { + return k == expkind.VCALL || k == expkind.VVARARG; +}; + class BlockCnt { constructor() { this.previous = null; /* chain */ @@ -376,6 +381,16 @@ const close_func = function(ls) { /* GRAMMAR RULES */ /*============================================================*/ +const block_follow = function(ls, withuntil) { + switch (ls.t.token) { + case R.TK_ELSE: case R.TK_ELSEIF: + case R.TK_END: case R.TK_EOS: + return true; + case R.TK_UNTIL: return withuntil; + default: return false; + } +}; + const statlist = function(ls) { /* statlist -> { stat [';'] } */ while (!block_follow(ls, 1)) { @@ -436,7 +451,7 @@ const closelistfield = function(fs, cc) { lcode.luaK_exp2nextreg(fs, cc.v); cc.v.k = expkind.VVOID; if (cc.tostore === lopcode.LFIELDS_PER_FLUSH) { - luaK_setlist(fs, cc.t.u.info, cc.na, cc.tostore); /* flush */ + lcode.luaK_setlist(fs, cc.t.u.info, cc.na, cc.tostore); /* flush */ cc.tostore = 0; /* no more items pending */ } }; @@ -548,6 +563,7 @@ const simpleexp = function(ls, v) { let fs = ls.fs; check_condition(ls, fs.f.is_vararg, "cannot use '...' outside a vararg function"); init_exp(v, expkind.VVARARG, lcode.luaK_codeABC(fs, OpCodesI.OP_VARARG, 0, 1, 0)); + break; } case '{': { /* constructor */ constructor(ls, v); @@ -604,16 +620,16 @@ const getbinopr = function(op) { }; const priority = [ /* ORDER OPR */ - {10, 10}, {10, 10}, /* '+' '-' */ - {11, 11}, {11, 11}, /* '*' '%' */ - {14, 13}, /* '^' (right associative) */ - {11, 11}, {11, 11}, /* '/' '//' */ - {6, 6}, {4, 4}, {5, 5}, /* '&' '|' '~' */ - {7, 7}, {7, 7}, /* '<<' '>>' */ - {9, 8}, /* '..' (right associative) */ - {3, 3}, {3, 3}, {3, 3}, /* ==, <, <= */ - {3, 3}, {3, 3}, {3, 3}, /* ~=, >, >= */ - {2, 2}, {1, 1} /* and, or */ + {left: 10, right: 10}, {left: 10, right: 10}, /* '+' '-' */ + {left: 11, right: 11}, {left: 11, right: 11}, /* '*' '%' */ + {left: 14, right: 13}, /* '^' (right associative) */ + {left: 11, right: 11}, {left: 11, right: 11}, /* '/' '//' */ + {left: 6, right: 6}, {left: 4, right: 4}, {left: 5, right: 5}, /* '&' '|' '~' */ + {left: 7, right: 7}, {left: 7, right: 7}, /* '<<' '>>' */ + {left: 9, right: 8}, /* '..' (right associative) */ + {left: 3, right: 3}, {left: 3, right: 3}, {left: 3, right: 3}, /* ==, <, <= */ + {left: 3, right: 3}, {left: 3, right: 3}, {left: 3, right: 3}, /* ~=, >, >= */ + {left: 2, right: 2}, {left: 1, right: 1} /* and, or */ ]; const UNARY_PRIORITY = 12; @@ -650,7 +666,7 @@ const subexpr = function(ls, v, limit) { const expr = function(ls, v) { subexpr(ls, v, 0); -} +}; const test_then_block = function(ls, escapelist) { /* test_then_block -> [IF | ELSEIF] cond THEN block */ diff --git a/src/ltablib.js b/src/ltablib.js index fa43523..a7963d3 100644 --- a/src/ltablib.js +++ b/src/ltablib.js @@ -1,4 +1,3 @@ -/* jshint esversion: 6 */ "use strict"; const assert = require('assert'); -- cgit v1.2.3-70-g09d2