fix API breakage

close #36, #38
This commit is contained in:
Mihai Bazon
2012-11-08 12:31:28 +02:00
parent 1a5fd3e052
commit e312c5c2a7

View File

@@ -59,7 +59,7 @@ SymbolDef.prototype = {
unmangleable: function(options) { unmangleable: function(options) {
return this.global return this.global
|| this.undeclared || this.undeclared
|| (!options.eval && (this.scope.uses_eval || this.scope.uses_with)); || (!(options && options.eval) && (this.scope.uses_eval || this.scope.uses_with));
}, },
mangle: function(options) { mangle: function(options) {
if (!this.mangled_name && !this.unmangleable(options)) if (!this.mangled_name && !this.unmangleable(options))
@@ -347,11 +347,15 @@ AST_Symbol.DEFMETHOD("global", function(){
return this.definition().global; return this.definition().global;
}); });
AST_Toplevel.DEFMETHOD("mangle_names", function(options){ AST_Toplevel.DEFMETHOD("_default_mangler_options", function(options){
options = defaults(options, { return defaults(options, {
except : [], except : [],
eval : false, eval : false,
}); });
});
AST_Toplevel.DEFMETHOD("mangle_names", function(options){
options = this._default_mangler_options(options);
// We only need to mangle declaration nodes. Special logic wired // We only need to mangle declaration nodes. Special logic wired
// into the code generator will display the mangled name if it's // into the code generator will display the mangled name if it's
// present (and for AST_SymbolRef-s it'll use the mangled name of // present (and for AST_SymbolRef-s it'll use the mangled name of
@@ -387,6 +391,7 @@ AST_Toplevel.DEFMETHOD("mangle_names", function(options){
}); });
AST_Toplevel.DEFMETHOD("compute_char_frequency", function(options){ AST_Toplevel.DEFMETHOD("compute_char_frequency", function(options){
options = this._default_mangler_options(options);
var tw = new TreeWalker(function(node){ var tw = new TreeWalker(function(node){
if (node instanceof AST_Constant) if (node instanceof AST_Constant)
base54.consider(node.print_to_string()); base54.consider(node.print_to_string());