fix API breakage
authorMihai Bazon <mihai@bazon.net>
Thu, 8 Nov 2012 10:31:28 +0000 (12:31 +0200)
committerMihai Bazon <mihai@bazon.net>
Thu, 8 Nov 2012 10:31:28 +0000 (12:31 +0200)
close #36, #38

lib/scope.js

index f8a1cb8..dc637cc 100644 (file)
@@ -59,7 +59,7 @@ SymbolDef.prototype = {
     unmangleable: function(options) {
         return this.global
             || 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) {
         if (!this.mangled_name && !this.unmangleable(options))
@@ -347,11 +347,15 @@ AST_Symbol.DEFMETHOD("global", function(){
     return this.definition().global;
 });
 
-AST_Toplevel.DEFMETHOD("mangle_names", function(options){
-    options = defaults(options, {
+AST_Toplevel.DEFMETHOD("_default_mangler_options", function(options){
+    return defaults(options, {
         except : [],
         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
     // 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
@@ -387,6 +391,7 @@ AST_Toplevel.DEFMETHOD("mangle_names", function(options){
 });
 
 AST_Toplevel.DEFMETHOD("compute_char_frequency", function(options){
+    options = this._default_mangler_options(options);
     var tw = new TreeWalker(function(node){
         if (node instanceof AST_Constant)
             base54.consider(node.print_to_string());