clean up Scope reference addition
This commit is contained in:
parent
99ea00ca18
commit
07de6f5f4a
@ -21,15 +21,19 @@ function Scope(block, parent) {
|
|||||||
this.references = this.getReferences();
|
this.references = this.getReferences();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Scope.add = function (node, references) {
|
||||||
|
if (!node) return;
|
||||||
|
_.merge(references, t.getIds(node, true));
|
||||||
|
};
|
||||||
|
|
||||||
Scope.prototype.getReferences = function () {
|
Scope.prototype.getReferences = function () {
|
||||||
var block = this.block;
|
var block = this.block;
|
||||||
if (block._scopeReferences) return block._scopeReferences;
|
if (block._scopeReferences) return block._scopeReferences;
|
||||||
|
|
||||||
var self = this;
|
|
||||||
var references = block._scopeReferences = {};
|
var references = block._scopeReferences = {};
|
||||||
|
|
||||||
var add = function (node) {
|
var add = function (node) {
|
||||||
self.add(node, references);
|
Scope.add(node, references);
|
||||||
};
|
};
|
||||||
|
|
||||||
// ForStatement - left, init
|
// ForStatement - left, init
|
||||||
@ -116,9 +120,8 @@ Scope.prototype.push = function (name, id, init) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Scope.prototype.add = function (node, references) {
|
Scope.prototype.add = function (node) {
|
||||||
if (!node) return;
|
Scope.add(node, this.references);
|
||||||
_.merge(references || this.references, t.getIds(node, true));
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Scope.prototype.get = function (id) {
|
Scope.prototype.get = function (id) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user