public void postProcess ( ) { if ( ! this . isEmptySlot ( ) ) { switch ( savedItem . getExpressionItemType ( ) ) { case OPERATOR : { if ( savedItem == OPERATOR_SUB ) { if ( ! childElements [ 0 ] . isEmptySlot ( ) && childElements [ 1 ] . isEmptySlot ( ) ) { final ExpressionTreeElement left = childElements [ 0 ] ; final ExpressionItem item = left . getItem ( ) ; if ( item . getExpressionItemType ( ) == ExpressionItemType . VALUE ) { final Value val = ( Value ) item ; switch ( val . getType ( ) ) { case INT : { childElements = EMPTY ; savedItem = Value . valueOf ( 0 - val . asLong ( ) ) ; makeMaxPriority ( ) ; } break ; case FLOAT : { childElements = EMPTY ; savedItem = Value . valueOf ( 0.0f - val . asFloat ( ) ) ; makeMaxPriority ( ) ; } break ; default : { if ( ! left . isEmptySlot ( ) ) { left . postProcess ( ) ; } } break ; } } } else { for ( final ExpressionTreeElement element : childElements ) { if ( ! element . isEmptySlot ( ) ) { element . postProcess ( ) ; } } } } else { for ( final ExpressionTreeElement element : childElements ) { if ( ! element . isEmptySlot ( ) ) { element . postProcess ( ) ; } } } } break ; case FUNCTION : { for ( final ExpressionTreeElement element : childElements ) { if ( ! element . isEmptySlot ( ) ) { element . postProcess ( ) ; } } } break ; } } }
Post - processing after the tree is formed the unary minus operation will be optimized