diff --git a/lib/6to5/file.js b/lib/6to5/file.js index ba4ed2faaf..dce01a04cc 100644 --- a/lib/6to5/file.js +++ b/lib/6to5/file.js @@ -389,7 +389,7 @@ File.prototype.checkNode = function (node, scope) { check(node, scope); - traverse(node, checkTransformerVisitor, scope, { + scope.traverse(node, checkTransformerVisitor, { check: check }); }; diff --git a/lib/6to5/transformation/helpers/name-method.js b/lib/6to5/transformation/helpers/name-method.js index c1876859f9..114122a9c7 100644 --- a/lib/6to5/transformation/helpers/name-method.js +++ b/lib/6to5/transformation/helpers/name-method.js @@ -35,7 +35,7 @@ exports.property = function (node, file, scope) { outerDeclar: scope.getBinding(id), }; - traverse(node, visitor, scope, state); + scope.traverse(node, visitor, state); if (state.selfReference) { // todo: support generators diff --git a/lib/6to5/transformation/helpers/remap-async-to-generator.js b/lib/6to5/transformation/helpers/remap-async-to-generator.js index 059d30639c..a26932eb9c 100644 --- a/lib/6to5/transformation/helpers/remap-async-to-generator.js +++ b/lib/6to5/transformation/helpers/remap-async-to-generator.js @@ -23,7 +23,7 @@ module.exports = function (node, callId, scope) { node.async = false; node.generator = true; - traverse(node, visitor, scope); + scope.traverse(node, visitor); var call = t.callExpression(callId, [node]); var id = node.id; diff --git a/lib/6to5/transformation/helpers/replace-supers.js b/lib/6to5/transformation/helpers/replace-supers.js index 107045af67..12d894d764 100644 --- a/lib/6to5/transformation/helpers/replace-supers.js +++ b/lib/6to5/transformation/helpers/replace-supers.js @@ -167,7 +167,7 @@ var visitor = { ReplaceSupers.prototype.traverseLevel = function (node, topLevel) { var state = { self: this, topLevel: topLevel }; - traverse(node, visitor, this.scope, state); + this.scope.traverse(node, visitor, state); }; /** diff --git a/lib/6to5/transformation/modules/_default.js b/lib/6to5/transformation/modules/_default.js index 3d06f64b9c..4e8cd7a705 100644 --- a/lib/6to5/transformation/modules/_default.js +++ b/lib/6to5/transformation/modules/_default.js @@ -60,7 +60,7 @@ var exportsVisitor = { }; DefaultFormatter.prototype.getLocalExports = function () { - traverse(this.file.ast, exportsVisitor, this.file.scope, this); + this.file.scope.traverse(this.file.ast, exportsVisitor, this); }; var importsVisitor = { @@ -74,7 +74,7 @@ var importsVisitor = { }; DefaultFormatter.prototype.getLocalImports = function () { - traverse(this.file.ast, importsVisitor, this.file.scope, this); + this.file.scope.traverse(this.file.ast, importsVisitor, this); }; var remapVisitor = { @@ -116,7 +116,7 @@ var remapVisitor = { DefaultFormatter.prototype.remapAssignments = function () { if (this.hasLocalImports) { - traverse(this.file.ast, remapVisitor, this.file.scope, this); + this.file.scope.traverse(this.file.ast, remapVisitor, this); } }; diff --git a/lib/6to5/transformation/modules/system.js b/lib/6to5/transformation/modules/system.js index 794616c0f3..fa6c6982d7 100644 --- a/lib/6to5/transformation/modules/system.js +++ b/lib/6to5/transformation/modules/system.js @@ -97,7 +97,7 @@ SystemFormatter.prototype.buildRunnerSetters = function (block, hoistDeclarators hoistDeclarators: hoistDeclarators }; - traverse(block, runnerSettersVisitor, scope, state); + scope.traverse(block, runnerSettersVisitor, state); return t.functionExpression(null, [uid], t.blockStatement(state.nodes)); })); @@ -182,7 +182,7 @@ SystemFormatter.prototype.transform = function (ast) { var returnStatement = handlerBody.pop(); // hoist up all variable declarations - traverse(block, hoistVariablesVisitor, this.file.scope, hoistDeclarators); + this.file.scope.traverse(block, hoistVariablesVisitor, hoistDeclarators); if (hoistDeclarators.length) { var hoistDeclar = t.variableDeclaration("var", hoistDeclarators); @@ -191,7 +191,7 @@ SystemFormatter.prototype.transform = function (ast) { } // hoist up function declarations for circular references - traverse(block, hoistFunctionsVisitor, this.file.scope, handlerBody); + this.file.scope.traverse(block, hoistFunctionsVisitor, handlerBody); handlerBody.push(returnStatement); diff --git a/lib/6to5/transformation/transformer-pass.js b/lib/6to5/transformation/transformer-pass.js index 5c02d6e215..e747d5f6db 100644 --- a/lib/6to5/transformation/transformer-pass.js +++ b/lib/6to5/transformation/transformer-pass.js @@ -89,7 +89,7 @@ TransformerPass.prototype.transform = function () { this.astRun("before"); var state = { file: file, handlers: this.handlers, pass: this }; - traverse(file.ast, transformVisitor, file.scope, state); + file.scope.traverse(file.ast, transformVisitor, state); this.astRun("after"); }; diff --git a/lib/6to5/transformation/transformers/es6/block-scoping-tdz.js b/lib/6to5/transformation/transformers/es6/block-scoping-tdz.js index d9b11b8923..4c58b7f74a 100644 --- a/lib/6to5/transformation/transformers/es6/block-scoping-tdz.js +++ b/lib/6to5/transformation/transformers/es6/block-scoping-tdz.js @@ -46,5 +46,5 @@ exports.BlockStatement = function (node, parent, scope, context, file) { file: file }; - traverse(node, visitor, scope, state); + scope.traverse(node, visitor, state); }; diff --git a/lib/6to5/transformation/transformers/es6/block-scoping.js b/lib/6to5/transformation/transformers/es6/block-scoping.js index 40daed0dae..8a1c7775b3 100644 --- a/lib/6to5/transformation/transformers/es6/block-scoping.js +++ b/lib/6to5/transformation/transformers/es6/block-scoping.js @@ -130,7 +130,7 @@ var replaceVisitor = { function traverseReplace(node, parent, scope, remaps) { replace(node, parent, scope, null, remaps); - traverse(node, replaceVisitor, scope, remaps); + scope.traverse(node, replaceVisitor, remaps); } /** @@ -176,7 +176,7 @@ BlockScoping.prototype.remap = function () { traverseReplace(loopParent.update, loopParent, scope, remaps); } - traverse(this.block, replaceVisitor, scope, remaps); + scope.traverse(this.block, replaceVisitor, remaps); }; /** @@ -243,7 +243,7 @@ var letReferenceFunctionVisitor = { var letReferenceBlockVisitor = { enter: function (node, parent, scope, context, state) { if (t.isFunction(node)) { - traverse(node, letReferenceFunctionVisitor, scope, state); + scope.traverse(node, letReferenceFunctionVisitor, state); return context.skip(); } } @@ -296,7 +296,7 @@ BlockScoping.prototype.getLetReferences = function () { // traverse through this block, stopping on functions and checking if they // contain any local let references - traverse(this.block, letReferenceBlockVisitor, this.scope, state); + this.scope.traverse(this.block, letReferenceBlockVisitor, state); return state.closurify; }; @@ -315,7 +315,7 @@ var loopVisitor = { if (t.isLoop(node)) { state.ignoreLabeless = true; - traverse(node, loopVisitor, scope, state); + scope.traverse(node, loopVisitor, state); state.ignoreLabeless = false; } @@ -388,8 +388,8 @@ BlockScoping.prototype.checkLoop = function () { map: {} }; - traverse(this.block, loopLabelVisitor, this.scope, state); - traverse(this.block, loopVisitor, this.scope, state); + this.scope.traverse(this.block, loopLabelVisitor, state); + this.scope.traverse(this.block, loopVisitor, state); return state; }; diff --git a/lib/6to5/transformation/transformers/es6/constants.js b/lib/6to5/transformation/transformers/es6/constants.js index cb7101faf2..165ff12512 100644 --- a/lib/6to5/transformation/transformers/es6/constants.js +++ b/lib/6to5/transformation/transformers/es6/constants.js @@ -37,7 +37,7 @@ var visitor = { }; exports.Scope = function (node, parent, scope, context, file) { - traverse(node, visitor, scope, { + scope.traverse(node, visitor, { constants: scope.getAllDeclarationsOfKind("const"), file: file }); diff --git a/lib/6to5/transformation/transformers/es6/parameters.default.js b/lib/6to5/transformation/transformers/es6/parameters.default.js index 2854e572d7..af715ae005 100644 --- a/lib/6to5/transformation/transformers/es6/parameters.default.js +++ b/lib/6to5/transformation/transformers/es6/parameters.default.js @@ -55,7 +55,7 @@ exports.Function = function (node, parent, scope) { if (t.isIdentifier(right) && scope.hasOwnReference(right.name)) { state.iife = true; } else { - traverse(right, iifeVisitor, scope, state); + scope.traverse(right, iifeVisitor, state); } } diff --git a/lib/6to5/transformation/transformers/internal/alias-functions.js b/lib/6to5/transformation/transformers/internal/alias-functions.js index 640f334f9c..8f53bc6cda 100644 --- a/lib/6to5/transformation/transformers/internal/alias-functions.js +++ b/lib/6to5/transformation/transformers/internal/alias-functions.js @@ -37,7 +37,7 @@ var functionVisitor = { } // traverse all child nodes of this function and find `arguments` and `this` - traverse(node, functionChildrenVisitor, scope, state); + scope.traverse(node, functionChildrenVisitor, state); return context.skip(); } @@ -58,7 +58,7 @@ var go = function (getBody, node, scope) { // traverse the function and find all alias functions so we can alias // `arguments` and `this` if necessary - traverse(node, functionVisitor, scope, state); + scope.traverse(node, functionVisitor, state); var body; diff --git a/lib/6to5/transformation/transformers/other/self-contained.js b/lib/6to5/transformation/transformers/other/self-contained.js index 4f60e3d015..9be7d45e33 100644 --- a/lib/6to5/transformation/transformers/other/self-contained.js +++ b/lib/6to5/transformation/transformers/other/self-contained.js @@ -77,7 +77,7 @@ exports.ast = { }, after: function (ast, file) { - traverse(ast, astVisitor, null, file); + file.scope.traverse(ast, astVisitor, file); } }; diff --git a/lib/6to5/transformation/transformers/playground/object-getter-memoization.js b/lib/6to5/transformation/transformers/playground/object-getter-memoization.js index e27da96702..55dff3d130 100644 --- a/lib/6to5/transformation/transformers/playground/object-getter-memoization.js +++ b/lib/6to5/transformation/transformers/playground/object-getter-memoization.js @@ -39,5 +39,5 @@ exports.MethodDefinition = function (node, parent, scope, context, file) { file: file }; - traverse(value, visitor, scope, state); + scope.traverse(value, visitor, state); }; diff --git a/lib/6to5/traverse/scope.js b/lib/6to5/traverse/scope.js index 1f05f05b86..6a35054c9c 100644 --- a/lib/6to5/traverse/scope.js +++ b/lib/6to5/traverse/scope.js @@ -308,7 +308,7 @@ Scope.prototype.crawl = function () { // Program, BlockStatement - let variables if (t.isBlockStatement(block) || t.isProgram(block)) { - traverse(block, blockVariableVisitor, this, this); + this.traverse(block, blockVariableVisitor, this); } // CatchClause - param @@ -334,7 +334,7 @@ Scope.prototype.crawl = function () { // Program, Function - var variables if (t.isProgram(block) || t.isFunction(block)) { - traverse(block, functionVariableVisitor, this, { + this.traverse(block, functionVariableVisitor, { blockId: block.id, scope: this }); @@ -351,7 +351,7 @@ Scope.prototype.crawl = function () { // Program if (t.isProgram(block)) { - traverse(block, programReferenceVisitor, this, this); + this.traverse(block, programReferenceVisitor, this); } };