diff options
author | Richard van Velzen <rvanvelzen1@gmail.com> | 2015-01-04 20:53:19 +0100 |
---|---|---|
committer | Richard van Velzen <rvanvelzen1@gmail.com> | 2015-01-04 21:48:43 +0100 |
commit | e37b67d013c4537a36bb3c24f4f99e72efbf6d4b (patch) | |
tree | 72776851da0e8fcf1a4f14840d182158615d7081 | |
parent | ad18689d926d25c7a25b95c630c2ad05b7b5f5b5 (diff) | |
download | tracifyjs-e37b67d013c4537a36bb3c24f4f99e72efbf6d4b.tar.gz tracifyjs-e37b67d013c4537a36bb3c24f4f99e72efbf6d4b.zip |
Add an option to prevent function names from being mangled
See #552. This is mostly useful for having the actual function names in traces.
-rw-r--r-- | lib/scope.js | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/lib/scope.js b/lib/scope.js index d252d535..73442a30 100644 --- a/lib/scope.js +++ b/lib/scope.js @@ -57,9 +57,14 @@ function SymbolDef(scope, index, orig) { SymbolDef.prototype = { unmangleable: function(options) { - return (this.global && !(options && options.toplevel)) + if (!options) options = {}; + + return (this.global && !options.toplevel) || this.undeclared - || (!(options && options.eval) && (this.scope.uses_eval || this.scope.uses_with)); + || (!options.eval && (this.scope.uses_eval || this.scope.uses_with)) + || (options.keep_fnames + && (this.orig[0] instanceof AST_SymbolLambda + || this.orig[0] instanceof AST_SymbolDefun)); }, mangle: function(options) { if (!this.mangled_name && !this.unmangleable(options)) { @@ -322,11 +327,12 @@ AST_Symbol.DEFMETHOD("global", function(){ AST_Toplevel.DEFMETHOD("_default_mangler_options", function(options){ return defaults(options, { - except : [], - eval : false, - sort : false, - toplevel : false, - screw_ie8 : false + except : [], + eval : false, + sort : false, + toplevel : false, + screw_ie8 : false, + keep_fnames : false }); }); |