public static Expression compare ( final int comparisonOpcode , final Expression left , final Expression right ) { checkArgument ( left . resultType ( ) . equals ( right . resultType ( ) ) , "left and right must have matching types, found %s and %s" , left . resultType ( ) , right . resultType ( ) ) ; checkIntComparisonOpcode ( left . resultType ( ) , comparisonOpcode ) ; Features features = Expression . areAllCheap ( left , right ) ? Features . of ( Feature . CHEAP ) : Features . of ( ) ; return new Expression ( Type . BOOLEAN_TYPE , features ) { @ Override protected void doGen ( CodeBuilder mv ) { left . gen ( mv ) ; right . gen ( mv ) ; Label ifTrue = mv . newLabel ( ) ; Label end = mv . newLabel ( ) ; mv . ifCmp ( left . resultType ( ) , comparisonOpcode , ifTrue ) ; mv . pushBoolean ( false ) ; mv . goTo ( end ) ; mv . mark ( ifTrue ) ; mv . pushBoolean ( true ) ; mv . mark ( end ) ; } } ; }
Compares the two primitive valued expressions using the provided comparison operation .