aboutsummaryrefslogtreecommitdiff
path: root/lib/scope.js
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2017-11-24 03:05:43 +0800
committerGitHub <noreply@github.com>2017-11-24 03:05:43 +0800
commit30cfea2e7a95fd5aaa8092ea0b305ef0be760534 (patch)
treec57d1804a91df0002de4a6e4957077d1c399fdab /lib/scope.js
parentf4e2fb9864a8c5dd6fb24870c4c09761b5914f75 (diff)
downloadtracifyjs-30cfea2e7a95fd5aaa8092ea0b305ef0be760534.tar.gz
tracifyjs-30cfea2e7a95fd5aaa8092ea0b305ef0be760534.zip
fix `rename` (#2501)
- suppress spurious `rename` from `commander` - handle `AST_SymbolCatch` correctly
Diffstat (limited to 'lib/scope.js')
-rw-r--r--lib/scope.js9
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/scope.js b/lib/scope.js
index ea35c0bf..f3010e7c 100644
--- a/lib/scope.js
+++ b/lib/scope.js
@@ -456,6 +456,7 @@ AST_Toplevel.DEFMETHOD("find_unique_prefix", function(options) {
this.globals.each(add_def);
this.walk(new TreeWalker(function(node) {
if (node instanceof AST_Scope) node.variables.each(add_def);
+ if (node instanceof AST_SymbolCatch) add_def(node.definition());
}));
var prefix, i = 0;
do {
@@ -492,17 +493,19 @@ AST_Toplevel.DEFMETHOD("expand_names", function(options) {
this.globals.each(rename);
this.walk(new TreeWalker(function(node) {
if (node instanceof AST_Scope) node.variables.each(rename);
+ if (node instanceof AST_SymbolCatch) rename(node.definition());
}));
function rename(def) {
if (def.global || def.unmangleable(options)) return;
if (member(def.name, options.reserved)) return;
- var name = prefix + def.id;
+ var d = def.redefined();
+ def.name = d ? d.name : prefix + def.id;
def.orig.forEach(function(sym) {
- sym.name = name;
+ sym.name = def.name;
});
def.references.forEach(function(sym) {
- sym.name = name;
+ sym.name = def.name;
});
}
});