Merge branch 'master' into harmony-v2.8.2
This commit is contained in:
@@ -61,7 +61,7 @@ function Compressor(options, false_by_default) {
|
||||
booleans : !false_by_default,
|
||||
loops : !false_by_default,
|
||||
unused : !false_by_default,
|
||||
toplevel : !!options["top_retain"],
|
||||
toplevel : !!(options && options["top_retain"]),
|
||||
top_retain : null,
|
||||
hoist_funs : !false_by_default,
|
||||
keep_fargs : true,
|
||||
@@ -188,8 +188,8 @@ merge(Compressor.prototype, {
|
||||
if (node instanceof AST_SymbolRef) {
|
||||
var d = node.definition();
|
||||
d.references.push(node);
|
||||
if (!d.modified && (d.orig.length > 1 || isModified(node, 0))) {
|
||||
d.modified = true;
|
||||
if (d.fixed && (d.orig.length > 1 || isModified(node, 0))) {
|
||||
d.fixed = false;
|
||||
}
|
||||
}
|
||||
if (node instanceof AST_Call && node.expression instanceof AST_Function) {
|
||||
@@ -206,7 +206,7 @@ merge(Compressor.prototype, {
|
||||
this.walk(tw);
|
||||
|
||||
function reset_def(def) {
|
||||
def.modified = false;
|
||||
def.fixed = true;
|
||||
def.references = [];
|
||||
def.should_replace = undefined;
|
||||
if (unsafe && def.init) {
|
||||
@@ -1168,11 +1168,14 @@ merge(Compressor.prototype, {
|
||||
def(AST_Statement, function(){
|
||||
throw new Error(string_template("Cannot evaluate a statement [{file}:{line},{col}]", this.start));
|
||||
});
|
||||
// XXX: AST_Accessor and AST_Function both inherit from AST_Scope,
|
||||
// which itself inherits from AST_Statement; however, they aren't
|
||||
// really statements. This could bite in other places too. :-(
|
||||
// Wish JS had multiple inheritance.
|
||||
def(AST_Accessor, function(){
|
||||
throw def;
|
||||
});
|
||||
def(AST_Function, function(){
|
||||
// XXX: AST_Function inherits from AST_Scope, which itself
|
||||
// inherits from AST_Statement; however, an AST_Function
|
||||
// isn't really a statement. This could byte in other
|
||||
// places too. :-( Wish JS had multiple inheritance.
|
||||
throw def;
|
||||
});
|
||||
def(AST_Arrow, function() {
|
||||
@@ -1210,7 +1213,9 @@ merge(Compressor.prototype, {
|
||||
for (var i = 0, len = this.properties.length; i < len; i++) {
|
||||
var prop = this.properties[i];
|
||||
var key = prop.key;
|
||||
if (key instanceof AST_Node) {
|
||||
if (key instanceof AST_Symbol) {
|
||||
key = key.name;
|
||||
} else if (key instanceof AST_Node) {
|
||||
key = ev(key, compressor);
|
||||
}
|
||||
if (typeof Object.prototype[key] === 'function') {
|
||||
@@ -1290,7 +1295,7 @@ merge(Compressor.prototype, {
|
||||
this._evaluating = true;
|
||||
try {
|
||||
var d = this.definition();
|
||||
if (compressor.option("reduce_vars") && !d.modified && d.init) {
|
||||
if (compressor.option("reduce_vars") && d.fixed && d.init) {
|
||||
if (compressor.option("unsafe")) {
|
||||
if (d.init._evaluated === undefined) {
|
||||
d.init._evaluated = ev(d.init, compressor);
|
||||
@@ -3174,7 +3179,7 @@ merge(Compressor.prototype, {
|
||||
}
|
||||
if (compressor.option("evaluate") && compressor.option("reduce_vars")) {
|
||||
var d = self.definition();
|
||||
if (!d.modified && d.init) {
|
||||
if (d.fixed && d.init) {
|
||||
if (d.should_replace === undefined) {
|
||||
var init = d.init.evaluate(compressor);
|
||||
if (init.length > 1) {
|
||||
|
||||
Reference in New Issue
Block a user