fix rename (#2501)
- suppress spurious `rename` from `commander` - handle `AST_SymbolCatch` correctly
This commit is contained in:
@@ -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;
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user