implement new and improved let scoping - fixes #91, fixes #102, fixes #124

This commit is contained in:
Sebastian McKenzie
2014-11-04 14:59:44 +11:00
parent d1088583ba
commit 287cbbb6a1
23 changed files with 404 additions and 122 deletions

View File

@@ -94,15 +94,15 @@ t.toBlock = function (node, parent) {
return t.blockStatement(node);
};
t.getIds = function (node) {
t.getIds = function (node, map) {
var search = [node];
var ids = [];
var ids = {};
while (search.length) {
var id = search.shift();
if (t.isIdentifier(id)) {
ids.push(id.name);
ids[id.name] = id;
} else if (t.isArrayPattern(id)) {
_.each(id.elements, function (elem) {
search.push(elem);
@@ -122,6 +122,7 @@ t.getIds = function (node) {
}
}
if (!map) ids = _.keys(ids);
return ids;
};