Refactor: introduce PrimitiveType.isFloatingPoint
This commit is contained in:
@@ -232,7 +232,7 @@ object Aggregates : TemplateGroupBase() {
|
||||
|
||||
|
||||
val f_minMax = run {
|
||||
val genericSpecializations = PrimitiveType.numericPrimitives.filterNot { it.isIntegral() }.toSet() + setOf(null)
|
||||
val genericSpecializations = PrimitiveType.floatingPointPrimitives + setOf(null)
|
||||
|
||||
listOf("min", "max").map { op ->
|
||||
fn("$op()") {
|
||||
@@ -242,7 +242,7 @@ object Aggregates : TemplateGroupBase() {
|
||||
include(ArraysOfPrimitives, PrimitiveType.defaultPrimitives - PrimitiveType.Boolean)
|
||||
include(CharSequences)
|
||||
} builder {
|
||||
val isFloat = primitive?.isIntegral() == false
|
||||
val isFloat = primitive?.isFloatingPoint() == true
|
||||
val isGeneric = f in listOf(Iterables, Sequences, ArraysOfObjects)
|
||||
|
||||
typeParam("T : Comparable<T>")
|
||||
|
||||
@@ -174,7 +174,7 @@ object ComparableOps : TemplateGroupBase() {
|
||||
body { "return minOf(a.toInt(), b.toInt()).$convertBack" }
|
||||
}
|
||||
}
|
||||
if (primitive?.isIntegral() == false) {
|
||||
if (primitive?.isFloatingPoint() == true) {
|
||||
on(Platform.Native) {
|
||||
body {
|
||||
"""
|
||||
@@ -314,7 +314,7 @@ object ComparableOps : TemplateGroupBase() {
|
||||
body { "return maxOf(a.toInt(), b.toInt()).$convertBack" }
|
||||
}
|
||||
}
|
||||
if (primitive?.isIntegral() == false) {
|
||||
if (primitive?.isFloatingPoint() == true) {
|
||||
on(Platform.Native) {
|
||||
body {
|
||||
"""
|
||||
|
||||
@@ -60,6 +60,7 @@ enum class PrimitiveType {
|
||||
val defaultPrimitives = PrimitiveType.values().toSet() - unsignedPrimitives
|
||||
val numericPrimitives = setOf(Int, Long, Byte, Short, Double, Float)
|
||||
val integralPrimitives = setOf(Int, Long, Byte, Short, Char)
|
||||
val floatingPointPrimitives = setOf(Double, Float)
|
||||
val rangePrimitives = setOf(Int, Long, Char, UInt, ULong)
|
||||
|
||||
val descendingByDomainCapacity = listOf(Double, Float, Long, Int, Short, Char, Byte)
|
||||
@@ -73,6 +74,8 @@ enum class PrimitiveType {
|
||||
|
||||
fun PrimitiveType.isIntegral(): Boolean = this in PrimitiveType.integralPrimitives
|
||||
fun PrimitiveType.isNumeric(): Boolean = this in PrimitiveType.numericPrimitives
|
||||
fun PrimitiveType.isFloatingPoint(): Boolean = this in PrimitiveType.floatingPointPrimitives
|
||||
|
||||
enum class Inline {
|
||||
No,
|
||||
Yes,
|
||||
|
||||
Reference in New Issue
Block a user