File: /home/f/r/e/frenchy/www/french-american.org/current/node_modules/uglyfly-js/lib/SymbolDef.js
/***********************************************************************
Copyright 2014 (c) Saair Quaderi <saair.quaderi@gmail.com>
Copyright 2012-2013 (c) Mihai Bazon <mihai.bazon@gmail.com>
UglyflyJS sourcecode can be found here:
https://github.com/quaderi/uglyflyjs
UglyflyJS (by Saair) is a fork of UglifyJS2 (by Mihai Bazon)
Both libraries are released under the BSD 2-Clause License.
***********************************************************************/
/*globals define, module, require */
((typeof define === "function") ? define :
function () { "use strict"; require('./nd').apply(module, arguments); })(
"SymbolDef",
[
//no dependencies
],
function () {
"use strict";
function SymbolDef(scope, index, orig) {
this.name = orig.name;
this.orig = [ orig ];
this.scope = scope;
this.references = [];
this.global = false;
this.mangled_name = null;
this.undeclared = false;
this.constant = false;
this.index = index;
}
SymbolDef.prototype = {
unmangleable: function (options) {
/*jslint evil:true*/ //not actually *using* eval here
options = options || {};
return (this.global && !options.toplevel) ||
this.undeclared ||
(!options.eval && (this.scope.uses_eval || this.scope.uses_with)) ||
(options.keep_fnames && this.orig[0] &&
((this.orig[0].instanceof_SymbolLambda) ||
(this.orig[0].instanceof_SymbolDefun)));
},
mangle: function (options) {
var s;
if (!this.mangled_name && !this.unmangleable(options)) {
s = this.scope;
if (!options.screw_ie8 && this.orig[0] && this.orig[0].instanceof_SymbolLambda) {
s = s.parent_scope;
}
this.mangled_name = s.next_mangled(options, this);
}
}
};
return SymbolDef;
}
);