default generateUid scope to Program
This commit is contained in:
parent
c967cded78
commit
d1088583ba
@ -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) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user