shift-codegen
Advanced tools
Comparing version 4.0.3 to 5.0.0
"use strict"; | ||
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; }; }(); | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
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; | ||
@@ -33,9 +34,10 @@ exports.escapeStringLiteral = escapeStringLiteral; | ||
Multiplicative: 12, | ||
Prefix: 13, | ||
Postfix: 14, | ||
New: 15, | ||
Call: 16, | ||
TaggedTemplate: 17, | ||
Member: 18, | ||
Primary: 19 | ||
Exponential: 13, | ||
Prefix: 14, | ||
Postfix: 15, | ||
New: 16, | ||
Call: 17, | ||
TaggedTemplate: 18, | ||
Member: 19, | ||
Primary: 20 | ||
}; | ||
@@ -45,2 +47,3 @@ | ||
var BinaryPrecedence = { | ||
@@ -70,3 +73,4 @@ ",": Precedence.Sequence, | ||
"%": Precedence.Multiplicative, | ||
"/": Precedence.Multiplicative | ||
"/": Precedence.Multiplicative, | ||
"**": Precedence.Exponential | ||
}; | ||
@@ -101,2 +105,4 @@ | ||
case "StaticMemberExpression": | ||
case "ComputedMemberAssignmentTarget": | ||
case "StaticMemberAssignmentTarget": | ||
switch (node.object.type) { | ||
@@ -152,23 +158,11 @@ case "CallExpression": | ||
result += delim; | ||
for (var i = 0; i < stringValue.length; i++) { | ||
var ch = stringValue.charAt(i); | ||
switch (ch) { | ||
for (var _i = 0; _i < stringValue.length; _i++) { | ||
var _ch = stringValue.charAt(_i); | ||
switch (_ch) { | ||
case delim: | ||
result += "\\" + delim; | ||
break; | ||
case "\b": | ||
result += "\\b"; | ||
break; | ||
case "\t": | ||
result += "\\t"; | ||
break; | ||
case "\n": | ||
result += "\\n"; | ||
break; | ||
case "\u000b": | ||
result += "\\v"; | ||
break; | ||
case "\f": | ||
result += "\\f"; | ||
break; | ||
case "\r": | ||
@@ -187,3 +181,3 @@ result += "\\r"; | ||
default: | ||
result += ch; | ||
result += _ch; | ||
break; | ||
@@ -190,0 +184,0 @@ } |
@@ -14,3 +14,3 @@ "use strict"; | ||
get: function get() { | ||
return _minimalCodegen.default; | ||
return _interopRequireDefault(_minimalCodegen).default; | ||
} | ||
@@ -17,0 +17,0 @@ }); |
"use strict"; | ||
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; }; }(); | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -9,2 +7,4 @@ value: true | ||
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 = require("object-assign"); | ||
@@ -134,7 +134,24 @@ | ||
}, { | ||
key: "reduceCompoundAssignmentExpression", | ||
value: function reduceCompoundAssignmentExpression(node, _ref4) { | ||
key: "reduceAssignmentTargetIdentifier", | ||
value: function reduceAssignmentTargetIdentifier(node) { | ||
var a = t(node.name); | ||
if (node.name === "let") { | ||
a.startsWithLet = true; | ||
} | ||
return a; | ||
} | ||
}, { | ||
key: "reduceAssignmentTargetWithDefault", | ||
value: function reduceAssignmentTargetWithDefault(node, _ref4) { | ||
var binding = _ref4.binding; | ||
var expression = _ref4.expression; | ||
var init = _ref4.init; | ||
return seq(binding, t("="), p(node.init, _coderep.Precedence.Assignment, init)); | ||
} | ||
}, { | ||
key: "reduceCompoundAssignmentExpression", | ||
value: function reduceCompoundAssignmentExpression(node, _ref5) { | ||
var binding = _ref5.binding; | ||
var expression = _ref5.expression; | ||
var leftCode = binding; | ||
@@ -154,5 +171,5 @@ var rightCode = expression; | ||
key: "reduceBinaryExpression", | ||
value: function reduceBinaryExpression(node, _ref5) { | ||
var left = _ref5.left; | ||
var right = _ref5.right; | ||
value: function reduceBinaryExpression(node, _ref6) { | ||
var left = _ref6.left; | ||
var right = _ref6.right; | ||
@@ -187,7 +204,7 @@ var leftCode = left; | ||
key: "reduceBindingWithDefault", | ||
value: function reduceBindingWithDefault(node, _ref6) { | ||
var binding = _ref6.binding; | ||
var init = _ref6.init; | ||
value: function reduceBindingWithDefault(node, _ref7) { | ||
var binding = _ref7.binding; | ||
var init = _ref7.init; | ||
return seq(binding, t("="), init); | ||
return seq(binding, t("="), p(node.init, _coderep.Precedence.Assignment, init)); | ||
} | ||
@@ -204,12 +221,30 @@ }, { | ||
}, { | ||
key: "reduceArrayAssignmentTarget", | ||
value: function reduceArrayAssignmentTarget(node, _ref8) { | ||
var elements = _ref8.elements; | ||
var rest = _ref8.rest; | ||
var content = void 0; | ||
if (elements.length === 0) { | ||
content = rest == null ? empty() : seq(t("..."), rest); | ||
} else { | ||
elements = elements.concat(rest == null ? [] : [seq(t("..."), rest)]); | ||
content = commaSep(elements.map(getAssignmentExpr)); | ||
if (elements.length > 0 && elements[elements.length - 1] == null) { | ||
content = seq(content, t(",")); | ||
} | ||
} | ||
return bracket(content); | ||
} | ||
}, { | ||
key: "reduceArrayBinding", | ||
value: function reduceArrayBinding(node, _ref7) { | ||
var elements = _ref7.elements; | ||
var restElement = _ref7.restElement; | ||
value: function reduceArrayBinding(node, _ref9) { | ||
var elements = _ref9.elements; | ||
var rest = _ref9.rest; | ||
var content = undefined; | ||
var content = void 0; | ||
if (elements.length === 0) { | ||
content = restElement == null ? empty() : seq(t("..."), restElement); | ||
content = rest == null ? empty() : seq(t("..."), rest); | ||
} else { | ||
elements = elements.concat(restElement == null ? [] : [seq(t("..."), restElement)]); | ||
elements = elements.concat(rest == null ? [] : [seq(t("..."), rest)]); | ||
content = commaSep(elements.map(getAssignmentExpr)); | ||
@@ -223,5 +258,14 @@ if (elements.length > 0 && elements[elements.length - 1] == null) { | ||
}, { | ||
key: "reduceObjectAssignmentTarget", | ||
value: function reduceObjectAssignmentTarget(node, _ref10) { | ||
var properties = _ref10.properties; | ||
var state = brace(commaSep(properties)); | ||
state.startsWithCurly = true; | ||
return state; | ||
} | ||
}, { | ||
key: "reduceObjectBinding", | ||
value: function reduceObjectBinding(node, _ref8) { | ||
var properties = _ref8.properties; | ||
value: function reduceObjectBinding(node, _ref11) { | ||
var properties = _ref11.properties; | ||
@@ -233,15 +277,32 @@ var state = brace(commaSep(properties)); | ||
}, { | ||
key: "reduceAssignmentTargetPropertyIdentifier", | ||
value: function reduceAssignmentTargetPropertyIdentifier(node, _ref12) { | ||
var binding = _ref12.binding; | ||
var init = _ref12.init; | ||
if (node.init == null) return binding; | ||
return seq(binding, t("="), p(node.init, _coderep.Precedence.Assignment, init)); | ||
} | ||
}, { | ||
key: "reduceAssignmentTargetPropertyProperty", | ||
value: function reduceAssignmentTargetPropertyProperty(node, _ref13) { | ||
var name = _ref13.name; | ||
var binding = _ref13.binding; | ||
return seq(name, t(":"), binding); | ||
} | ||
}, { | ||
key: "reduceBindingPropertyIdentifier", | ||
value: function reduceBindingPropertyIdentifier(node, _ref9) { | ||
var binding = _ref9.binding; | ||
var init = _ref9.init; | ||
value: function reduceBindingPropertyIdentifier(node, _ref14) { | ||
var binding = _ref14.binding; | ||
var init = _ref14.init; | ||
if (node.init == null) return binding; | ||
return seq(binding, t("="), init); | ||
return seq(binding, t("="), p(node.init, _coderep.Precedence.Assignment, init)); | ||
} | ||
}, { | ||
key: "reduceBindingPropertyProperty", | ||
value: function reduceBindingPropertyProperty(node, _ref10) { | ||
var name = _ref10.name; | ||
var binding = _ref10.binding; | ||
value: function reduceBindingPropertyProperty(node, _ref15) { | ||
var name = _ref15.name; | ||
var binding = _ref15.binding; | ||
@@ -252,4 +313,4 @@ return seq(name, t(":"), binding); | ||
key: "reduceBlock", | ||
value: function reduceBlock(node, _ref11) { | ||
var statements = _ref11.statements; | ||
value: function reduceBlock(node, _ref16) { | ||
var statements = _ref16.statements; | ||
@@ -260,4 +321,4 @@ return brace(seq.apply(undefined, _toConsumableArray(statements))); | ||
key: "reduceBlockStatement", | ||
value: function reduceBlockStatement(node, _ref12) { | ||
var block = _ref12.block; | ||
value: function reduceBlockStatement(node, _ref17) { | ||
var block = _ref17.block; | ||
@@ -268,12 +329,10 @@ return block; | ||
key: "reduceBreakStatement", | ||
value: function reduceBreakStatement(node, _ref13) { | ||
var label = _ref13.label; | ||
return seq(t("break"), label ? t(label) : empty(), semiOp()); | ||
value: function reduceBreakStatement(node) { | ||
return seq(t("break"), node.label ? t(node.label) : empty(), semiOp()); | ||
} | ||
}, { | ||
key: "reduceCallExpression", | ||
value: function reduceCallExpression(node, _ref14) { | ||
var callee = _ref14.callee; | ||
var args = _ref14.arguments; | ||
value: function reduceCallExpression(node, _ref18) { | ||
var callee = _ref18.callee; | ||
var args = _ref18.arguments; | ||
@@ -288,5 +347,5 @@ return (0, _objectAssign2.default)(seq(p(node.callee, (0, _coderep.getPrecedence)(node), callee), paren(commaSep(args))), { | ||
key: "reduceCatchClause", | ||
value: function reduceCatchClause(node, _ref15) { | ||
var binding = _ref15.binding; | ||
var body = _ref15.body; | ||
value: function reduceCatchClause(node, _ref19) { | ||
var binding = _ref19.binding; | ||
var body = _ref19.body; | ||
@@ -297,10 +356,10 @@ return seq(t("catch"), paren(binding), body); | ||
key: "reduceClassDeclaration", | ||
value: function reduceClassDeclaration(node, _ref16) { | ||
var name = _ref16.name; | ||
var _super = _ref16.super; | ||
var elements = _ref16.elements; | ||
value: function reduceClassDeclaration(node, _ref20) { | ||
var name = _ref20.name; | ||
var _super = _ref20.super; | ||
var elements = _ref20.elements; | ||
var state = seq(t("class"), name); | ||
var state = seq(t("class"), node.name.name === "*default*" ? empty() : name); | ||
if (_super != null) { | ||
state = seq(state, t("extends"), _super); | ||
state = seq(state, t("extends"), p(node.super, _coderep.Precedence.New, _super)); | ||
} | ||
@@ -312,6 +371,6 @@ state = seq.apply(undefined, [state, t("{")].concat(_toConsumableArray(elements), [t("}")])); | ||
key: "reduceClassExpression", | ||
value: function reduceClassExpression(node, _ref17) { | ||
var name = _ref17.name; | ||
var _super = _ref17.super; | ||
var elements = _ref17.elements; | ||
value: function reduceClassExpression(node, _ref21) { | ||
var name = _ref21.name; | ||
var _super = _ref21.super; | ||
var elements = _ref21.elements; | ||
@@ -323,3 +382,3 @@ var state = t("class"); | ||
if (_super != null) { | ||
state = seq(state, t("extends"), _super); | ||
state = seq(state, t("extends"), p(node.super, _coderep.Precedence.New, _super)); | ||
} | ||
@@ -332,4 +391,4 @@ state = seq.apply(undefined, [state, t("{")].concat(_toConsumableArray(elements), [t("}")])); | ||
key: "reduceClassElement", | ||
value: function reduceClassElement(node, _ref18) { | ||
var method = _ref18.method; | ||
value: function reduceClassElement(node, _ref22) { | ||
var method = _ref22.method; | ||
@@ -340,6 +399,20 @@ if (!node.isStatic) return method; | ||
}, { | ||
key: "reduceComputedMemberAssignmentTarget", | ||
value: function reduceComputedMemberAssignmentTarget(node, _ref23) { | ||
var object = _ref23.object; | ||
var expression = _ref23.expression; | ||
var startsWithLetSquareBracket = object.startsWithLetSquareBracket || node.object.type === "IdentifierExpression" && node.object.name === "let"; | ||
return (0, _objectAssign2.default)(seq(p(node.object, (0, _coderep.getPrecedence)(node), object), bracket(expression)), { | ||
startsWithLet: object.startsWithLet, | ||
startsWithLetSquareBracket: startsWithLetSquareBracket, | ||
startsWithCurly: object.startsWithCurly, | ||
startsWithFunctionOrClass: object.startsWithFunctionOrClass | ||
}); | ||
} | ||
}, { | ||
key: "reduceComputedMemberExpression", | ||
value: function reduceComputedMemberExpression(node, _ref19) { | ||
var object = _ref19.object; | ||
var expression = _ref19.expression; | ||
value: function reduceComputedMemberExpression(node, _ref24) { | ||
var object = _ref24.object; | ||
var expression = _ref24.expression; | ||
@@ -356,13 +429,13 @@ var startsWithLetSquareBracket = object.startsWithLetSquareBracket || node.object.type === "IdentifierExpression" && node.object.name === "let"; | ||
key: "reduceComputedPropertyName", | ||
value: function reduceComputedPropertyName(node, _ref20) { | ||
var expression = _ref20.expression; | ||
value: function reduceComputedPropertyName(node, _ref25) { | ||
var expression = _ref25.expression; | ||
return bracket(expression); | ||
return bracket(p(node.expression, _coderep.Precedence.Assignment, expression)); | ||
} | ||
}, { | ||
key: "reduceConditionalExpression", | ||
value: function reduceConditionalExpression(node, _ref21) { | ||
var test = _ref21.test; | ||
var consequent = _ref21.consequent; | ||
var alternate = _ref21.alternate; | ||
value: function reduceConditionalExpression(node, _ref26) { | ||
var test = _ref26.test; | ||
var consequent = _ref26.consequent; | ||
var alternate = _ref26.alternate; | ||
@@ -382,12 +455,10 @@ var containsIn = test.containsIn || alternate.containsIn; | ||
key: "reduceContinueStatement", | ||
value: function reduceContinueStatement(node, _ref22) { | ||
var label = _ref22.label; | ||
return seq(t("continue"), label ? t(label) : empty(), semiOp()); | ||
value: function reduceContinueStatement(node) { | ||
return seq(t("continue"), node.label ? t(node.label) : empty(), semiOp()); | ||
} | ||
}, { | ||
key: "reduceDataProperty", | ||
value: function reduceDataProperty(node, _ref23) { | ||
var name = _ref23.name; | ||
var expression = _ref23.expression; | ||
value: function reduceDataProperty(node, _ref27) { | ||
var name = _ref27.name; | ||
var expression = _ref27.expression; | ||
@@ -403,5 +474,5 @@ return seq(name, t(":"), getAssignmentExpr(expression)); | ||
key: "reduceDoWhileStatement", | ||
value: function reduceDoWhileStatement(node, _ref24) { | ||
var body = _ref24.body; | ||
var test = _ref24.test; | ||
value: function reduceDoWhileStatement(node, _ref28) { | ||
var body = _ref28.body; | ||
var test = _ref28.test; | ||
@@ -417,4 +488,4 @@ return seq(t("do"), body, t("while"), paren(test), semiOp()); | ||
key: "reduceExpressionStatement", | ||
value: function reduceExpressionStatement(node, _ref25) { | ||
var expression = _ref25.expression; | ||
value: function reduceExpressionStatement(node, _ref29) { | ||
var expression = _ref29.expression; | ||
@@ -426,6 +497,6 @@ var needsParens = expression.startsWithCurly || expression.startsWithLetSquareBracket || expression.startsWithFunctionOrClass; | ||
key: "reduceForInStatement", | ||
value: function reduceForInStatement(node, _ref26) { | ||
var left = _ref26.left; | ||
var right = _ref26.right; | ||
var body = _ref26.body; | ||
value: function reduceForInStatement(node, _ref30) { | ||
var left = _ref30.left; | ||
var right = _ref30.right; | ||
var body = _ref30.body; | ||
@@ -437,3 +508,3 @@ var leftP = left; | ||
break; | ||
case "BindingIdentifier": | ||
case "AssignmentTargetIdentifier": | ||
if (node.left.name === "let") { | ||
@@ -448,17 +519,17 @@ leftP = paren(left); | ||
key: "reduceForOfStatement", | ||
value: function reduceForOfStatement(node, _ref27) { | ||
var left = _ref27.left; | ||
var right = _ref27.right; | ||
var body = _ref27.body; | ||
value: function reduceForOfStatement(node, _ref31) { | ||
var left = _ref31.left; | ||
var right = _ref31.right; | ||
var body = _ref31.body; | ||
left = node.left.type === "VariableDeclaration" ? noIn(markContainsIn(left)) : left; | ||
return (0, _objectAssign2.default)(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"), p(node.right, _coderep.Precedence.Assignment, right))), body), { endsWithMissingElse: body.endsWithMissingElse }); | ||
} | ||
}, { | ||
key: "reduceForStatement", | ||
value: function reduceForStatement(node, _ref28) { | ||
var init = _ref28.init; | ||
var test = _ref28.test; | ||
var update = _ref28.update; | ||
var body = _ref28.body; | ||
value: function reduceForStatement(node, _ref32) { | ||
var init = _ref32.init; | ||
var test = _ref32.test; | ||
var update = _ref32.update; | ||
var body = _ref32.body; | ||
@@ -471,5 +542,5 @@ return (0, _objectAssign2.default)(seq(t("for"), paren(seq(init ? noIn(markContainsIn(init)) : empty(), semi(), test || empty(), semi(), update || empty())), body), { | ||
key: "reduceFunctionBody", | ||
value: function reduceFunctionBody(node, _ref29) { | ||
var directives = _ref29.directives; | ||
var statements = _ref29.statements; | ||
value: function reduceFunctionBody(node, _ref33) { | ||
var directives = _ref33.directives; | ||
var statements = _ref33.statements; | ||
@@ -483,6 +554,6 @@ if (statements.length) { | ||
key: "reduceFunctionDeclaration", | ||
value: function reduceFunctionDeclaration(node, _ref30) { | ||
var name = _ref30.name; | ||
var params = _ref30.params; | ||
var body = _ref30.body; | ||
value: function reduceFunctionDeclaration(node, _ref34) { | ||
var name = _ref34.name; | ||
var params = _ref34.params; | ||
var body = _ref34.body; | ||
@@ -493,6 +564,6 @@ return seq(t("function"), node.isGenerator ? t("*") : empty(), node.name.name === "*default*" ? empty() : name, paren(params), brace(body)); | ||
key: "reduceFunctionExpression", | ||
value: function reduceFunctionExpression(node, _ref31) { | ||
var name = _ref31.name; | ||
var params = _ref31.params; | ||
var body = _ref31.body; | ||
value: function reduceFunctionExpression(node, _ref35) { | ||
var name = _ref35.name; | ||
var params = _ref35.params; | ||
var body = _ref35.body; | ||
@@ -505,5 +576,5 @@ var state = seq(t("function"), node.isGenerator ? t("*") : empty(), name ? name : empty(), paren(params), brace(body)); | ||
key: "reduceFormalParameters", | ||
value: function reduceFormalParameters(node, _ref32) { | ||
var items = _ref32.items; | ||
var rest = _ref32.rest; | ||
value: function reduceFormalParameters(node, _ref36) { | ||
var items = _ref36.items; | ||
var rest = _ref36.rest; | ||
@@ -514,5 +585,5 @@ return commaSep(items.concat(rest == null ? [] : [seq(t("..."), rest)])); | ||
key: "reduceArrowExpression", | ||
value: function reduceArrowExpression(node, _ref33) { | ||
var params = _ref33.params; | ||
var body = _ref33.body; | ||
value: function reduceArrowExpression(node, _ref37) { | ||
var params = _ref37.params; | ||
var body = _ref37.body; | ||
@@ -531,5 +602,5 @@ if (node.params.rest != null || node.params.items.length !== 1 || node.params.items[0].type !== "BindingIdentifier") { | ||
key: "reduceGetter", | ||
value: function reduceGetter(node, _ref34) { | ||
var name = _ref34.name; | ||
var body = _ref34.body; | ||
value: function reduceGetter(node, _ref38) { | ||
var name = _ref38.name; | ||
var body = _ref38.body; | ||
@@ -549,6 +620,6 @@ return seq(t("get"), name, paren(empty()), brace(body)); | ||
key: "reduceIfStatement", | ||
value: function reduceIfStatement(node, _ref35) { | ||
var test = _ref35.test; | ||
var consequent = _ref35.consequent; | ||
var alternate = _ref35.alternate; | ||
value: function reduceIfStatement(node, _ref39) { | ||
var test = _ref39.test; | ||
var consequent = _ref39.consequent; | ||
var alternate = _ref39.alternate; | ||
@@ -562,5 +633,5 @@ if (alternate && consequent.endsWithMissingElse) { | ||
key: "reduceImport", | ||
value: function reduceImport(node, _ref36) { | ||
var defaultBinding = _ref36.defaultBinding; | ||
var namedImports = _ref36.namedImports; | ||
value: function reduceImport(node, _ref40) { | ||
var defaultBinding = _ref40.defaultBinding; | ||
var namedImports = _ref40.namedImports; | ||
@@ -581,5 +652,5 @@ var bindings = []; | ||
key: "reduceImportNamespace", | ||
value: function reduceImportNamespace(node, _ref37) { | ||
var defaultBinding = _ref37.defaultBinding; | ||
var namespaceBinding = _ref37.namespaceBinding; | ||
value: function reduceImportNamespace(node, _ref41) { | ||
var defaultBinding = _ref41.defaultBinding; | ||
var namespaceBinding = _ref41.namespaceBinding; | ||
@@ -590,4 +661,4 @@ return seq(t("import"), defaultBinding == null ? empty() : seq(defaultBinding, t(",")), t("*"), t("as"), namespaceBinding, t("from"), t((0, _coderep.escapeStringLiteral)(node.moduleSpecifier)), semiOp()); | ||
key: "reduceImportSpecifier", | ||
value: function reduceImportSpecifier(node, _ref38) { | ||
var binding = _ref38.binding; | ||
value: function reduceImportSpecifier(node, _ref42) { | ||
var binding = _ref42.binding; | ||
@@ -604,11 +675,18 @@ if (node.name == null) return binding; | ||
key: "reduceExportFrom", | ||
value: function reduceExportFrom(node, _ref39) { | ||
var namedExports = _ref39.namedExports; | ||
value: function reduceExportFrom(node, _ref43) { | ||
var namedExports = _ref43.namedExports; | ||
return seq(t("export"), brace(commaSep(namedExports)), node.moduleSpecifier == null ? empty() : seq(t("from"), t((0, _coderep.escapeStringLiteral)(node.moduleSpecifier)), semiOp())); | ||
return seq(t("export"), brace(commaSep(namedExports)), t("from"), t((0, _coderep.escapeStringLiteral)(node.moduleSpecifier)), semiOp()); | ||
} | ||
}, { | ||
key: "reduceExportLocals", | ||
value: function reduceExportLocals(node, _ref44) { | ||
var namedExports = _ref44.namedExports; | ||
return seq(t("export"), brace(commaSep(namedExports)), semiOp()); | ||
} | ||
}, { | ||
key: "reduceExport", | ||
value: function reduceExport(node, _ref40) { | ||
var declaration = _ref40.declaration; | ||
value: function reduceExport(node, _ref45) { | ||
var declaration = _ref45.declaration; | ||
@@ -626,4 +704,4 @@ switch (node.declaration.type) { | ||
key: "reduceExportDefault", | ||
value: function reduceExportDefault(node, _ref41) { | ||
var body = _ref41.body; | ||
value: function reduceExportDefault(node, _ref46) { | ||
var body = _ref46.body; | ||
@@ -634,21 +712,27 @@ body = body.startsWithFunctionOrClass ? paren(body) : body; | ||
case "ClassDeclaration": | ||
break; | ||
return seq(t("export default"), body); | ||
default: | ||
body = seq(body, semiOp()); | ||
return seq(t("export default"), p(node.body, _coderep.Precedence.Assignment, body), semiOp()); | ||
} | ||
return seq(t("export default"), body); | ||
} | ||
}, { | ||
key: "reduceExportSpecifier", | ||
value: function reduceExportSpecifier(node) { | ||
if (node.name == null) return t(node.exportedName); | ||
key: "reduceExportFromSpecifier", | ||
value: function reduceExportFromSpecifier(node) { | ||
if (node.exportedName == null) return t(node.name); | ||
return seq(t(node.name), t("as"), t(node.exportedName)); | ||
} | ||
}, { | ||
key: "reduceExportLocalSpecifier", | ||
value: function reduceExportLocalSpecifier(node, _ref47) { | ||
var name = _ref47.name; | ||
if (node.exportedName == null) return name; | ||
return seq(name, t("as"), t(node.exportedName)); | ||
} | ||
}, { | ||
key: "reduceLabeledStatement", | ||
value: function reduceLabeledStatement(node, _ref42) { | ||
var label = _ref42.label; | ||
var body = _ref42.body; | ||
value: function reduceLabeledStatement(node, _ref48) { | ||
var body = _ref48.body; | ||
return (0, _objectAssign2.default)(seq(t(label + ":"), body), { endsWithMissingElse: body.endsWithMissingElse }); | ||
return (0, _objectAssign2.default)(seq(t(node.label + ":"), body), { endsWithMissingElse: body.endsWithMissingElse }); | ||
} | ||
@@ -678,3 +762,3 @@ }, { | ||
value: function reduceLiteralRegExpExpression(node) { | ||
return t("/" + node.pattern + "/" + node.flags); | ||
return t("/" + node.pattern + "/" + (node.global ? 'g' : '') + (node.ignoreCase ? 'i' : '') + (node.multiLine ? 'm' : '') + (node.unicode ? 'u' : '') + (node.sticky ? 'y' : '')); | ||
} | ||
@@ -688,6 +772,6 @@ }, { | ||
key: "reduceMethod", | ||
value: function reduceMethod(node, _ref43) { | ||
var name = _ref43.name; | ||
var params = _ref43.params; | ||
var body = _ref43.body; | ||
value: function reduceMethod(node, _ref49) { | ||
var name = _ref49.name; | ||
var params = _ref49.params; | ||
var body = _ref49.body; | ||
@@ -698,5 +782,5 @@ return seq(node.isGenerator ? t("*") : empty(), name, paren(params), brace(body)); | ||
key: "reduceModule", | ||
value: function reduceModule(node, _ref44) { | ||
var directives = _ref44.directives; | ||
var items = _ref44.items; | ||
value: function reduceModule(node, _ref50) { | ||
var directives = _ref50.directives; | ||
var items = _ref50.items; | ||
@@ -710,5 +794,5 @@ if (items.length) { | ||
key: "reduceNewExpression", | ||
value: function reduceNewExpression(node, _ref45) { | ||
var callee = _ref45.callee; | ||
var args = _ref45.arguments; | ||
value: function reduceNewExpression(node, _ref51) { | ||
var callee = _ref51.callee; | ||
var args = _ref51.arguments; | ||
@@ -725,4 +809,4 @@ var calleeRep = (0, _coderep.getPrecedence)(node.callee) == _coderep.Precedence.Call ? paren(callee) : p(node.callee, (0, _coderep.getPrecedence)(node), callee); | ||
key: "reduceObjectExpression", | ||
value: function reduceObjectExpression(node, _ref46) { | ||
var properties = _ref46.properties; | ||
value: function reduceObjectExpression(node, _ref52) { | ||
var properties = _ref52.properties; | ||
@@ -735,4 +819,4 @@ var state = brace(commaSep(properties)); | ||
key: "reduceUpdateExpression", | ||
value: function reduceUpdateExpression(node, _ref47) { | ||
var operand = _ref47.operand; | ||
value: function reduceUpdateExpression(node, _ref53) { | ||
var operand = _ref53.operand; | ||
@@ -751,4 +835,4 @@ if (node.isPrefix) { | ||
key: "reduceUnaryExpression", | ||
value: function reduceUnaryExpression(node, _ref48) { | ||
var operand = _ref48.operand; | ||
value: function reduceUnaryExpression(node, _ref54) { | ||
var operand = _ref54.operand; | ||
@@ -759,4 +843,4 @@ return seq(t(node.operator), p(node.operand, (0, _coderep.getPrecedence)(node), operand)); | ||
key: "reduceReturnStatement", | ||
value: function reduceReturnStatement(node, _ref49) { | ||
var expression = _ref49.expression; | ||
value: function reduceReturnStatement(node, _ref55) { | ||
var expression = _ref55.expression; | ||
@@ -767,5 +851,5 @@ return seq(t("return"), expression || empty(), semiOp()); | ||
key: "reduceScript", | ||
value: function reduceScript(node, _ref50) { | ||
var directives = _ref50.directives; | ||
var statements = _ref50.statements; | ||
value: function reduceScript(node, _ref56) { | ||
var directives = _ref56.directives; | ||
var statements = _ref56.statements; | ||
@@ -779,6 +863,6 @@ if (statements.length) { | ||
key: "reduceSetter", | ||
value: function reduceSetter(node, _ref51) { | ||
var name = _ref51.name; | ||
var param = _ref51.param; | ||
var body = _ref51.body; | ||
value: function reduceSetter(node, _ref57) { | ||
var name = _ref57.name; | ||
var param = _ref57.param; | ||
var body = _ref57.body; | ||
@@ -789,12 +873,25 @@ return seq(t("set"), name, paren(param), brace(body)); | ||
key: "reduceShorthandProperty", | ||
value: function reduceShorthandProperty(node) { | ||
return t(node.name); | ||
value: function reduceShorthandProperty(node, _ref58) { | ||
var name = _ref58.name; | ||
return name; | ||
} | ||
}, { | ||
key: "reduceStaticMemberAssignmentTarget", | ||
value: function reduceStaticMemberAssignmentTarget(node, _ref59) { | ||
var object = _ref59.object; | ||
var state = seq(p(node.object, (0, _coderep.getPrecedence)(node), object), t("."), t(node.property)); | ||
state.startsWithLet = object.startsWithLet; | ||
state.startsWithCurly = object.startsWithCurly; | ||
state.startsWithLetSquareBracket = object.startsWithLetSquareBracket; | ||
state.startsWithFunctionOrClass = object.startsWithFunctionOrClass; | ||
return state; | ||
} | ||
}, { | ||
key: "reduceStaticMemberExpression", | ||
value: function reduceStaticMemberExpression(node, _ref52) { | ||
var object = _ref52.object; | ||
var property = _ref52.property; | ||
value: function reduceStaticMemberExpression(node, _ref60) { | ||
var object = _ref60.object; | ||
var state = seq(p(node.object, (0, _coderep.getPrecedence)(node), object), t("."), t(property)); | ||
var state = seq(p(node.object, (0, _coderep.getPrecedence)(node), object), t("."), t(node.property)); | ||
state.startsWithLet = object.startsWithLet; | ||
@@ -809,6 +906,7 @@ state.startsWithCurly = object.startsWithCurly; | ||
value: function reduceStaticPropertyName(node) { | ||
var n; | ||
if (_esutils.keyword.isIdentifierNameES6(node.value)) { | ||
return t(node.value); | ||
} else if (n = parseFloat(node.value), n === n) { | ||
} | ||
var n = parseFloat(node.value); | ||
if (n >= 0 && n.toString() === node.value) { | ||
return new _coderep.NumberCodeRep(n); | ||
@@ -825,5 +923,5 @@ } | ||
key: "reduceSwitchCase", | ||
value: function reduceSwitchCase(node, _ref53) { | ||
var test = _ref53.test; | ||
var consequent = _ref53.consequent; | ||
value: function reduceSwitchCase(node, _ref61) { | ||
var test = _ref61.test; | ||
var consequent = _ref61.consequent; | ||
@@ -834,4 +932,4 @@ return seq(t("case"), test, t(":"), seq.apply(undefined, _toConsumableArray(consequent))); | ||
key: "reduceSwitchDefault", | ||
value: function reduceSwitchDefault(node, _ref54) { | ||
var consequent = _ref54.consequent; | ||
value: function reduceSwitchDefault(node, _ref62) { | ||
var consequent = _ref62.consequent; | ||
@@ -842,5 +940,5 @@ return seq(t("default:"), seq.apply(undefined, _toConsumableArray(consequent))); | ||
key: "reduceSwitchStatement", | ||
value: function reduceSwitchStatement(node, _ref55) { | ||
var discriminant = _ref55.discriminant; | ||
var cases = _ref55.cases; | ||
value: function reduceSwitchStatement(node, _ref63) { | ||
var discriminant = _ref63.discriminant; | ||
var cases = _ref63.cases; | ||
@@ -851,7 +949,7 @@ return seq(t("switch"), paren(discriminant), brace(seq.apply(undefined, _toConsumableArray(cases)))); | ||
key: "reduceSwitchStatementWithDefault", | ||
value: function reduceSwitchStatementWithDefault(node, _ref56) { | ||
var discriminant = _ref56.discriminant; | ||
var preDefaultCases = _ref56.preDefaultCases; | ||
var defaultCase = _ref56.defaultCase; | ||
var postDefaultCases = _ref56.postDefaultCases; | ||
value: function reduceSwitchStatementWithDefault(node, _ref64) { | ||
var discriminant = _ref64.discriminant; | ||
var preDefaultCases = _ref64.preDefaultCases; | ||
var defaultCase = _ref64.defaultCase; | ||
var postDefaultCases = _ref64.postDefaultCases; | ||
@@ -862,5 +960,5 @@ return seq(t("switch"), paren(discriminant), brace(seq.apply(undefined, _toConsumableArray(preDefaultCases).concat([defaultCase], _toConsumableArray(postDefaultCases))))); | ||
key: "reduceTemplateExpression", | ||
value: function reduceTemplateExpression(node, _ref57) { | ||
var tag = _ref57.tag; | ||
var elements = _ref57.elements; | ||
value: function reduceTemplateExpression(node, _ref65) { | ||
var tag = _ref65.tag; | ||
var elements = _ref65.elements; | ||
@@ -901,4 +999,4 @@ var state = node.tag == null ? empty() : p(node.tag, (0, _coderep.getPrecedence)(node), tag); | ||
key: "reduceThrowStatement", | ||
value: function reduceThrowStatement(node, _ref58) { | ||
var expression = _ref58.expression; | ||
value: function reduceThrowStatement(node, _ref66) { | ||
var expression = _ref66.expression; | ||
@@ -909,5 +1007,5 @@ return seq(t("throw"), expression, semiOp()); | ||
key: "reduceTryCatchStatement", | ||
value: function reduceTryCatchStatement(node, _ref59) { | ||
var body = _ref59.body; | ||
var catchClause = _ref59.catchClause; | ||
value: function reduceTryCatchStatement(node, _ref67) { | ||
var body = _ref67.body; | ||
var catchClause = _ref67.catchClause; | ||
@@ -918,6 +1016,6 @@ return seq(t("try"), body, catchClause); | ||
key: "reduceTryFinallyStatement", | ||
value: function reduceTryFinallyStatement(node, _ref60) { | ||
var body = _ref60.body; | ||
var catchClause = _ref60.catchClause; | ||
var finalizer = _ref60.finalizer; | ||
value: function reduceTryFinallyStatement(node, _ref68) { | ||
var body = _ref68.body; | ||
var catchClause = _ref68.catchClause; | ||
var finalizer = _ref68.finalizer; | ||
@@ -928,4 +1026,4 @@ return seq(t("try"), body, catchClause || empty(), t("finally"), finalizer); | ||
key: "reduceYieldExpression", | ||
value: function reduceYieldExpression(node, _ref61) { | ||
var expression = _ref61.expression; | ||
value: function reduceYieldExpression(node, _ref69) { | ||
var expression = _ref69.expression; | ||
@@ -937,4 +1035,4 @@ if (node.expression == null) return t("yield"); | ||
key: "reduceYieldGeneratorExpression", | ||
value: function reduceYieldGeneratorExpression(node, _ref62) { | ||
var expression = _ref62.expression; | ||
value: function reduceYieldGeneratorExpression(node, _ref70) { | ||
var expression = _ref70.expression; | ||
@@ -946,3 +1044,3 @@ return seq(t("yield"), t("*"), p(node.expression, (0, _coderep.getPrecedence)(node), expression)); | ||
value: function reduceDirective(node) { | ||
var delim = /^(?:[^"\\]|\\.)*$/.test(node.rawValue) ? "\"" : "'"; | ||
var delim = node.rawValue.match(/(^|[^\\])(\\\\)*"/) ? "'" : '"'; | ||
return seq(t(delim + node.rawValue + delim), semiOp()); | ||
@@ -952,4 +1050,4 @@ } | ||
key: "reduceVariableDeclaration", | ||
value: function reduceVariableDeclaration(node, _ref63) { | ||
var declarators = _ref63.declarators; | ||
value: function reduceVariableDeclaration(node, _ref71) { | ||
var declarators = _ref71.declarators; | ||
@@ -960,4 +1058,4 @@ return seq(t(node.kind), commaSep(declarators)); | ||
key: "reduceVariableDeclarationStatement", | ||
value: function reduceVariableDeclarationStatement(node, _ref64) { | ||
var declaration = _ref64.declaration; | ||
value: function reduceVariableDeclarationStatement(node, _ref72) { | ||
var declaration = _ref72.declaration; | ||
@@ -968,5 +1066,5 @@ return seq(declaration, semiOp()); | ||
key: "reduceVariableDeclarator", | ||
value: function reduceVariableDeclarator(node, _ref65) { | ||
var binding = _ref65.binding; | ||
var init = _ref65.init; | ||
value: function reduceVariableDeclarator(node, _ref73) { | ||
var binding = _ref73.binding; | ||
var init = _ref73.init; | ||
@@ -985,5 +1083,5 @@ var containsIn = init && init.containsIn && !init.containsGroup; | ||
key: "reduceWhileStatement", | ||
value: function reduceWhileStatement(node, _ref66) { | ||
var test = _ref66.test; | ||
var body = _ref66.body; | ||
value: function reduceWhileStatement(node, _ref74) { | ||
var test = _ref74.test; | ||
var body = _ref74.body; | ||
@@ -994,5 +1092,5 @@ return (0, _objectAssign2.default)(seq(t("while"), paren(test), body), { endsWithMissingElse: body.endsWithMissingElse }); | ||
key: "reduceWithStatement", | ||
value: function reduceWithStatement(node, _ref67) { | ||
var object = _ref67.object; | ||
var body = _ref67.body; | ||
value: function reduceWithStatement(node, _ref75) { | ||
var object = _ref75.object; | ||
var body = _ref75.body; | ||
@@ -999,0 +1097,0 @@ return (0, _objectAssign2.default)(seq(t("with"), paren(object), body), { endsWithMissingElse: body.endsWithMissingElse }); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.TokenStream = undefined; | ||
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; }; }(); /** | ||
@@ -19,7 +24,2 @@ * Copyright 2014 Shape Security, Inc. | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.TokenStream = undefined; | ||
var _esutils = require("esutils"); | ||
@@ -30,3 +30,3 @@ | ||
function numberDot(fragment) { | ||
if (fragment.indexOf(".") < 0 && fragment.indexOf("e") < 0) { | ||
if (fragment.indexOf(".") < 0 && fragment.indexOf("e") < 0 && fragment.indexOf("x") < 0) { | ||
return ".."; | ||
@@ -100,3 +100,3 @@ } | ||
this.lastChar = tokenStr.charAt(tokenStr.length - 1); | ||
if (lastChar && ((lastChar == "+" || lastChar == "-") && lastChar == rightChar || _esutils.code.isIdentifierPartES6(lastChar.charCodeAt(0)) && _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" || rightChar == "/"))) { | ||
this.result += " "; | ||
@@ -103,0 +103,0 @@ } |
{ | ||
"name": "shift-codegen", | ||
"version": "4.0.3", | ||
"version": "5.0.0", | ||
"description": "code generator for Shift format ASTs", | ||
@@ -23,4 +23,4 @@ "author": "Shape Security Labs", | ||
"esutils": "^2.0.2", | ||
"object-assign": "^3.0.0", | ||
"shift-reducer": "^3.0.2" | ||
"object-assign": "^4.1.0", | ||
"shift-reducer": "^4.0.0" | ||
}, | ||
@@ -35,3 +35,3 @@ "devDependencies": { | ||
"mocha": "2.2.5", | ||
"shift-parser": "3.0.1" | ||
"shift-parser": "5.0.0" | ||
}, | ||
@@ -38,0 +38,0 @@ "keywords": [ |
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
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
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
146010
2946
7
1
0
+ Addedobject-assign@4.1.1(transitive)
+ Addedshift-ast@4.0.0(transitive)
+ Addedshift-reducer@4.4.1(transitive)
- Removedobject-assign@3.0.0(transitive)
- Removedshift-reducer@3.0.3(transitive)
- Removedshift-spec@2015.2.1(transitive)
Updatedobject-assign@^4.1.0
Updatedshift-reducer@^4.0.0