shift-codegen
Advanced tools
Comparing version 4.0.0 to 4.0.1
@@ -1,2 +0,2 @@ | ||
/*istanbul ignore next*/"use strict"; | ||
"use strict"; | ||
@@ -9,4 +9,4 @@ var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
exports.getPrecedence = getPrecedence; | ||
/*istanbul ignore next*/exports.escapeStringLiteral = escapeStringLiteral; | ||
/*istanbul ignore next*/ | ||
exports.escapeStringLiteral = escapeStringLiteral; | ||
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } | ||
@@ -43,3 +43,3 @@ | ||
/*istanbul ignore next*/exports.Precedence = Precedence; | ||
exports.Precedence = Precedence; | ||
@@ -191,6 +191,4 @@ var BinaryPrecedence = { | ||
/*istanbul ignore next*/ | ||
var CodeRep = exports.CodeRep = function () { | ||
function CodeRep() { | ||
/*istanbul ignore next*/ | ||
_classCallCheck(this, CodeRep); | ||
@@ -219,3 +217,2 @@ | ||
/*istanbul ignore next*/ | ||
var Empty = exports.Empty = function (_CodeRep) { | ||
@@ -225,6 +222,5 @@ _inherits(Empty, _CodeRep); | ||
function Empty() { | ||
/*istanbul ignore next*/ | ||
_classCallCheck(this, Empty); | ||
/*istanbul ignore next*/return _possibleConstructorReturn(this, Object.getPrototypeOf(Empty).call(this)); | ||
return _possibleConstructorReturn(this, Object.getPrototypeOf(Empty).call(this)); | ||
} | ||
@@ -240,3 +236,2 @@ | ||
/*istanbul ignore next*/ | ||
var Token = exports.Token = function (_CodeRep2) { | ||
@@ -246,10 +241,8 @@ _inherits(Token, _CodeRep2); | ||
function Token(token) { | ||
/*istanbul ignore next*/ | ||
_classCallCheck(this, Token); | ||
/*istanbul ignore next*/ | ||
var _this2 = _possibleConstructorReturn(this, Object.getPrototypeOf(Token).call(this)); | ||
/*istanbul ignore next*/_this2.token = token; | ||
/*istanbul ignore next*/return _this2; | ||
_this2.token = token; | ||
return _this2; | ||
} | ||
@@ -267,3 +260,2 @@ | ||
/*istanbul ignore next*/ | ||
var NumberCodeRep = exports.NumberCodeRep = function (_CodeRep3) { | ||
@@ -273,10 +265,8 @@ _inherits(NumberCodeRep, _CodeRep3); | ||
function NumberCodeRep(number) { | ||
/*istanbul ignore next*/ | ||
_classCallCheck(this, NumberCodeRep); | ||
/*istanbul ignore next*/ | ||
var _this3 = _possibleConstructorReturn(this, Object.getPrototypeOf(NumberCodeRep).call(this)); | ||
/*istanbul ignore next*/_this3.number = number; | ||
/*istanbul ignore next*/return _this3; | ||
_this3.number = number; | ||
return _this3; | ||
} | ||
@@ -294,3 +284,2 @@ | ||
/*istanbul ignore next*/ | ||
var Paren = exports.Paren = function (_CodeRep4) { | ||
@@ -300,10 +289,8 @@ _inherits(Paren, _CodeRep4); | ||
function Paren(expr) { | ||
/*istanbul ignore next*/ | ||
_classCallCheck(this, Paren); | ||
/*istanbul ignore next*/ | ||
var _this4 = _possibleConstructorReturn(this, Object.getPrototypeOf(Paren).call(this)); | ||
/*istanbul ignore next*/_this4.expr = expr; | ||
/*istanbul ignore next*/return _this4; | ||
_this4.expr = expr; | ||
return _this4; | ||
} | ||
@@ -329,3 +316,2 @@ | ||
/*istanbul ignore next*/ | ||
var Bracket = exports.Bracket = function (_CodeRep5) { | ||
@@ -335,10 +321,8 @@ _inherits(Bracket, _CodeRep5); | ||
function Bracket(expr) { | ||
/*istanbul ignore next*/ | ||
_classCallCheck(this, Bracket); | ||
/*istanbul ignore next*/ | ||
var _this5 = _possibleConstructorReturn(this, Object.getPrototypeOf(Bracket).call(this)); | ||
/*istanbul ignore next*/_this5.expr = expr; | ||
/*istanbul ignore next*/return _this5; | ||
_this5.expr = expr; | ||
return _this5; | ||
} | ||
@@ -364,3 +348,2 @@ | ||
/*istanbul ignore next*/ | ||
var Brace = exports.Brace = function (_CodeRep6) { | ||
@@ -370,10 +353,8 @@ _inherits(Brace, _CodeRep6); | ||
function Brace(expr) { | ||
/*istanbul ignore next*/ | ||
_classCallCheck(this, Brace); | ||
/*istanbul ignore next*/ | ||
var _this6 = _possibleConstructorReturn(this, Object.getPrototypeOf(Brace).call(this)); | ||
/*istanbul ignore next*/_this6.expr = expr; | ||
/*istanbul ignore next*/return _this6; | ||
_this6.expr = expr; | ||
return _this6; | ||
} | ||
@@ -399,3 +380,2 @@ | ||
/*istanbul ignore next*/ | ||
var NoIn = exports.NoIn = function (_CodeRep7) { | ||
@@ -405,10 +385,8 @@ _inherits(NoIn, _CodeRep7); | ||
function NoIn(expr) { | ||
/*istanbul ignore next*/ | ||
_classCallCheck(this, NoIn); | ||
/*istanbul ignore next*/ | ||
var _this7 = _possibleConstructorReturn(this, Object.getPrototypeOf(NoIn).call(this)); | ||
/*istanbul ignore next*/_this7.expr = expr; | ||
/*istanbul ignore next*/return _this7; | ||
_this7.expr = expr; | ||
return _this7; | ||
} | ||
@@ -432,3 +410,2 @@ | ||
/*istanbul ignore next*/ | ||
var ContainsIn = exports.ContainsIn = function (_CodeRep8) { | ||
@@ -438,10 +415,8 @@ _inherits(ContainsIn, _CodeRep8); | ||
function ContainsIn(expr) { | ||
/*istanbul ignore next*/ | ||
_classCallCheck(this, ContainsIn); | ||
/*istanbul ignore next*/ | ||
var _this8 = _possibleConstructorReturn(this, Object.getPrototypeOf(ContainsIn).call(this)); | ||
/*istanbul ignore next*/_this8.expr = expr; | ||
/*istanbul ignore next*/return _this8; | ||
_this8.expr = expr; | ||
return _this8; | ||
} | ||
@@ -471,3 +446,2 @@ | ||
/*istanbul ignore next*/ | ||
var Seq = exports.Seq = function (_CodeRep9) { | ||
@@ -477,10 +451,8 @@ _inherits(Seq, _CodeRep9); | ||
function Seq(children) { | ||
/*istanbul ignore next*/ | ||
_classCallCheck(this, Seq); | ||
/*istanbul ignore next*/ | ||
var _this9 = _possibleConstructorReturn(this, Object.getPrototypeOf(Seq).call(this)); | ||
/*istanbul ignore next*/_this9.children = children; | ||
/*istanbul ignore next*/return _this9; | ||
_this9.children = children; | ||
return _this9; | ||
} | ||
@@ -491,3 +463,3 @@ | ||
value: function emit(ts, noIn) { | ||
this.children.forEach(function (cr) /*istanbul ignore next*/{ | ||
this.children.forEach(function (cr) { | ||
return cr.emit(ts, noIn); | ||
@@ -500,3 +472,3 @@ }); | ||
f(this); | ||
this.children.forEach(function (x) /*istanbul ignore next*/{ | ||
this.children.forEach(function (x) { | ||
return x.forEach(f); | ||
@@ -510,3 +482,2 @@ }); | ||
/*istanbul ignore next*/ | ||
var Semi = exports.Semi = function (_Token) { | ||
@@ -516,6 +487,5 @@ _inherits(Semi, _Token); | ||
function Semi() { | ||
/*istanbul ignore next*/ | ||
_classCallCheck(this, Semi); | ||
/*istanbul ignore next*/return _possibleConstructorReturn(this, Object.getPrototypeOf(Semi).call(this, ";")); | ||
return _possibleConstructorReturn(this, Object.getPrototypeOf(Semi).call(this, ";")); | ||
} | ||
@@ -526,3 +496,2 @@ | ||
/*istanbul ignore next*/ | ||
var CommaSep = exports.CommaSep = function (_CodeRep10) { | ||
@@ -532,10 +501,8 @@ _inherits(CommaSep, _CodeRep10); | ||
function CommaSep(children) { | ||
/*istanbul ignore next*/ | ||
_classCallCheck(this, CommaSep); | ||
/*istanbul ignore next*/ | ||
var _this11 = _possibleConstructorReturn(this, Object.getPrototypeOf(CommaSep).call(this)); | ||
/*istanbul ignore next*/_this11.children = children; | ||
/*istanbul ignore next*/return _this11; | ||
_this11.children = children; | ||
return _this11; | ||
} | ||
@@ -560,3 +527,3 @@ | ||
f(this); | ||
this.children.forEach(function (x) /*istanbul ignore next*/{ | ||
this.children.forEach(function (x) { | ||
return x.forEach(f); | ||
@@ -570,3 +537,2 @@ }); | ||
/*istanbul ignore next*/ | ||
var SemiOp = exports.SemiOp = function (_CodeRep11) { | ||
@@ -576,6 +542,5 @@ _inherits(SemiOp, _CodeRep11); | ||
function SemiOp() { | ||
/*istanbul ignore next*/ | ||
_classCallCheck(this, SemiOp); | ||
/*istanbul ignore next*/return _possibleConstructorReturn(this, Object.getPrototypeOf(SemiOp).call(this)); | ||
return _possibleConstructorReturn(this, Object.getPrototypeOf(SemiOp).call(this)); | ||
} | ||
@@ -582,0 +547,0 @@ |
@@ -1,2 +0,2 @@ | ||
/*istanbul ignore next*/"use strict"; | ||
"use strict"; | ||
@@ -8,3 +8,3 @@ Object.defineProperty(exports, "__esModule", { | ||
exports.default = codeGen; | ||
/*istanbul ignore next*/ | ||
var _minimalCodegen = require("./minimal-codegen"); | ||
@@ -18,3 +18,3 @@ | ||
}); | ||
/*istanbul ignore next*/ | ||
var _formattedCodegen = require("./formatted-codegen"); | ||
@@ -28,3 +28,3 @@ | ||
}); | ||
/*istanbul ignore next*/Object.defineProperty(exports, "FormattedCodeGen", { | ||
Object.defineProperty(exports, "FormattedCodeGen", { | ||
enumerable: true, | ||
@@ -35,3 +35,3 @@ get: function get() { | ||
}); | ||
/*istanbul ignore next*/Object.defineProperty(exports, "Sep", { | ||
Object.defineProperty(exports, "Sep", { | ||
enumerable: true, | ||
@@ -42,3 +42,3 @@ get: function get() { | ||
}); | ||
/*istanbul ignore next*/ | ||
var _coderep = require("./coderep"); | ||
@@ -52,3 +52,3 @@ | ||
}); | ||
/*istanbul ignore next*/Object.defineProperty(exports, "getPrecedence", { | ||
Object.defineProperty(exports, "getPrecedence", { | ||
enumerable: true, | ||
@@ -59,3 +59,3 @@ get: function get() { | ||
}); | ||
/*istanbul ignore next*/Object.defineProperty(exports, "escapeStringLiteral", { | ||
Object.defineProperty(exports, "escapeStringLiteral", { | ||
enumerable: true, | ||
@@ -66,3 +66,3 @@ get: function get() { | ||
}); | ||
/*istanbul ignore next*/Object.defineProperty(exports, "CodeRep", { | ||
Object.defineProperty(exports, "CodeRep", { | ||
enumerable: true, | ||
@@ -73,3 +73,3 @@ get: function get() { | ||
}); | ||
/*istanbul ignore next*/Object.defineProperty(exports, "Empty", { | ||
Object.defineProperty(exports, "Empty", { | ||
enumerable: true, | ||
@@ -80,3 +80,3 @@ get: function get() { | ||
}); | ||
/*istanbul ignore next*/Object.defineProperty(exports, "Token", { | ||
Object.defineProperty(exports, "Token", { | ||
enumerable: true, | ||
@@ -87,3 +87,3 @@ get: function get() { | ||
}); | ||
/*istanbul ignore next*/Object.defineProperty(exports, "NumberCodeRep", { | ||
Object.defineProperty(exports, "NumberCodeRep", { | ||
enumerable: true, | ||
@@ -94,3 +94,3 @@ get: function get() { | ||
}); | ||
/*istanbul ignore next*/Object.defineProperty(exports, "Paren", { | ||
Object.defineProperty(exports, "Paren", { | ||
enumerable: true, | ||
@@ -101,3 +101,3 @@ get: function get() { | ||
}); | ||
/*istanbul ignore next*/Object.defineProperty(exports, "Bracket", { | ||
Object.defineProperty(exports, "Bracket", { | ||
enumerable: true, | ||
@@ -108,3 +108,3 @@ get: function get() { | ||
}); | ||
/*istanbul ignore next*/Object.defineProperty(exports, "Brace", { | ||
Object.defineProperty(exports, "Brace", { | ||
enumerable: true, | ||
@@ -115,3 +115,3 @@ get: function get() { | ||
}); | ||
/*istanbul ignore next*/Object.defineProperty(exports, "NoIn", { | ||
Object.defineProperty(exports, "NoIn", { | ||
enumerable: true, | ||
@@ -122,3 +122,3 @@ get: function get() { | ||
}); | ||
/*istanbul ignore next*/Object.defineProperty(exports, "ContainsIn", { | ||
Object.defineProperty(exports, "ContainsIn", { | ||
enumerable: true, | ||
@@ -129,3 +129,3 @@ get: function get() { | ||
}); | ||
/*istanbul ignore next*/Object.defineProperty(exports, "Seq", { | ||
Object.defineProperty(exports, "Seq", { | ||
enumerable: true, | ||
@@ -136,3 +136,3 @@ get: function get() { | ||
}); | ||
/*istanbul ignore next*/Object.defineProperty(exports, "Semi", { | ||
Object.defineProperty(exports, "Semi", { | ||
enumerable: true, | ||
@@ -143,3 +143,3 @@ get: function get() { | ||
}); | ||
/*istanbul ignore next*/Object.defineProperty(exports, "CommaSep", { | ||
Object.defineProperty(exports, "CommaSep", { | ||
enumerable: true, | ||
@@ -150,3 +150,3 @@ get: function get() { | ||
}); | ||
/*istanbul ignore next*/Object.defineProperty(exports, "SemiOp", { | ||
Object.defineProperty(exports, "SemiOp", { | ||
enumerable: true, | ||
@@ -157,3 +157,3 @@ get: function get() { | ||
}); | ||
/*istanbul ignore next*/ | ||
var _shiftReducer = require("shift-reducer"); | ||
@@ -170,8 +170,8 @@ | ||
function codeGen(script) { | ||
/*istanbul ignore next*/var generator = arguments.length <= 1 || arguments[1] === undefined ? new /*istanbul ignore next*/_minimalCodegen2.default() : arguments[1]; | ||
var generator = arguments.length <= 1 || arguments[1] === undefined ? new _minimalCodegen2.default() : arguments[1]; | ||
var ts = new /*istanbul ignore next*/_token_stream.TokenStream(); | ||
var rep = /*istanbul ignore next*/(0, _shiftReducer2.default)(generator, script); | ||
var ts = new _token_stream.TokenStream(); | ||
var rep = (0, _shiftReducer2.default)(generator, script); | ||
rep.emit(ts); | ||
return ts.result; | ||
} |
@@ -1,2 +0,2 @@ | ||
/*istanbul ignore next*/"use strict"; | ||
"use strict"; | ||
@@ -11,5 +11,4 @@ var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
var objectAssign = _interopRequireWildcard(_objectAssign); | ||
var _objectAssign2 = _interopRequireDefault(_objectAssign); | ||
/*istanbul ignore next*/ | ||
var _esutils = require("esutils"); | ||
@@ -19,3 +18,3 @@ | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -27,32 +26,30 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } | ||
function p(node, precedence, a) { | ||
return (/*istanbul ignore next*/(0, _coderep.getPrecedence)(node) < precedence ? paren(a) : a | ||
); | ||
return (0, _coderep.getPrecedence)(node) < precedence ? paren(a) : a; | ||
} | ||
function t(token) { | ||
return new /*istanbul ignore next*/_coderep.Token(token); | ||
return new _coderep.Token(token); | ||
} | ||
function paren(rep) { | ||
return new /*istanbul ignore next*/_coderep.Paren(rep); | ||
return new _coderep.Paren(rep); | ||
} | ||
function brace(rep) { | ||
return new /*istanbul ignore next*/_coderep.Brace(rep); | ||
return new _coderep.Brace(rep); | ||
} | ||
function bracket(rep) { | ||
return new /*istanbul ignore next*/_coderep.Bracket(rep); | ||
return new _coderep.Bracket(rep); | ||
} | ||
function noIn(rep) { | ||
return new /*istanbul ignore next*/_coderep.NoIn(rep); | ||
return new _coderep.NoIn(rep); | ||
} | ||
function markContainsIn(state) { | ||
return state.containsIn ? new /*istanbul ignore next*/_coderep.ContainsIn(state) : state; | ||
return state.containsIn ? new _coderep.ContainsIn(state) : state; | ||
} | ||
function seq() { | ||
/*istanbul ignore next*/ | ||
for (var _len = arguments.length, reps = Array(_len), _key = 0; _key < _len; _key++) { | ||
@@ -62,19 +59,19 @@ reps[_key] = arguments[_key]; | ||
return new /*istanbul ignore next*/_coderep.Seq(reps); | ||
return new _coderep.Seq(reps); | ||
} | ||
function semi() { | ||
return new /*istanbul ignore next*/_coderep.Semi(); | ||
return new _coderep.Semi(); | ||
} | ||
function semiOp() { | ||
return new /*istanbul ignore next*/_coderep.SemiOp(); | ||
return new _coderep.SemiOp(); | ||
} | ||
function empty() { | ||
return new /*istanbul ignore next*/_coderep.Empty(); | ||
return new _coderep.Empty(); | ||
} | ||
function commaSep(pieces) { | ||
return new /*istanbul ignore next*/_coderep.CommaSep(pieces); | ||
return new _coderep.CommaSep(pieces); | ||
} | ||
@@ -86,3 +83,2 @@ | ||
/*istanbul ignore next*/ | ||
var MinimalCodeGen = function () { | ||
@@ -104,3 +100,3 @@ function MinimalCodeGen() { | ||
value: function reduceArrayExpression(node, _ref) { | ||
/*istanbul ignore next*/var elements = _ref.elements; | ||
var elements = _ref.elements; | ||
@@ -120,5 +116,5 @@ if (elements.length === 0) { | ||
value: function reduceSpreadElement(node, _ref2) { | ||
/*istanbul ignore next*/var expression = _ref2.expression; | ||
var expression = _ref2.expression; | ||
return seq(t("..."), p(node.expression, /*istanbul ignore next*/_coderep.Precedence.Assignment, expression)); | ||
return seq(t("..."), p(node.expression, _coderep.Precedence.Assignment, expression)); | ||
} | ||
@@ -128,4 +124,4 @@ }, { | ||
value: function reduceAssignmentExpression(node, _ref3) { | ||
/*istanbul ignore next*/var binding = _ref3.binding; | ||
/*istanbul ignore next*/var expression = _ref3.expression; | ||
var binding = _ref3.binding; | ||
var expression = _ref3.expression; | ||
@@ -138,7 +134,7 @@ var leftCode = binding; | ||
var startsWithFunctionOrClass = binding.startsWithFunctionOrClass; | ||
if ( /*istanbul ignore next*/(0, _coderep.getPrecedence)(node.expression) < /*istanbul ignore next*/(0, _coderep.getPrecedence)(node)) { | ||
if ((0, _coderep.getPrecedence)(node.expression) < (0, _coderep.getPrecedence)(node)) { | ||
rightCode = paren(rightCode); | ||
containsIn = false; | ||
} | ||
return objectAssign(seq(leftCode, t("="), rightCode), { containsIn: containsIn, startsWithCurly: startsWithCurly, startsWithLetSquareBracket: startsWithLetSquareBracket, startsWithFunctionOrClass: startsWithFunctionOrClass }); | ||
return (0, _objectAssign2.default)(seq(leftCode, t("="), rightCode), { containsIn: containsIn, startsWithCurly: startsWithCurly, startsWithLetSquareBracket: startsWithLetSquareBracket, startsWithFunctionOrClass: startsWithFunctionOrClass }); | ||
} | ||
@@ -148,4 +144,4 @@ }, { | ||
value: function reduceCompoundAssignmentExpression(node, _ref4) { | ||
/*istanbul ignore next*/var binding = _ref4.binding; | ||
/*istanbul ignore next*/var expression = _ref4.expression; | ||
var binding = _ref4.binding; | ||
var expression = _ref4.expression; | ||
@@ -158,7 +154,7 @@ var leftCode = binding; | ||
var startsWithFunctionOrClass = binding.startsWithFunctionOrClass; | ||
if ( /*istanbul ignore next*/(0, _coderep.getPrecedence)(node.expression) < /*istanbul ignore next*/(0, _coderep.getPrecedence)(node)) { | ||
if ((0, _coderep.getPrecedence)(node.expression) < (0, _coderep.getPrecedence)(node)) { | ||
rightCode = paren(rightCode); | ||
containsIn = false; | ||
} | ||
return objectAssign(seq(leftCode, t(node.operator), rightCode), { containsIn: containsIn, startsWithCurly: startsWithCurly, startsWithLetSquareBracket: startsWithLetSquareBracket, startsWithFunctionOrClass: startsWithFunctionOrClass }); | ||
return (0, _objectAssign2.default)(seq(leftCode, t(node.operator), rightCode), { containsIn: containsIn, startsWithCurly: startsWithCurly, startsWithLetSquareBracket: startsWithLetSquareBracket, startsWithFunctionOrClass: startsWithFunctionOrClass }); | ||
} | ||
@@ -168,4 +164,4 @@ }, { | ||
value: function reduceBinaryExpression(node, _ref5) { | ||
/*istanbul ignore next*/var left = _ref5.left; | ||
/*istanbul ignore next*/var right = _ref5.right; | ||
var left = _ref5.left; | ||
var right = _ref5.right; | ||
@@ -177,3 +173,3 @@ var leftCode = left; | ||
var leftContainsIn = left.containsIn; | ||
if ( /*istanbul ignore next*/(0, _coderep.getPrecedence)(node.left) < /*istanbul ignore next*/(0, _coderep.getPrecedence)(node)) { | ||
if ((0, _coderep.getPrecedence)(node.left) < (0, _coderep.getPrecedence)(node)) { | ||
leftCode = paren(leftCode); | ||
@@ -187,7 +183,7 @@ startsWithCurly = false; | ||
var rightContainsIn = right.containsIn; | ||
if ( /*istanbul ignore next*/(0, _coderep.getPrecedence)(node.right) <= /*istanbul ignore next*/(0, _coderep.getPrecedence)(node)) { | ||
if ((0, _coderep.getPrecedence)(node.right) <= (0, _coderep.getPrecedence)(node)) { | ||
rightCode = paren(rightCode); | ||
rightContainsIn = false; | ||
} | ||
return objectAssign(seq(leftCode, t(node.operator), rightCode), { | ||
return (0, _objectAssign2.default)(seq(leftCode, t(node.operator), rightCode), { | ||
containsIn: leftContainsIn || rightContainsIn || node.operator === "in", | ||
@@ -203,4 +199,4 @@ containsGroup: node.operator == ",", | ||
value: function reduceBindingWithDefault(node, _ref6) { | ||
/*istanbul ignore next*/var binding = _ref6.binding; | ||
/*istanbul ignore next*/var init = _ref6.init; | ||
var binding = _ref6.binding; | ||
var init = _ref6.init; | ||
@@ -221,6 +217,6 @@ return seq(binding, t("="), init); | ||
value: function reduceArrayBinding(node, _ref7) { | ||
/*istanbul ignore next*/var elements = _ref7.elements; | ||
/*istanbul ignore next*/var restElement = _ref7.restElement; | ||
var elements = _ref7.elements; | ||
var restElement = _ref7.restElement; | ||
var content = /*istanbul ignore next*/undefined; | ||
var content = undefined; | ||
if (elements.length === 0) { | ||
@@ -240,3 +236,3 @@ content = restElement == null ? empty() : seq(t("..."), restElement); | ||
value: function reduceObjectBinding(node, _ref8) { | ||
/*istanbul ignore next*/var properties = _ref8.properties; | ||
var properties = _ref8.properties; | ||
@@ -250,4 +246,4 @@ var state = brace(commaSep(properties)); | ||
value: function reduceBindingPropertyIdentifier(node, _ref9) { | ||
/*istanbul ignore next*/var binding = _ref9.binding; | ||
/*istanbul ignore next*/var init = _ref9.init; | ||
var binding = _ref9.binding; | ||
var init = _ref9.init; | ||
@@ -260,4 +256,4 @@ if (node.init == null) return binding; | ||
value: function reduceBindingPropertyProperty(node, _ref10) { | ||
/*istanbul ignore next*/var name = _ref10.name; | ||
/*istanbul ignore next*/var binding = _ref10.binding; | ||
var name = _ref10.name; | ||
var binding = _ref10.binding; | ||
@@ -269,5 +265,5 @@ return seq(name, t(":"), binding); | ||
value: function reduceBlock(node, _ref11) { | ||
/*istanbul ignore next*/var statements = _ref11.statements; | ||
var statements = _ref11.statements; | ||
return brace( /*istanbul ignore next*/seq.apply( /*istanbul ignore next*/undefined, _toConsumableArray(statements))); | ||
return brace(seq.apply(undefined, _toConsumableArray(statements))); | ||
} | ||
@@ -277,3 +273,3 @@ }, { | ||
value: function reduceBlockStatement(node, _ref12) { | ||
/*istanbul ignore next*/var block = _ref12.block; | ||
var block = _ref12.block; | ||
@@ -285,3 +281,3 @@ return block; | ||
value: function reduceBreakStatement(node, _ref13) { | ||
/*istanbul ignore next*/var label = _ref13.label; | ||
var label = _ref13.label; | ||
@@ -293,6 +289,6 @@ return seq(t("break"), label ? t(label) : empty(), semiOp()); | ||
value: function reduceCallExpression(node, _ref14) { | ||
/*istanbul ignore next*/var callee = _ref14.callee; | ||
/*istanbul ignore next*/var args = _ref14.arguments; | ||
var callee = _ref14.callee; | ||
var args = _ref14.arguments; | ||
return objectAssign(seq(p(node.callee, /*istanbul ignore next*/(0, _coderep.getPrecedence)(node), callee), paren(commaSep(args))), { | ||
return (0, _objectAssign2.default)(seq(p(node.callee, (0, _coderep.getPrecedence)(node), callee), paren(commaSep(args))), { | ||
startsWithCurly: callee.startsWithCurly, | ||
@@ -306,4 +302,4 @@ startsWithLetSquareBracket: callee.startsWithLetSquareBracket, | ||
value: function reduceCatchClause(node, _ref15) { | ||
/*istanbul ignore next*/var binding = _ref15.binding; | ||
/*istanbul ignore next*/var body = _ref15.body; | ||
var binding = _ref15.binding; | ||
var body = _ref15.body; | ||
@@ -315,5 +311,5 @@ return seq(t("catch"), paren(binding), body); | ||
value: function reduceClassDeclaration(node, _ref16) { | ||
/*istanbul ignore next*/var name = _ref16.name; | ||
/*istanbul ignore next*/var _super = _ref16.super; | ||
/*istanbul ignore next*/var elements = _ref16.elements; | ||
var name = _ref16.name; | ||
var _super = _ref16.super; | ||
var elements = _ref16.elements; | ||
@@ -324,3 +320,3 @@ var state = seq(t("class"), name); | ||
} | ||
state = /*istanbul ignore next*/seq.apply( /*istanbul ignore next*/undefined, [state, t("{")].concat(_toConsumableArray(elements), [t("}")])); | ||
state = seq.apply(undefined, [state, t("{")].concat(_toConsumableArray(elements), [t("}")])); | ||
return state; | ||
@@ -331,5 +327,5 @@ } | ||
value: function reduceClassExpression(node, _ref17) { | ||
/*istanbul ignore next*/var name = _ref17.name; | ||
/*istanbul ignore next*/var _super = _ref17.super; | ||
/*istanbul ignore next*/var elements = _ref17.elements; | ||
var name = _ref17.name; | ||
var _super = _ref17.super; | ||
var elements = _ref17.elements; | ||
@@ -343,3 +339,3 @@ var state = t("class"); | ||
} | ||
state = /*istanbul ignore next*/seq.apply( /*istanbul ignore next*/undefined, [state, t("{")].concat(_toConsumableArray(elements), [t("}")])); | ||
state = seq.apply(undefined, [state, t("{")].concat(_toConsumableArray(elements), [t("}")])); | ||
state.startsWithFunctionOrClass = true; | ||
@@ -351,3 +347,3 @@ return state; | ||
value: function reduceClassElement(node, _ref18) { | ||
/*istanbul ignore next*/var method = _ref18.method; | ||
var method = _ref18.method; | ||
@@ -360,7 +356,7 @@ if (!node.isStatic) return method; | ||
value: function reduceComputedMemberExpression(node, _ref19) { | ||
/*istanbul ignore next*/var object = _ref19.object; | ||
/*istanbul ignore next*/var expression = _ref19.expression; | ||
var object = _ref19.object; | ||
var expression = _ref19.expression; | ||
var startsWithLetSquareBracket = object.startsWithLetSquareBracket || node.object.type === "IdentifierExpression" && node.object.name === "let"; | ||
return objectAssign(seq(p(node.object, /*istanbul ignore next*/(0, _coderep.getPrecedence)(node), object), bracket(expression)), { | ||
return (0, _objectAssign2.default)(seq(p(node.object, (0, _coderep.getPrecedence)(node), object), bracket(expression)), { | ||
startsWithLet: object.startsWithLet, | ||
@@ -375,3 +371,3 @@ startsWithLetSquareBracket: startsWithLetSquareBracket, | ||
value: function reduceComputedPropertyName(node, _ref20) { | ||
/*istanbul ignore next*/var expression = _ref20.expression; | ||
var expression = _ref20.expression; | ||
@@ -383,5 +379,5 @@ return bracket(expression); | ||
value: function reduceConditionalExpression(node, _ref21) { | ||
/*istanbul ignore next*/var test = _ref21.test; | ||
/*istanbul ignore next*/var consequent = _ref21.consequent; | ||
/*istanbul ignore next*/var alternate = _ref21.alternate; | ||
var test = _ref21.test; | ||
var consequent = _ref21.consequent; | ||
var alternate = _ref21.alternate; | ||
@@ -392,3 +388,3 @@ var containsIn = test.containsIn || alternate.containsIn; | ||
var startsWithFunctionOrClass = test.startsWithFunctionOrClass; | ||
return objectAssign(seq(p(node.test, /*istanbul ignore next*/_coderep.Precedence.LogicalOR, test), t("?"), p(node.consequent, /*istanbul ignore next*/_coderep.Precedence.Assignment, consequent), t(":"), p(node.alternate, /*istanbul ignore next*/_coderep.Precedence.Assignment, alternate)), { | ||
return (0, _objectAssign2.default)(seq(p(node.test, _coderep.Precedence.LogicalOR, test), t("?"), p(node.consequent, _coderep.Precedence.Assignment, consequent), t(":"), p(node.alternate, _coderep.Precedence.Assignment, alternate)), { | ||
containsIn: containsIn, | ||
@@ -403,3 +399,3 @@ startsWithCurly: startsWithCurly, | ||
value: function reduceContinueStatement(node, _ref22) { | ||
/*istanbul ignore next*/var label = _ref22.label; | ||
var label = _ref22.label; | ||
@@ -411,4 +407,4 @@ return seq(t("continue"), label ? t(label) : empty(), semiOp()); | ||
value: function reduceDataProperty(node, _ref23) { | ||
/*istanbul ignore next*/var name = _ref23.name; | ||
/*istanbul ignore next*/var expression = _ref23.expression; | ||
var name = _ref23.name; | ||
var expression = _ref23.expression; | ||
@@ -425,4 +421,4 @@ return seq(name, t(":"), getAssignmentExpr(expression)); | ||
value: function reduceDoWhileStatement(node, _ref24) { | ||
/*istanbul ignore next*/var body = _ref24.body; | ||
/*istanbul ignore next*/var test = _ref24.test; | ||
var body = _ref24.body; | ||
var test = _ref24.test; | ||
@@ -439,3 +435,3 @@ return seq(t("do"), body, t("while"), paren(test), semiOp()); | ||
value: function reduceExpressionStatement(node, _ref25) { | ||
/*istanbul ignore next*/var expression = _ref25.expression; | ||
var expression = _ref25.expression; | ||
@@ -448,5 +444,5 @@ var needsParens = expression.startsWithCurly || expression.startsWithLetSquareBracket || expression.startsWithFunctionOrClass; | ||
value: function reduceForInStatement(node, _ref26) { | ||
/*istanbul ignore next*/var left = _ref26.left; | ||
/*istanbul ignore next*/var right = _ref26.right; | ||
/*istanbul ignore next*/var body = _ref26.body; | ||
var left = _ref26.left; | ||
var right = _ref26.right; | ||
var body = _ref26.body; | ||
@@ -464,3 +460,3 @@ var leftP = left; | ||
} | ||
return objectAssign(seq(t("for"), paren(seq(leftP, t("in"), right)), body), { endsWithMissingElse: body.endsWithMissingElse }); | ||
return (0, _objectAssign2.default)(seq(t("for"), paren(seq(leftP, t("in"), right)), body), { endsWithMissingElse: body.endsWithMissingElse }); | ||
} | ||
@@ -470,8 +466,8 @@ }, { | ||
value: function reduceForOfStatement(node, _ref27) { | ||
/*istanbul ignore next*/var left = _ref27.left; | ||
/*istanbul ignore next*/var right = _ref27.right; | ||
/*istanbul ignore next*/var body = _ref27.body; | ||
var left = _ref27.left; | ||
var right = _ref27.right; | ||
var body = _ref27.body; | ||
left = node.left.type === "VariableDeclaration" ? noIn(markContainsIn(left)) : left; | ||
return objectAssign(seq(t("for"), paren(seq(left.startsWithLet ? paren(left) : left, t("of"), right)), body), { endsWithMissingElse: body.endsWithMissingElse }); | ||
return (0, _objectAssign2.default)(seq(t("for"), paren(seq(left.startsWithLet ? paren(left) : left, t("of"), right)), body), { endsWithMissingElse: body.endsWithMissingElse }); | ||
} | ||
@@ -481,8 +477,8 @@ }, { | ||
value: function reduceForStatement(node, _ref28) { | ||
/*istanbul ignore next*/var init = _ref28.init; | ||
/*istanbul ignore next*/var test = _ref28.test; | ||
/*istanbul ignore next*/var update = _ref28.update; | ||
/*istanbul ignore next*/var body = _ref28.body; | ||
var init = _ref28.init; | ||
var test = _ref28.test; | ||
var update = _ref28.update; | ||
var body = _ref28.body; | ||
return objectAssign(seq(t("for"), paren(seq(init ? noIn(markContainsIn(init)) : empty(), semi(), test || empty(), semi(), update || empty())), body), { | ||
return (0, _objectAssign2.default)(seq(t("for"), paren(seq(init ? noIn(markContainsIn(init)) : empty(), semi(), test || empty(), semi(), update || empty())), body), { | ||
endsWithMissingElse: body.endsWithMissingElse | ||
@@ -494,4 +490,4 @@ }); | ||
value: function reduceFunctionBody(node, _ref29) { | ||
/*istanbul ignore next*/var directives = _ref29.directives; | ||
/*istanbul ignore next*/var statements = _ref29.statements; | ||
var directives = _ref29.directives; | ||
var statements = _ref29.statements; | ||
@@ -501,4 +497,3 @@ if (statements.length) { | ||
} | ||
return (/*istanbul ignore next*/seq.apply( /*istanbul ignore next*/undefined, _toConsumableArray(directives).concat(_toConsumableArray(statements))) | ||
); | ||
return seq.apply(undefined, _toConsumableArray(directives).concat(_toConsumableArray(statements))); | ||
} | ||
@@ -508,5 +503,5 @@ }, { | ||
value: function reduceFunctionDeclaration(node, _ref30) { | ||
/*istanbul ignore next*/var name = _ref30.name; | ||
/*istanbul ignore next*/var params = _ref30.params; | ||
/*istanbul ignore next*/var body = _ref30.body; | ||
var name = _ref30.name; | ||
var params = _ref30.params; | ||
var body = _ref30.body; | ||
@@ -518,5 +513,5 @@ return seq(t("function"), node.isGenerator ? t("*") : empty(), node.name.name === "*default*" ? empty() : name, paren(params), brace(body)); | ||
value: function reduceFunctionExpression(node, _ref31) { | ||
/*istanbul ignore next*/var name = _ref31.name; | ||
/*istanbul ignore next*/var params = _ref31.params; | ||
/*istanbul ignore next*/var body = _ref31.body; | ||
var name = _ref31.name; | ||
var params = _ref31.params; | ||
var body = _ref31.body; | ||
@@ -530,4 +525,4 @@ var state = seq(t("function"), node.isGenerator ? t("*") : empty(), name ? name : empty(), paren(params), brace(body)); | ||
value: function reduceFormalParameters(node, _ref32) { | ||
/*istanbul ignore next*/var items = _ref32.items; | ||
/*istanbul ignore next*/var rest = _ref32.rest; | ||
var items = _ref32.items; | ||
var rest = _ref32.rest; | ||
@@ -539,4 +534,4 @@ return commaSep(items.concat(rest == null ? [] : [seq(t("..."), rest)])); | ||
value: function reduceArrowExpression(node, _ref33) { | ||
/*istanbul ignore next*/var params = _ref33.params; | ||
/*istanbul ignore next*/var body = _ref33.body; | ||
var params = _ref33.params; | ||
var body = _ref33.body; | ||
@@ -551,3 +546,3 @@ if (node.params.rest != null || node.params.items.length !== 1 || node.params.items[0].type !== "BindingIdentifier") { | ||
} | ||
return seq(params, t("=>"), p(node.body, /*istanbul ignore next*/_coderep.Precedence.Assignment, body)); | ||
return seq(params, t("=>"), p(node.body, _coderep.Precedence.Assignment, body)); | ||
} | ||
@@ -557,4 +552,4 @@ }, { | ||
value: function reduceGetter(node, _ref34) { | ||
/*istanbul ignore next*/var name = _ref34.name; | ||
/*istanbul ignore next*/var body = _ref34.body; | ||
var name = _ref34.name; | ||
var body = _ref34.body; | ||
@@ -575,5 +570,5 @@ return seq(t("get"), name, paren(empty()), brace(body)); | ||
value: function reduceIfStatement(node, _ref35) { | ||
/*istanbul ignore next*/var test = _ref35.test; | ||
/*istanbul ignore next*/var consequent = _ref35.consequent; | ||
/*istanbul ignore next*/var alternate = _ref35.alternate; | ||
var test = _ref35.test; | ||
var consequent = _ref35.consequent; | ||
var alternate = _ref35.alternate; | ||
@@ -583,3 +578,3 @@ if (alternate && consequent.endsWithMissingElse) { | ||
} | ||
return objectAssign(seq(t("if"), paren(test), consequent, alternate ? seq(t("else"), alternate) : empty()), { endsWithMissingElse: alternate ? alternate.endsWithMissingElse : true }); | ||
return (0, _objectAssign2.default)(seq(t("if"), paren(test), consequent, alternate ? seq(t("else"), alternate) : empty()), { endsWithMissingElse: alternate ? alternate.endsWithMissingElse : true }); | ||
} | ||
@@ -589,4 +584,4 @@ }, { | ||
value: function reduceImport(node, _ref36) { | ||
/*istanbul ignore next*/var defaultBinding = _ref36.defaultBinding; | ||
/*istanbul ignore next*/var namedImports = _ref36.namedImports; | ||
var defaultBinding = _ref36.defaultBinding; | ||
var namedImports = _ref36.namedImports; | ||
@@ -601,5 +596,5 @@ var bindings = []; | ||
if (bindings.length === 0) { | ||
return seq(t("import"), t( /*istanbul ignore next*/(0, _coderep.escapeStringLiteral)(node.moduleSpecifier)), semiOp()); | ||
return seq(t("import"), t((0, _coderep.escapeStringLiteral)(node.moduleSpecifier)), semiOp()); | ||
} | ||
return seq(t("import"), commaSep(bindings), t("from"), t( /*istanbul ignore next*/(0, _coderep.escapeStringLiteral)(node.moduleSpecifier)), semiOp()); | ||
return seq(t("import"), commaSep(bindings), t("from"), t((0, _coderep.escapeStringLiteral)(node.moduleSpecifier)), semiOp()); | ||
} | ||
@@ -609,6 +604,6 @@ }, { | ||
value: function reduceImportNamespace(node, _ref37) { | ||
/*istanbul ignore next*/var defaultBinding = _ref37.defaultBinding; | ||
/*istanbul ignore next*/var namespaceBinding = _ref37.namespaceBinding; | ||
var defaultBinding = _ref37.defaultBinding; | ||
var namespaceBinding = _ref37.namespaceBinding; | ||
return seq(t("import"), defaultBinding == null ? empty() : seq(defaultBinding, t(",")), t("*"), t("as"), namespaceBinding, t("from"), t( /*istanbul ignore next*/(0, _coderep.escapeStringLiteral)(node.moduleSpecifier)), semiOp()); | ||
return seq(t("import"), defaultBinding == null ? empty() : seq(defaultBinding, t(",")), t("*"), t("as"), namespaceBinding, t("from"), t((0, _coderep.escapeStringLiteral)(node.moduleSpecifier)), semiOp()); | ||
} | ||
@@ -618,3 +613,3 @@ }, { | ||
value: function reduceImportSpecifier(node, _ref38) { | ||
/*istanbul ignore next*/var binding = _ref38.binding; | ||
var binding = _ref38.binding; | ||
@@ -627,3 +622,3 @@ if (node.name == null) return binding; | ||
value: function reduceExportAllFrom(node) { | ||
return seq(t("export"), t("*"), t("from"), t( /*istanbul ignore next*/(0, _coderep.escapeStringLiteral)(node.moduleSpecifier)), semiOp()); | ||
return seq(t("export"), t("*"), t("from"), t((0, _coderep.escapeStringLiteral)(node.moduleSpecifier)), semiOp()); | ||
} | ||
@@ -633,5 +628,5 @@ }, { | ||
value: function reduceExportFrom(node, _ref39) { | ||
/*istanbul ignore next*/var namedExports = _ref39.namedExports; | ||
var namedExports = _ref39.namedExports; | ||
return seq(t("export"), brace(commaSep(namedExports)), node.moduleSpecifier == null ? empty() : seq(t("from"), t( /*istanbul ignore next*/(0, _coderep.escapeStringLiteral)(node.moduleSpecifier)), semiOp())); | ||
return seq(t("export"), brace(commaSep(namedExports)), node.moduleSpecifier == null ? empty() : seq(t("from"), t((0, _coderep.escapeStringLiteral)(node.moduleSpecifier)), semiOp())); | ||
} | ||
@@ -641,3 +636,3 @@ }, { | ||
value: function reduceExport(node, _ref40) { | ||
/*istanbul ignore next*/var declaration = _ref40.declaration; | ||
var declaration = _ref40.declaration; | ||
@@ -656,3 +651,3 @@ switch (node.declaration.type) { | ||
value: function reduceExportDefault(node, _ref41) { | ||
/*istanbul ignore next*/var body = _ref41.body; | ||
var body = _ref41.body; | ||
@@ -678,6 +673,6 @@ body = body.startsWithFunctionOrClass ? paren(body) : body; | ||
value: function reduceLabeledStatement(node, _ref42) { | ||
/*istanbul ignore next*/var label = _ref42.label; | ||
/*istanbul ignore next*/var body = _ref42.body; | ||
var label = _ref42.label; | ||
var body = _ref42.body; | ||
return objectAssign(seq(t(label + ":"), body), { endsWithMissingElse: body.endsWithMissingElse }); | ||
return (0, _objectAssign2.default)(seq(t(label + ":"), body), { endsWithMissingElse: body.endsWithMissingElse }); | ||
} | ||
@@ -702,3 +697,3 @@ }, { | ||
value: function reduceLiteralNumericExpression(node) { | ||
return new /*istanbul ignore next*/_coderep.NumberCodeRep(node.value); | ||
return new _coderep.NumberCodeRep(node.value); | ||
} | ||
@@ -708,3 +703,3 @@ }, { | ||
value: function reduceLiteralRegExpExpression(node) { | ||
return t( /*istanbul ignore next*/"/" + node.pattern + "/" + node.flags); | ||
return t("/" + node.pattern + "/" + node.flags); | ||
} | ||
@@ -714,3 +709,3 @@ }, { | ||
value: function reduceLiteralStringExpression(node) { | ||
return t( /*istanbul ignore next*/(0, _coderep.escapeStringLiteral)(node.value)); | ||
return t((0, _coderep.escapeStringLiteral)(node.value)); | ||
} | ||
@@ -720,5 +715,5 @@ }, { | ||
value: function reduceMethod(node, _ref43) { | ||
/*istanbul ignore next*/var name = _ref43.name; | ||
/*istanbul ignore next*/var params = _ref43.params; | ||
/*istanbul ignore next*/var body = _ref43.body; | ||
var name = _ref43.name; | ||
var params = _ref43.params; | ||
var body = _ref43.body; | ||
@@ -730,4 +725,4 @@ return seq(node.isGenerator ? t("*") : empty(), name, paren(params), brace(body)); | ||
value: function reduceModule(node, _ref44) { | ||
/*istanbul ignore next*/var directives = _ref44.directives; | ||
/*istanbul ignore next*/var items = _ref44.items; | ||
var directives = _ref44.directives; | ||
var items = _ref44.items; | ||
@@ -737,4 +732,3 @@ if (items.length) { | ||
} | ||
return (/*istanbul ignore next*/seq.apply( /*istanbul ignore next*/undefined, _toConsumableArray(directives).concat(_toConsumableArray(items))) | ||
); | ||
return seq.apply(undefined, _toConsumableArray(directives).concat(_toConsumableArray(items))); | ||
} | ||
@@ -744,6 +738,6 @@ }, { | ||
value: function reduceNewExpression(node, _ref45) { | ||
/*istanbul ignore next*/var callee = _ref45.callee; | ||
/*istanbul ignore next*/var args = _ref45.arguments; | ||
var callee = _ref45.callee; | ||
var args = _ref45.arguments; | ||
var calleeRep = /*istanbul ignore next*/(0, _coderep.getPrecedence)(node.callee) == /*istanbul ignore next*/_coderep.Precedence.Call ? paren(callee) : p(node.callee, /*istanbul ignore next*/(0, _coderep.getPrecedence)(node), callee); | ||
var calleeRep = (0, _coderep.getPrecedence)(node.callee) == _coderep.Precedence.Call ? paren(callee) : p(node.callee, (0, _coderep.getPrecedence)(node), callee); | ||
return seq(t("new"), calleeRep, args.length === 0 ? empty() : paren(commaSep(args))); | ||
@@ -759,3 +753,3 @@ } | ||
value: function reduceObjectExpression(node, _ref46) { | ||
/*istanbul ignore next*/var properties = _ref46.properties; | ||
var properties = _ref46.properties; | ||
@@ -769,9 +763,8 @@ var state = brace(commaSep(properties)); | ||
value: function reduceUpdateExpression(node, _ref47) { | ||
/*istanbul ignore next*/var operand = _ref47.operand; | ||
var operand = _ref47.operand; | ||
if (node.isPrefix) { | ||
return (/*istanbul ignore next*/this.reduceUnaryExpression. /*istanbul ignore next*/apply(this, arguments) | ||
); | ||
return this.reduceUnaryExpression.apply(this, arguments); | ||
} else { | ||
return objectAssign(seq(p(node.operand, /*istanbul ignore next*/_coderep.Precedence.New, operand), t(node.operator)), { | ||
return (0, _objectAssign2.default)(seq(p(node.operand, _coderep.Precedence.New, operand), t(node.operator)), { | ||
startsWithCurly: operand.startsWithCurly, | ||
@@ -786,5 +779,5 @@ startsWithLetSquareBracket: operand.startsWithLetSquareBracket, | ||
value: function reduceUnaryExpression(node, _ref48) { | ||
/*istanbul ignore next*/var operand = _ref48.operand; | ||
var operand = _ref48.operand; | ||
return seq(t(node.operator), p(node.operand, /*istanbul ignore next*/(0, _coderep.getPrecedence)(node), operand)); | ||
return seq(t(node.operator), p(node.operand, (0, _coderep.getPrecedence)(node), operand)); | ||
} | ||
@@ -794,3 +787,3 @@ }, { | ||
value: function reduceReturnStatement(node, _ref49) { | ||
/*istanbul ignore next*/var expression = _ref49.expression; | ||
var expression = _ref49.expression; | ||
@@ -802,4 +795,4 @@ return seq(t("return"), expression || empty(), semiOp()); | ||
value: function reduceScript(node, _ref50) { | ||
/*istanbul ignore next*/var directives = _ref50.directives; | ||
/*istanbul ignore next*/var statements = _ref50.statements; | ||
var directives = _ref50.directives; | ||
var statements = _ref50.statements; | ||
@@ -809,4 +802,3 @@ if (statements.length) { | ||
} | ||
return (/*istanbul ignore next*/seq.apply( /*istanbul ignore next*/undefined, _toConsumableArray(directives).concat(_toConsumableArray(statements))) | ||
); | ||
return seq.apply(undefined, _toConsumableArray(directives).concat(_toConsumableArray(statements))); | ||
} | ||
@@ -816,5 +808,5 @@ }, { | ||
value: function reduceSetter(node, _ref51) { | ||
/*istanbul ignore next*/var name = _ref51.name; | ||
/*istanbul ignore next*/var param = _ref51.param; | ||
/*istanbul ignore next*/var body = _ref51.body; | ||
var name = _ref51.name; | ||
var param = _ref51.param; | ||
var body = _ref51.body; | ||
@@ -831,6 +823,6 @@ return seq(t("set"), name, paren(param), brace(body)); | ||
value: function reduceStaticMemberExpression(node, _ref52) { | ||
/*istanbul ignore next*/var object = _ref52.object; | ||
/*istanbul ignore next*/var property = _ref52.property; | ||
var object = _ref52.object; | ||
var property = _ref52.property; | ||
var state = seq(p(node.object, /*istanbul ignore next*/(0, _coderep.getPrecedence)(node), object), t("."), t(property)); | ||
var state = seq(p(node.object, (0, _coderep.getPrecedence)(node), object), t("."), t(property)); | ||
state.startsWithLet = object.startsWithLet; | ||
@@ -846,8 +838,8 @@ state.startsWithCurly = object.startsWithCurly; | ||
var n; | ||
if ( /*istanbul ignore next*/_esutils.keyword.isIdentifierNameES6(node.value)) { | ||
if (_esutils.keyword.isIdentifierNameES6(node.value)) { | ||
return t(node.value); | ||
} else if (n = parseFloat(node.value), n === n) { | ||
return new /*istanbul ignore next*/_coderep.NumberCodeRep(n); | ||
return new _coderep.NumberCodeRep(n); | ||
} | ||
return t( /*istanbul ignore next*/(0, _coderep.escapeStringLiteral)(node.value)); | ||
return t((0, _coderep.escapeStringLiteral)(node.value)); | ||
} | ||
@@ -862,6 +854,6 @@ }, { | ||
value: function reduceSwitchCase(node, _ref53) { | ||
/*istanbul ignore next*/var test = _ref53.test; | ||
/*istanbul ignore next*/var consequent = _ref53.consequent; | ||
var test = _ref53.test; | ||
var consequent = _ref53.consequent; | ||
return seq(t("case"), test, t(":"), /*istanbul ignore next*/seq.apply( /*istanbul ignore next*/undefined, _toConsumableArray(consequent))); | ||
return seq(t("case"), test, t(":"), seq.apply(undefined, _toConsumableArray(consequent))); | ||
} | ||
@@ -871,5 +863,5 @@ }, { | ||
value: function reduceSwitchDefault(node, _ref54) { | ||
/*istanbul ignore next*/var consequent = _ref54.consequent; | ||
var consequent = _ref54.consequent; | ||
return seq(t("default:"), /*istanbul ignore next*/seq.apply( /*istanbul ignore next*/undefined, _toConsumableArray(consequent))); | ||
return seq(t("default:"), seq.apply(undefined, _toConsumableArray(consequent))); | ||
} | ||
@@ -879,6 +871,6 @@ }, { | ||
value: function reduceSwitchStatement(node, _ref55) { | ||
/*istanbul ignore next*/var discriminant = _ref55.discriminant; | ||
/*istanbul ignore next*/var cases = _ref55.cases; | ||
var discriminant = _ref55.discriminant; | ||
var cases = _ref55.cases; | ||
return seq(t("switch"), paren(discriminant), brace( /*istanbul ignore next*/seq.apply( /*istanbul ignore next*/undefined, _toConsumableArray(cases)))); | ||
return seq(t("switch"), paren(discriminant), brace(seq.apply(undefined, _toConsumableArray(cases)))); | ||
} | ||
@@ -888,8 +880,8 @@ }, { | ||
value: function reduceSwitchStatementWithDefault(node, _ref56) { | ||
/*istanbul ignore next*/var discriminant = _ref56.discriminant; | ||
/*istanbul ignore next*/var preDefaultCases = _ref56.preDefaultCases; | ||
/*istanbul ignore next*/var defaultCase = _ref56.defaultCase; | ||
/*istanbul ignore next*/var postDefaultCases = _ref56.postDefaultCases; | ||
var discriminant = _ref56.discriminant; | ||
var preDefaultCases = _ref56.preDefaultCases; | ||
var defaultCase = _ref56.defaultCase; | ||
var postDefaultCases = _ref56.postDefaultCases; | ||
return seq(t("switch"), paren(discriminant), brace( /*istanbul ignore next*/seq.apply( /*istanbul ignore next*/undefined, _toConsumableArray(preDefaultCases).concat([defaultCase], _toConsumableArray(postDefaultCases))))); | ||
return seq(t("switch"), paren(discriminant), brace(seq.apply(undefined, _toConsumableArray(preDefaultCases).concat([defaultCase], _toConsumableArray(postDefaultCases))))); | ||
} | ||
@@ -899,6 +891,6 @@ }, { | ||
value: function reduceTemplateExpression(node, _ref57) { | ||
/*istanbul ignore next*/var tag = _ref57.tag; | ||
/*istanbul ignore next*/var elements = _ref57.elements; | ||
var tag = _ref57.tag; | ||
var elements = _ref57.elements; | ||
var state = node.tag == null ? empty() : p(node.tag, /*istanbul ignore next*/(0, _coderep.getPrecedence)(node), tag); | ||
var state = node.tag == null ? empty() : p(node.tag, (0, _coderep.getPrecedence)(node), tag); | ||
var templateData = ""; | ||
@@ -938,3 +930,3 @@ state = seq(state, t("`")); | ||
value: function reduceThrowStatement(node, _ref58) { | ||
/*istanbul ignore next*/var expression = _ref58.expression; | ||
var expression = _ref58.expression; | ||
@@ -946,4 +938,4 @@ return seq(t("throw"), expression, semiOp()); | ||
value: function reduceTryCatchStatement(node, _ref59) { | ||
/*istanbul ignore next*/var body = _ref59.body; | ||
/*istanbul ignore next*/var catchClause = _ref59.catchClause; | ||
var body = _ref59.body; | ||
var catchClause = _ref59.catchClause; | ||
@@ -955,5 +947,5 @@ return seq(t("try"), body, catchClause); | ||
value: function reduceTryFinallyStatement(node, _ref60) { | ||
/*istanbul ignore next*/var body = _ref60.body; | ||
/*istanbul ignore next*/var catchClause = _ref60.catchClause; | ||
/*istanbul ignore next*/var finalizer = _ref60.finalizer; | ||
var body = _ref60.body; | ||
var catchClause = _ref60.catchClause; | ||
var finalizer = _ref60.finalizer; | ||
@@ -965,6 +957,6 @@ return seq(t("try"), body, catchClause || empty(), t("finally"), finalizer); | ||
value: function reduceYieldExpression(node, _ref61) { | ||
/*istanbul ignore next*/var expression = _ref61.expression; | ||
var expression = _ref61.expression; | ||
if (node.expression == null) return t("yield"); | ||
return seq(t("yield"), p(node.expression, /*istanbul ignore next*/(0, _coderep.getPrecedence)(node), expression)); | ||
return seq(t("yield"), p(node.expression, (0, _coderep.getPrecedence)(node), expression)); | ||
} | ||
@@ -974,5 +966,5 @@ }, { | ||
value: function reduceYieldGeneratorExpression(node, _ref62) { | ||
/*istanbul ignore next*/var expression = _ref62.expression; | ||
var expression = _ref62.expression; | ||
return seq(t("yield"), t("*"), p(node.expression, /*istanbul ignore next*/(0, _coderep.getPrecedence)(node), expression)); | ||
return seq(t("yield"), t("*"), p(node.expression, (0, _coderep.getPrecedence)(node), expression)); | ||
} | ||
@@ -988,3 +980,3 @@ }, { | ||
value: function reduceVariableDeclaration(node, _ref63) { | ||
/*istanbul ignore next*/var declarators = _ref63.declarators; | ||
var declarators = _ref63.declarators; | ||
@@ -996,3 +988,3 @@ return seq(t(node.kind), commaSep(declarators)); | ||
value: function reduceVariableDeclarationStatement(node, _ref64) { | ||
/*istanbul ignore next*/var declaration = _ref64.declaration; | ||
var declaration = _ref64.declaration; | ||
@@ -1004,4 +996,4 @@ return seq(declaration, semiOp()); | ||
value: function reduceVariableDeclarator(node, _ref65) { | ||
/*istanbul ignore next*/var binding = _ref65.binding; | ||
/*istanbul ignore next*/var init = _ref65.init; | ||
var binding = _ref65.binding; | ||
var init = _ref65.init; | ||
@@ -1016,3 +1008,3 @@ var containsIn = init && init.containsIn && !init.containsGroup; | ||
} | ||
return objectAssign(init == null ? binding : seq(binding, t("="), init), { containsIn: containsIn }); | ||
return (0, _objectAssign2.default)(init == null ? binding : seq(binding, t("="), init), { containsIn: containsIn }); | ||
} | ||
@@ -1022,6 +1014,6 @@ }, { | ||
value: function reduceWhileStatement(node, _ref66) { | ||
/*istanbul ignore next*/var test = _ref66.test; | ||
/*istanbul ignore next*/var body = _ref66.body; | ||
var test = _ref66.test; | ||
var body = _ref66.body; | ||
return objectAssign(seq(t("while"), paren(test), body), { endsWithMissingElse: body.endsWithMissingElse }); | ||
return (0, _objectAssign2.default)(seq(t("while"), paren(test), body), { endsWithMissingElse: body.endsWithMissingElse }); | ||
} | ||
@@ -1031,6 +1023,6 @@ }, { | ||
value: function reduceWithStatement(node, _ref67) { | ||
/*istanbul ignore next*/var object = _ref67.object; | ||
/*istanbul ignore next*/var body = _ref67.body; | ||
var object = _ref67.object; | ||
var body = _ref67.body; | ||
return objectAssign(seq(t("with"), paren(object), body), { endsWithMissingElse: body.endsWithMissingElse }); | ||
return (0, _objectAssign2.default)(seq(t("with"), paren(object), body), { endsWithMissingElse: body.endsWithMissingElse }); | ||
} | ||
@@ -1042,2 +1034,2 @@ }]); | ||
/*istanbul ignore next*/exports.default = MinimalCodeGen; | ||
exports.default = MinimalCodeGen; |
@@ -1,2 +0,2 @@ | ||
/*istanbul ignore next*/"use strict"; | ||
"use strict"; | ||
@@ -55,6 +55,4 @@ var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); /** | ||
/*istanbul ignore next*/ | ||
var TokenStream = exports.TokenStream = function () { | ||
function TokenStream() { | ||
/*istanbul ignore next*/ | ||
_classCallCheck(this, TokenStream); | ||
@@ -101,3 +99,3 @@ | ||
this.lastChar = tokenStr.charAt(tokenStr.length - 1); | ||
if (lastChar && ((lastChar == "+" || lastChar == "-") && lastChar == rightChar || /*istanbul ignore next*/_esutils.code.isIdentifierPartES6(lastChar.charCodeAt(0)) && /*istanbul ignore next*/_esutils.code.isIdentifierPartES6(rightChar.charCodeAt(0)) || lastChar == "/" && rightChar == "i")) { | ||
if (lastChar && ((lastChar == "+" || lastChar == "-") && lastChar == rightChar || _esutils.code.isIdentifierPartES6(lastChar.charCodeAt(0)) && _esutils.code.isIdentifierPartES6(rightChar.charCodeAt(0)) || lastChar == "/" && rightChar == "i")) { | ||
this.result += " "; | ||
@@ -104,0 +102,0 @@ } |
{ | ||
"name": "shift-codegen", | ||
"version": "4.0.0", | ||
"version": "4.0.1", | ||
"description": "code generator for Shift format ASTs", | ||
@@ -17,5 +17,3 @@ "author": "Shape Security Labs", | ||
"test": "mocha --inline-diffs --check-leaks --ui tdd --reporter dot --timeout 5000 --recursive test", | ||
"build": "babel --auxiliary-comment-before 'istanbul ignore next' --source-maps-inline --out-dir dist src", | ||
"generate-coverage": "istanbul cover _mocha -- --inline-diffs --check-leaks --ui tdd --reporter dot --timeout 5000 --recursive test", | ||
"check-coverage": "istanbul check-coverage --statements 100 --functions 100 --branches 100 --lines 100", | ||
"build": "babel --source-maps-inline --out-dir dist src", | ||
"cjsify": "cjsify --export ShiftCodegen dist/index.js > shift-codegen.js", | ||
@@ -27,3 +25,3 @@ "prepublish": "rm -rf dist/* && npm update && npm run build" | ||
"object-assign": "^3.0.0", | ||
"shift-reducer": "^3.0.0" | ||
"shift-reducer": "^3.0.2" | ||
}, | ||
@@ -37,3 +35,2 @@ "devDependencies": { | ||
"expect.js": "0.3.1", | ||
"istanbul": "0.3.17", | ||
"mocha": "2.2.5", | ||
@@ -40,0 +37,0 @@ "shift-parser": "3.0.1" |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
8
0
138624
2767
Updatedshift-reducer@^3.0.2