update, text, response
This commit is contained in:
67
node_modules/uglify-js/lib/scope.js
generated
vendored
67
node_modules/uglify-js/lib/scope.js
generated
vendored
@@ -68,9 +68,7 @@ SymbolDef.prototype = {
|
||||
var cache = this.global && options.cache && options.cache.props;
|
||||
if (cache && cache.has(this.name)) {
|
||||
this.mangled_name = cache.get(this.name);
|
||||
} else if (this.unmangleable(options)) {
|
||||
names_in_use(this.scope, options).set(this.name, true);
|
||||
} else {
|
||||
} else if (!this.unmangleable(options)) {
|
||||
var def = this.redefined();
|
||||
if (def) {
|
||||
this.mangled_name = def.mangled_name || def.name;
|
||||
@@ -180,6 +178,13 @@ AST_Toplevel.DEFMETHOD("figure_out_scope", function(options) {
|
||||
});
|
||||
return true;
|
||||
}
|
||||
if (node instanceof AST_Switch) {
|
||||
node.expression.walk(tw);
|
||||
walk_scope(function() {
|
||||
walk_body(node, tw);
|
||||
});
|
||||
return true;
|
||||
}
|
||||
if (node instanceof AST_SwitchBranch) {
|
||||
node.init_vars(scope);
|
||||
descend();
|
||||
@@ -439,35 +444,43 @@ AST_Toplevel.DEFMETHOD("def_global", function(node) {
|
||||
}
|
||||
});
|
||||
|
||||
function init_block_vars(scope, parent) {
|
||||
scope.enclosed = []; // variables from this or outer scope(s) that are referenced from this or inner scopes
|
||||
scope.parent_scope = parent; // the parent scope (null if this is the top level)
|
||||
scope.functions = new Dictionary(); // map name to AST_SymbolDefun (functions defined in this scope)
|
||||
scope.variables = new Dictionary(); // map name to AST_SymbolVar (variables defined in this scope; includes functions)
|
||||
if (parent) scope.make_def = parent.make_def; // top-level tracking of SymbolDef instances
|
||||
function init_block_vars(scope, parent, orig) {
|
||||
// variables from this or outer scope(s) that are referenced from this or inner scopes
|
||||
scope.enclosed = orig ? orig.enclosed.slice() : [];
|
||||
// map name to AST_SymbolDefun (functions defined in this scope)
|
||||
scope.functions = orig ? orig.functions.clone() : new Dictionary();
|
||||
// map name to AST_SymbolVar (variables defined in this scope; includes functions)
|
||||
scope.variables = orig ? orig.variables.clone() : new Dictionary();
|
||||
if (!parent) return;
|
||||
// top-level tracking of SymbolDef instances
|
||||
scope.make_def = parent.make_def;
|
||||
// the parent scope (null if this is the top level)
|
||||
scope.parent_scope = parent;
|
||||
}
|
||||
|
||||
function init_scope_vars(scope, parent) {
|
||||
init_block_vars(scope, parent);
|
||||
scope.uses_eval = false; // will be set to true if this or nested scope uses the global `eval`
|
||||
scope.uses_with = false; // will be set to true if this or some nested scope uses the `with` statement
|
||||
function init_scope_vars(scope, parent, orig) {
|
||||
init_block_vars(scope, parent, orig);
|
||||
// will be set to true if this or nested scope uses the global `eval`
|
||||
scope.uses_eval = false;
|
||||
// will be set to true if this or some nested scope uses the `with` statement
|
||||
scope.uses_with = false;
|
||||
}
|
||||
|
||||
AST_BlockScope.DEFMETHOD("init_vars", function(parent_scope) {
|
||||
init_block_vars(this, parent_scope);
|
||||
AST_BlockScope.DEFMETHOD("init_vars", function(parent, orig) {
|
||||
init_block_vars(this, parent, orig);
|
||||
});
|
||||
AST_Scope.DEFMETHOD("init_vars", function(parent_scope) {
|
||||
init_scope_vars(this, parent_scope);
|
||||
AST_Scope.DEFMETHOD("init_vars", function(parent, orig) {
|
||||
init_scope_vars(this, parent, orig);
|
||||
});
|
||||
AST_Arrow.DEFMETHOD("init_vars", function(parent_scope) {
|
||||
init_scope_vars(this, parent_scope);
|
||||
AST_Arrow.DEFMETHOD("init_vars", function(parent, orig) {
|
||||
init_scope_vars(this, parent, orig);
|
||||
return this;
|
||||
});
|
||||
AST_AsyncArrow.DEFMETHOD("init_vars", function(parent_scope) {
|
||||
init_scope_vars(this, parent_scope);
|
||||
AST_AsyncArrow.DEFMETHOD("init_vars", function(parent, orig) {
|
||||
init_scope_vars(this, parent, orig);
|
||||
});
|
||||
AST_Lambda.DEFMETHOD("init_vars", function(parent_scope) {
|
||||
init_scope_vars(this, parent_scope);
|
||||
AST_Lambda.DEFMETHOD("init_vars", function(parent, orig) {
|
||||
init_scope_vars(this, parent, orig);
|
||||
this.uses_arguments = false;
|
||||
this.def_variable(new AST_SymbolFunarg({
|
||||
name: "arguments",
|
||||
@@ -643,8 +656,12 @@ AST_Toplevel.DEFMETHOD("mangle_names", function(options) {
|
||||
}, true);
|
||||
}
|
||||
var to_mangle = node.to_mangle = [];
|
||||
node.variables.each(function(def) {
|
||||
if (!defer_redef(def)) to_mangle.push(def);
|
||||
node.variables.each(function(def, name) {
|
||||
if (def.unmangleable(options)) {
|
||||
names_in_use(node, options).set(name, true);
|
||||
} else if (!defer_redef(def)) {
|
||||
to_mangle.push(def);
|
||||
}
|
||||
});
|
||||
descend();
|
||||
if (options.cache && node instanceof AST_Toplevel) {
|
||||
|
||||
Reference in New Issue
Block a user