@@ -419,22 +419,26 @@ function simplifyExpressionsPre(ast, asm) {
419419 while ( rerun ) {
420420 rerun = false ;
421421 traverseGenerated ( ast , function process ( node , type , stack ) {
422- if ( type == 'binary' && node [ 1 ] == '|' && ( jsonCompare ( node [ 2 ] , ZERO ) || jsonCompare ( node [ 3 ] , ZERO ) ) ) {
423- // We might be able to remove this correction
424- for ( var i = stack . length - 1 ; i >= 0 ; i -- ) {
425- if ( stack [ i ] == 1 ) {
426- // we will replace ourselves with the non-zero side. Recursively process that node.
427- var result = jsonCompare ( node [ 2 ] , ZERO ) ? node [ 3 ] : node [ 2 ] , other ;
428- // Great, we can eliminate
429- rerun = true ;
430- while ( other = process ( result , result [ 0 ] , stack ) ) {
431- result = other ;
422+ if ( type == 'binary' && node [ 1 ] == '|' ) {
423+ if ( node [ 2 ] [ 0 ] == 'num' && node [ 3 ] [ 0 ] == 'num' ) {
424+ return [ 'num' , node [ 2 ] [ 1 ] | node [ 3 ] [ 1 ] ] ;
425+ } else if ( jsonCompare ( node [ 2 ] , ZERO ) || jsonCompare ( node [ 3 ] , ZERO ) ) {
426+ // We might be able to remove this correction
427+ for ( var i = stack . length - 1 ; i >= 0 ; i -- ) {
428+ if ( stack [ i ] == 1 ) {
429+ // we will replace ourselves with the non-zero side. Recursively process that node.
430+ var result = jsonCompare ( node [ 2 ] , ZERO ) ? node [ 3 ] : node [ 2 ] , other ;
431+ // Great, we can eliminate
432+ rerun = true ;
433+ while ( other = process ( result , result [ 0 ] , stack ) ) {
434+ result = other ;
435+ }
436+ return result ;
437+ } else if ( stack [ i ] == - 1 ) {
438+ break ; // Too bad, we can't
439+ } else if ( asm ) {
440+ break ; // we must keep a coercion right on top of a heap access in asm mode
432441 }
433- return result ;
434- } else if ( stack [ i ] == - 1 ) {
435- break ; // Too bad, we can't
436- } else if ( asm ) {
437- break ; // we must keep a coercion right on top of a heap access in asm mode
438442 }
439443 }
440444 stack . push ( 1 ) ; // From here on up, no need for this kind of correction, it's done at the top
@@ -452,6 +456,7 @@ function simplifyExpressionsPre(ast, asm) {
452456 // &-related optimizations
453457 traverseGenerated ( ast , function ( node , type ) {
454458 if ( type == 'binary' && node [ 1 ] == '&' && node [ 3 ] [ 0 ] == 'num' ) {
459+ if ( node [ 2 ] [ 0 ] == 'num' ) return [ 'num' , node [ 2 ] [ 1 ] & node [ 3 ] [ 1 ] ] ;
455460 var input = node [ 2 ] ;
456461 var amount = node [ 3 ] [ 1 ] ;
457462 if ( input [ 0 ] == 'binary' && input [ 1 ] == '&' && input [ 3 ] [ 0 ] == 'num' ) {
0 commit comments