Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
for (var i = 0; i < this.stk.length; ++i) {
var scope = this.stk[i].scope;
if (scope.hasOwnProperty(name)) {
decl = scope[name];
break;
}
}
return decl;
};
var ScopedIterator = function ScopedIterator(root, globalScope) {
this.scopes = new ScopeStack(root, globalScope);
esprima.TreeIterator.call(this, root);
};
var Base = esprima.TreeIterator.prototype;
ScopedIterator.prototype = Object.create(Base);
ScopedIterator.prototype.stepIn = function stepIn() {
var node = this.get();
var type = node.type;
if (type === "FunctionDeclaration" || type === "FunctionExpression") {
this.scopes.push(node);
}
Base.stepIn.call(this);
};
ScopedIterator.prototype.stepOut = function stepOut() {
if (!Base.stepOut.call(this)) return false;
var node = this.get();
if (node === this.scopes.top().node) {
this.scopes.pop(node);
/**
* Moves to the next node in the depth-first iteration order (which may be a
* child).
* @param skipSubtree {Boolean}
* Whether or not to skip over the current node's children.
*/
TreeIterator.prototype.next = function next(skipSubtree) {
if (skipSubtree || this.isLeaf()) {
this.nextNonDescendant();
} else {
this.stepIn();
}
};
require("esprima").TreeIterator = TreeIterator;
}());
var ScopedIterator = function ScopedIterator(root, globalScope) {
this.scopes = new ScopeStack(root, globalScope);
esprima.TreeIterator.call(this, root);
};