From d1088583ba41ece98455b95817888919183481db Mon Sep 17 00:00:00 2001 From: Sebastian McKenzie Date: Tue, 4 Nov 2014 12:57:06 +1100 Subject: [PATCH] default generateUid scope to Program --- lib/6to5/file.js | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/lib/6to5/file.js b/lib/6to5/file.js index 0c93ed0740..a53f7ab60e 100644 --- a/lib/6to5/file.js +++ b/lib/6to5/file.js @@ -4,6 +4,7 @@ var SHEBANG_REGEX = /^\#\!.*/; var transform = require("./transform"); var generate = require("./generator"); +var Scope = require("./scope"); var acorn = require("acorn-6to5"); var util = require("./util"); var t = require("./types"); @@ -108,6 +109,7 @@ File.prototype.parse = function (code) { File.prototype.transform = function (ast) { this.ast = ast; + this.scope = new Scope(null, ast.program); var self = this; @@ -135,15 +137,12 @@ File.prototype.generate = function () { }; File.prototype.generateUid = function (name, scope) { - if (scope) { - var uid; - do { - uid = this._generateUid(name); - } while (scope.has(uid)); - return uid; - } else { - return this._generateUid(name); - } + scope = scope || this.scope; + var uid; + do { + uid = this._generateUid(name); + } while (scope.has(uid)); + return uid; }; File.prototype._generateUid = function (name) {