Skip to content

Commit

Permalink
Add an option to prevent function names from being mangled
Browse files Browse the repository at this point in the history
See mishoo#552. This is mostly useful for having the actual function names in traces.
  • Loading branch information
rvanvelzen committed Jan 4, 2015
1 parent 4613644 commit 62d2184
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions lib/scope.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.no_funcs
&& (this.orig[0] instanceof AST_SymbolLambda
|| this.orig[0] instanceof AST_SymbolDefun));
},
mangle: function(options) {
if (!this.mangled_name && !this.unmangleable(options)) {
Expand Down Expand Up @@ -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,
no_funcs : false
});
});

Expand Down

0 comments on commit 62d2184

Please sign in to comment.