clean up Scope reference addition

This commit is contained in:
Sebastian McKenzie 2014-11-25 18:59:45 +11:00
parent 99ea00ca18
commit 07de6f5f4a

View File

@ -21,15 +21,19 @@ function Scope(block, parent) {
this.references = this.getReferences();
}
Scope.add = function (node, references) {
if (!node) return;
_.merge(references, t.getIds(node, true));
};
Scope.prototype.getReferences = function () {
var block = this.block;
if (block._scopeReferences) return block._scopeReferences;
var self = this;
var references = block._scopeReferences = {};
var add = function (node) {
self.add(node, references);
Scope.add(node, references);
};
// ForStatement - left, init
@ -116,9 +120,8 @@ Scope.prototype.push = function (name, id, init) {
}
};
Scope.prototype.add = function (node, references) {
if (!node) return;
_.merge(references || this.references, t.getIds(node, true));
Scope.prototype.add = function (node) {
Scope.add(node, this.references);
};
Scope.prototype.get = function (id) {