Implement special desugaring for numeric comparisons in PSI2IR
This introduces the following IR built-in functions required for proper
implementation of the number comparisons:
- ieee754Equals(T, T): Boolean,
for each T in {Float?, Double?}
- less(T, T): Boolean
lessOrEqual(T, T): Boolean
greater(T, T): Boolean
greaterOrEqual(T, T): Boolean
for each T in {Int, Long, Float, Double}
This commit is contained in:
+14
@@ -0,0 +1,14 @@
|
||||
fun test1d(x: Double, y: Double) = x.compareTo(y)
|
||||
fun test2d(x: Double, y: Any) = y is Double && x.compareTo(y) == 0
|
||||
fun test3d(x: Any, y: Any) = x is Double && y is Double && x.compareTo(y) == 0
|
||||
|
||||
fun test1f(x: Float, y: Float) = x.compareTo(y)
|
||||
fun test2f(x: Float, y: Any) = y is Float && x.compareTo(y) == 0
|
||||
fun test3f(x: Any, y: Any) = x is Float && y is Float && x.compareTo(y) == 0
|
||||
|
||||
fun testFD(x: Any, y: Any) = x is Float && y is Double && x.compareTo(y) == 0
|
||||
fun testDF(x: Any, y: Any) = x is Double && y is Float && x.compareTo(y) == 0
|
||||
|
||||
fun Float.test1fr(x: Float) = compareTo(x)
|
||||
fun Float.test2fr(x: Any) = x is Float && compareTo(x) == 0
|
||||
fun Float.test3fr(x: Any) = x is Double && compareTo(x) == 0
|
||||
Reference in New Issue
Block a user