aboutsummaryrefslogtreecommitdiff
path: root/lib/scope.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/scope.js')
-rw-r--r--lib/scope.js19
1 files changed, 9 insertions, 10 deletions
diff --git a/lib/scope.js b/lib/scope.js
index 17d87643..fb14480f 100644
--- a/lib/scope.js
+++ b/lib/scope.js
@@ -63,12 +63,12 @@ SymbolDef.prototype = {
unmangleable: function(options) {
if (!options) options = {};
- return (this.global && !options.toplevel)
+ return this.global && !options.toplevel
|| this.undeclared
- || (!options.eval && (this.scope.uses_eval || this.scope.uses_with))
- || (options.keep_fnames
+ || !options.eval && this.scope.pinned()
+ || options.keep_fnames
&& (this.orig[0] instanceof AST_SymbolLambda
- || this.orig[0] instanceof AST_SymbolDefun));
+ || this.orig[0] instanceof AST_SymbolDefun);
},
mangle: function(options) {
var cache = options.cache && options.cache.props;
@@ -355,7 +355,7 @@ function next_mangled_name(scope, options, def) {
return name;
}
-AST_Symbol.DEFMETHOD("unmangleable", function(options){
+AST_Symbol.DEFMETHOD("unmangleable", function(options) {
var def = this.definition();
return !def || def.unmangleable(options);
});
@@ -363,16 +363,15 @@ AST_Symbol.DEFMETHOD("unmangleable", function(options){
// labels are always mangleable
AST_Label.DEFMETHOD("unmangleable", return_false);
-AST_Symbol.DEFMETHOD("unreferenced", function(){
- return this.definition().references.length == 0
- && !(this.scope.uses_eval || this.scope.uses_with);
+AST_Symbol.DEFMETHOD("unreferenced", function() {
+ return !this.definition().references.length && !this.scope.pinned();
});
-AST_Symbol.DEFMETHOD("definition", function(){
+AST_Symbol.DEFMETHOD("definition", function() {
return this.thedef;
});
-AST_Symbol.DEFMETHOD("global", function(){
+AST_Symbol.DEFMETHOD("global", function() {
return this.definition().global;
});