File tree 3 files changed +19
-8
lines changed
3 files changed +19
-8
lines changed Original file line number Diff line number Diff line change @@ -783,14 +783,13 @@ function simplifyExpressionsPost(ast) {
783
783
simplifyNotComps ( ast ) ;
784
784
}
785
785
786
- function hasSideEffects ( node ) { // this is 99% incomplete and wrong! It just works on __label__ == X and number literals
787
- if ( node [ 0 ] == 'num' ) return false ;
788
- if ( node [ 0 ] == 'binary' && ( node [ 1 ] == '==' || node [ 1 ] == '!=' ) && node [ 2 ] [ 0 ] == 'name' &&
789
- node [ 3 ] [ 0 ] == 'num' ) {
790
- return false ;
791
- } else {
792
- return true ;
793
- }
786
+ var NO_SIDE_EFFECTS = set ( 'num' , 'name' ) ;
787
+
788
+ function hasSideEffects ( node ) { // this is 99% incomplete!
789
+ if ( node [ 0 ] in NO_SIDE_EFFECTS ) return false ;
790
+ if ( node [ 0 ] == 'unary-prefix' && node [ 1 ] == '!' ) return hasSideEffects ( node [ 2 ] ) ;
791
+ if ( node [ 0 ] == 'binary' ) return hasSideEffects ( node [ 2 ] ) || hasSideEffects ( node [ 3 ] ) ;
792
+ return true ;
794
793
}
795
794
796
795
// Clear out empty ifs and blocks, and redundant blocks/stats and so forth
Original file line number Diff line number Diff line change @@ -173,6 +173,8 @@ function hoisting() {
173
173
if ( __label__ == 38 ) {
174
174
var $79 = $_pr6 ;
175
175
}
176
+ pause ( 9 ) ;
177
+ var $cmp70 = ( $call69 | 0 ) != 0 ;
176
178
}
177
179
function innerShouldAlsoBeHoisted ( ) {
178
180
function hoisting ( ) {
Original file line number Diff line number Diff line change @@ -216,6 +216,16 @@ function hoisting() {
216
216
var $79 = $_pr6 ;
217
217
}
218
218
} while ( 0 ) ;
219
+ pause ( 9 ) ;
220
+ var $cmp70 = ( $call69 | 0 ) != 0 ;
221
+ if ( $cmp70 ) {
222
+ __label__ = 40 ;
223
+ } else {
224
+ __label__ = 41 ;
225
+ }
226
+ $if_then72$$if_end73$126 : do {
227
+ if ( __label__ == 40 ) { } else if ( __label__ == 41 ) { }
228
+ } while ( 0 ) ;
219
229
}
220
230
function innerShouldAlsoBeHoisted ( ) {
221
231
function hoisting ( ) {
You can’t perform that action at this time.
0 commit comments