From 363723fc84f7b8477592e0105aeb331ec9a017af Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Mon, 14 Aug 2017 05:01:11 +0200 Subject: node_modules --- node_modules/istanbul-lib-instrument/dist/visitor.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'node_modules/istanbul-lib-instrument/dist/visitor.js') diff --git a/node_modules/istanbul-lib-instrument/dist/visitor.js b/node_modules/istanbul-lib-instrument/dist/visitor.js index beae5d91b..3462f9314 100644 --- a/node_modules/istanbul-lib-instrument/dist/visitor.js +++ b/node_modules/istanbul-lib-instrument/dist/visitor.js @@ -101,6 +101,15 @@ var VisitState = function () { extractURL(node.trailingComments); } + // for these expressions the statement counter needs to be hoisted, so + // function name inference can be preserved + + }, { + key: 'counterNeedsHoisting', + value: function counterNeedsHoisting(path) { + return path.isFunctionExpression() || path.isArrowFunctionExpression() || path.isClassExpression(); + } + // all the generic stuff that needs to be done on enter for every node }, { @@ -174,7 +183,7 @@ var VisitState = function () { } : function (x) { return x; }; - return T.unaryExpression('++', wrap(T.memberExpression(T.memberExpression(T.identifier(this.varName), T.identifier(type)), T.numericLiteral(id), true))); + return T.updateExpression('++', wrap(T.memberExpression(T.memberExpression(T.identifier(this.varName), T.identifier(type)), T.numericLiteral(id), true))); } }, { key: 'insertCounter', @@ -184,7 +193,7 @@ var VisitState = function () { path.node.body.unshift(T.expressionStatement(increment)); } else if (path.isStatement()) { path.insertBefore(T.expressionStatement(increment)); - } else if ((path.isFunctionExpression() || path.isArrowFunctionExpression()) && T.isVariableDeclarator(path.parentPath)) { + } else if (this.counterNeedsHoisting(path) && T.isVariableDeclarator(path.parentPath)) { // make an attempt to hoist the statement counter, so that // function names are maintained. var parent = path.parentPath.parentPath; -- cgit v1.2.3