@ -32,22 +32,23 @@ fun Long.toLongLiteralExpr(): LongLiteralExpr {
}
}
fun Expression . negate ( ) : Expression {
fun Expression . negate ( ) : Expression {
return if ( isUnaryExpr && asUnaryExpr ( ) . operator == UnaryExpr . Operator . MINUS ) {
return when ( this ) {
asUnaryExpr ( ) . expression . clone ( )
is UnaryExpr -> when ( operator ) {
} else if ( isIntegerLiteralExpr ) {
UnaryExpr . Operator . PLUS -> UnaryExpr ( expression . clone ( ) , UnaryExpr . Operator . MINUS )
when ( val n = asIntegerLiteralExpr ( ) . asNumber ( ) ) {
UnaryExpr . Operator . MINUS -> expression . clone ( )
else -> UnaryExpr ( clone ( ) , UnaryExpr . Operator . MINUS )
}
is IntegerLiteralExpr -> when ( val n = asNumber ( ) ) {
IntegerLiteralExpr . MAX _31 _BIT _UNSIGNED _VALUE _AS _LONG -> IntegerLiteralExpr ( Integer . MIN _VALUE . toString ( ) )
IntegerLiteralExpr . MAX _31 _BIT _UNSIGNED _VALUE _AS _LONG -> IntegerLiteralExpr ( Integer . MIN _VALUE . toString ( ) )
is Int -> IntegerLiteralExpr ( ( - n . toInt ( ) ) . toString ( ) )
is Int -> IntegerLiteralExpr ( ( - n . toInt ( ) ) . toString ( ) )
else -> error ( " Invalid IntegerLiteralExpr type " )
else -> error ( " Invalid IntegerLiteralExpr type " )
}
}
} else if ( isLongLiteralExpr ) {
is LongLiteralExpr -> when ( val n = asNumber ( ) ) {
when ( val n = asLongLiteralExpr ( ) . asNumber ( ) ) {
LongLiteralExpr . MAX _63 _BIT _UNSIGNED _VALUE _AS _BIG _INTEGER -> Long . MIN _VALUE . toLongLiteralExpr ( )
LongLiteralExpr . MAX _63 _BIT _UNSIGNED _VALUE _AS _BIG _INTEGER -> Long . MIN _VALUE . toLongLiteralExpr ( )
is Long -> ( - n ) . toLongLiteralExpr ( )
is Long -> ( - n ) . toLongLiteralExpr ( )
else -> error ( " Invalid LongLiteralExpr type " )
else -> error ( " Invalid LongLiteralExpr type " )
}
}
} else {
else -> UnaryExpr ( clone ( ) , UnaryExpr . Operator . MINUS )
throw IllegalArgumentException ( )
}
}
}
}