@@ -336,13 +336,10 @@ merge(Compressor.prototype, {
336
336
def . chained = false ;
337
337
def . direct_access = false ;
338
338
def . escaped = false ;
339
- if ( def . scope . pinned ( ) ) {
340
- def . fixed = false ;
341
- } else if ( ! compressor . exposed ( def ) ) {
342
- def . fixed = def . init ;
343
- } else {
344
- def . fixed = false ;
345
- }
339
+ def . fixed = ! def . scope . pinned ( )
340
+ && ! compressor . exposed ( def )
341
+ && ! ( def . init instanceof AST_Function && def . init !== def . scope )
342
+ && def . init ;
346
343
if ( def . fixed instanceof AST_Defun && ! all ( def . references , function ( ref ) {
347
344
var scope = ref . scope ;
348
345
do {
@@ -3444,6 +3441,7 @@ merge(Compressor.prototype, {
3444
3441
if ( scope !== self ) return ;
3445
3442
if ( node instanceof AST_Function
3446
3443
&& node . name
3444
+ && ! compressor . option ( "ie8" )
3447
3445
&& ! compressor . option ( "keep_fnames" ) ) {
3448
3446
var def = node . name . definition ( ) ;
3449
3447
// any declarations with same name will overshadow
@@ -3927,8 +3925,39 @@ merge(Compressor.prototype, {
3927
3925
}
3928
3926
3929
3927
def ( AST_Node , return_this ) ;
3930
- def ( AST_Constant , return_null ) ;
3931
- def ( AST_This , return_null ) ;
3928
+ def ( AST_Accessor , return_null ) ;
3929
+ def ( AST_Array , function ( compressor , first_in_statement ) {
3930
+ var values = trim ( this . elements , compressor , first_in_statement ) ;
3931
+ return values && make_sequence ( this , values ) ;
3932
+ } ) ;
3933
+ def ( AST_Assign , function ( compressor ) {
3934
+ var left = this . left ;
3935
+ if ( left . has_side_effects ( compressor )
3936
+ || compressor . has_directive ( "use strict" )
3937
+ && left instanceof AST_PropAccess
3938
+ && left . expression . is_constant ( ) ) {
3939
+ return this ;
3940
+ }
3941
+ this . write_only = true ;
3942
+ if ( root_expr ( left ) . is_constant_expression ( compressor . find_parent ( AST_Scope ) ) ) {
3943
+ return this . right . drop_side_effect_free ( compressor ) ;
3944
+ }
3945
+ return this ;
3946
+ } ) ;
3947
+ def ( AST_Binary , function ( compressor , first_in_statement ) {
3948
+ var right = this . right . drop_side_effect_free ( compressor ) ;
3949
+ if ( ! right ) return this . left . drop_side_effect_free ( compressor , first_in_statement ) ;
3950
+ if ( lazy_op [ this . operator ] ) {
3951
+ if ( right === this . right ) return this ;
3952
+ var node = this . clone ( ) ;
3953
+ node . right = right ;
3954
+ return node ;
3955
+ } else {
3956
+ var left = this . left . drop_side_effect_free ( compressor , first_in_statement ) ;
3957
+ if ( ! left ) return this . right . drop_side_effect_free ( compressor , first_in_statement ) ;
3958
+ return make_sequence ( this , [ left , right ] ) ;
3959
+ }
3960
+ } ) ;
3932
3961
def ( AST_Call , function ( compressor , first_in_statement ) {
3933
3962
if ( ! this . is_expr_pure ( compressor ) ) {
3934
3963
if ( this . expression . is_call_pure ( compressor ) ) {
@@ -3959,36 +3988,6 @@ merge(Compressor.prototype, {
3959
3988
var args = trim ( this . args , compressor , first_in_statement ) ;
3960
3989
return args && make_sequence ( this , args ) ;
3961
3990
} ) ;
3962
- def ( AST_Accessor , return_null ) ;
3963
- def ( AST_Function , return_null ) ;
3964
- def ( AST_Binary , function ( compressor , first_in_statement ) {
3965
- var right = this . right . drop_side_effect_free ( compressor ) ;
3966
- if ( ! right ) return this . left . drop_side_effect_free ( compressor , first_in_statement ) ;
3967
- if ( lazy_op [ this . operator ] ) {
3968
- if ( right === this . right ) return this ;
3969
- var node = this . clone ( ) ;
3970
- node . right = right ;
3971
- return node ;
3972
- } else {
3973
- var left = this . left . drop_side_effect_free ( compressor , first_in_statement ) ;
3974
- if ( ! left ) return this . right . drop_side_effect_free ( compressor , first_in_statement ) ;
3975
- return make_sequence ( this , [ left , right ] ) ;
3976
- }
3977
- } ) ;
3978
- def ( AST_Assign , function ( compressor ) {
3979
- var left = this . left ;
3980
- if ( left . has_side_effects ( compressor )
3981
- || compressor . has_directive ( "use strict" )
3982
- && left instanceof AST_PropAccess
3983
- && left . expression . is_constant ( ) ) {
3984
- return this ;
3985
- }
3986
- this . write_only = true ;
3987
- if ( root_expr ( left ) . is_constant_expression ( compressor . find_parent ( AST_Scope ) ) ) {
3988
- return this . right . drop_side_effect_free ( compressor ) ;
3989
- }
3990
- return this ;
3991
- } ) ;
3992
3991
def ( AST_Conditional , function ( compressor ) {
3993
3992
var consequent = this . consequent . drop_side_effect_free ( compressor ) ;
3994
3993
var alternative = this . alternative . drop_side_effect_free ( compressor ) ;
@@ -4008,6 +4007,14 @@ merge(Compressor.prototype, {
4008
4007
node . alternative = alternative ;
4009
4008
return node ;
4010
4009
} ) ;
4010
+ def ( AST_Constant , return_null ) ;
4011
+ def ( AST_Dot , function ( compressor , first_in_statement ) {
4012
+ if ( this . expression . may_throw_on_access ( compressor ) ) return this ;
4013
+ return this . expression . drop_side_effect_free ( compressor , first_in_statement ) ;
4014
+ } ) ;
4015
+ def ( AST_Function , function ( compressor ) {
4016
+ return this . name && compressor . option ( "ie8" ) ? this : null ;
4017
+ } ) ;
4011
4018
def ( AST_Unary , function ( compressor , first_in_statement ) {
4012
4019
if ( unary_side_effects [ this . operator ] ) {
4013
4020
this . write_only = ! this . expression . has_side_effects ( compressor ) ;
@@ -4021,23 +4028,20 @@ merge(Compressor.prototype, {
4021
4028
}
4022
4029
return expression ;
4023
4030
} ) ;
4024
- def ( AST_SymbolRef , function ( compressor ) {
4025
- return this . is_declared ( compressor ) ? null : this ;
4026
- } ) ;
4027
4031
def ( AST_Object , function ( compressor , first_in_statement ) {
4028
4032
var values = trim ( this . properties , compressor , first_in_statement ) ;
4029
4033
return values && make_sequence ( this , values ) ;
4030
4034
} ) ;
4031
4035
def ( AST_ObjectProperty , function ( compressor , first_in_statement ) {
4032
4036
return this . value . drop_side_effect_free ( compressor , first_in_statement ) ;
4033
4037
} ) ;
4034
- def ( AST_Array , function ( compressor , first_in_statement ) {
4035
- var values = trim ( this . elements , compressor , first_in_statement ) ;
4036
- return values && make_sequence ( this , values ) ;
4037
- } ) ;
4038
- def ( AST_Dot , function ( compressor , first_in_statement ) {
4039
- if ( this . expression . may_throw_on_access ( compressor ) ) return this ;
4040
- return this . expression . drop_side_effect_free ( compressor , first_in_statement ) ;
4038
+ def ( AST_Sequence , function ( compressor ) {
4039
+ var last = this . tail_node ( ) ;
4040
+ var expr = last . drop_side_effect_free ( compressor ) ;
4041
+ if ( expr === last ) return this ;
4042
+ var expressions = this . expressions . slice ( 0 , - 1 ) ;
4043
+ if ( expr ) expressions . push ( expr ) ;
4044
+ return make_sequence ( this , expressions ) ;
4041
4045
} ) ;
4042
4046
def ( AST_Sub , function ( compressor , first_in_statement ) {
4043
4047
if ( this . expression . may_throw_on_access ( compressor ) ) return this ;
@@ -4047,14 +4051,10 @@ merge(Compressor.prototype, {
4047
4051
if ( ! property ) return expression ;
4048
4052
return make_sequence ( this , [ expression , property ] ) ;
4049
4053
} ) ;
4050
- def ( AST_Sequence , function ( compressor ) {
4051
- var last = this . tail_node ( ) ;
4052
- var expr = last . drop_side_effect_free ( compressor ) ;
4053
- if ( expr === last ) return this ;
4054
- var expressions = this . expressions . slice ( 0 , - 1 ) ;
4055
- if ( expr ) expressions . push ( expr ) ;
4056
- return make_sequence ( this , expressions ) ;
4054
+ def ( AST_SymbolRef , function ( compressor ) {
4055
+ return this . is_declared ( compressor ) ? null : this ;
4057
4056
} ) ;
4057
+ def ( AST_This , return_null ) ;
4058
4058
} ) ( function ( node , func ) {
4059
4059
node . DEFMETHOD ( "drop_side_effect_free" , func ) ;
4060
4060
} ) ;
0 commit comments