parent
f0c1a01bc2
commit
01d19b4b52
|
|
@ -897,7 +897,9 @@ merge(Compressor.prototype, {
|
||||||
|| this.operator == "--"
|
|| this.operator == "--"
|
||||||
|| this.expression.has_side_effects(compressor);
|
|| this.expression.has_side_effects(compressor);
|
||||||
});
|
});
|
||||||
def(AST_SymbolRef, function(compressor){ return false });
|
def(AST_SymbolRef, function(compressor){
|
||||||
|
return this.global() && this.undeclared();
|
||||||
|
});
|
||||||
def(AST_Object, function(compressor){
|
def(AST_Object, function(compressor){
|
||||||
for (var i = this.properties.length; --i >= 0;)
|
for (var i = this.properties.length; --i >= 0;)
|
||||||
if (this.properties[i].has_side_effects(compressor))
|
if (this.properties[i].has_side_effects(compressor))
|
||||||
|
|
|
||||||
|
|
@ -239,6 +239,7 @@ cond_7: {
|
||||||
evaluate : true
|
evaluate : true
|
||||||
};
|
};
|
||||||
input: {
|
input: {
|
||||||
|
var x, y, z, a, b;
|
||||||
// compress these
|
// compress these
|
||||||
if (y) {
|
if (y) {
|
||||||
x = 1+1;
|
x = 1+1;
|
||||||
|
|
@ -281,6 +282,7 @@ cond_7: {
|
||||||
x = y ? 'foo' : 'fo';
|
x = y ? 'foo' : 'fo';
|
||||||
}
|
}
|
||||||
expect: {
|
expect: {
|
||||||
|
var x, y, z, a, b;
|
||||||
x = 2;
|
x = 2;
|
||||||
x = 2;
|
x = 2;
|
||||||
x = 'foo';
|
x = 'foo';
|
||||||
|
|
@ -293,3 +295,20 @@ cond_7: {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cond_7_1: {
|
||||||
|
options = {
|
||||||
|
conditionals: true,
|
||||||
|
evaluate : true
|
||||||
|
};
|
||||||
|
input: {
|
||||||
|
// access to global should be assumed to have side effects
|
||||||
|
if (y) {
|
||||||
|
x = 1+1;
|
||||||
|
} else {
|
||||||
|
x = 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
x = (y, 2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -91,9 +91,11 @@ make_sequences_4: {
|
||||||
lift_sequences_1: {
|
lift_sequences_1: {
|
||||||
options = { sequences: true };
|
options = { sequences: true };
|
||||||
input: {
|
input: {
|
||||||
|
var foo, x, y, bar;
|
||||||
foo = !(x(), y(), bar());
|
foo = !(x(), y(), bar());
|
||||||
}
|
}
|
||||||
expect: {
|
expect: {
|
||||||
|
var foo, x, y, bar;
|
||||||
x(), y(), foo = !bar();
|
x(), y(), foo = !bar();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -101,10 +103,12 @@ lift_sequences_1: {
|
||||||
lift_sequences_2: {
|
lift_sequences_2: {
|
||||||
options = { sequences: true, evaluate: true };
|
options = { sequences: true, evaluate: true };
|
||||||
input: {
|
input: {
|
||||||
|
var foo, bar;
|
||||||
foo.x = (foo = {}, 10);
|
foo.x = (foo = {}, 10);
|
||||||
bar = (bar = {}, 10);
|
bar = (bar = {}, 10);
|
||||||
}
|
}
|
||||||
expect: {
|
expect: {
|
||||||
|
var foo, bar;
|
||||||
foo.x = (foo = {}, 10),
|
foo.x = (foo = {}, 10),
|
||||||
bar = {}, bar = 10;
|
bar = {}, bar = 10;
|
||||||
}
|
}
|
||||||
|
|
@ -113,9 +117,11 @@ lift_sequences_2: {
|
||||||
lift_sequences_3: {
|
lift_sequences_3: {
|
||||||
options = { sequences: true, conditionals: true };
|
options = { sequences: true, conditionals: true };
|
||||||
input: {
|
input: {
|
||||||
|
var x, foo, bar, baz;
|
||||||
x = (foo(), bar(), baz()) ? 10 : 20;
|
x = (foo(), bar(), baz()) ? 10 : 20;
|
||||||
}
|
}
|
||||||
expect: {
|
expect: {
|
||||||
|
var x, foo, bar, baz;
|
||||||
foo(), bar(), x = baz() ? 10 : 20;
|
foo(), bar(), x = baz() ? 10 : 20;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -123,9 +129,11 @@ lift_sequences_3: {
|
||||||
lift_sequences_4: {
|
lift_sequences_4: {
|
||||||
options = { side_effects: true };
|
options = { side_effects: true };
|
||||||
input: {
|
input: {
|
||||||
|
var x, foo, bar, baz;
|
||||||
x = (foo, bar, baz);
|
x = (foo, bar, baz);
|
||||||
}
|
}
|
||||||
expect: {
|
expect: {
|
||||||
|
var x, foo, bar, baz;
|
||||||
x = baz;
|
x = baz;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user