From f352a4dcd4e79ab6965ef1f55d15348a76d76680 Mon Sep 17 00:00:00 2001 From: Ting-Yuan Huang Date: Wed, 27 Feb 2019 14:16:05 -0800 Subject: [PATCH] IrBuiltIns: factoring out operator names so that they can be used in other contexts. --- .../kotlin/ir/descriptors/IrBuiltIns.kt | 42 +++++++++++++------ 1 file changed, 29 insertions(+), 13 deletions(-) diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/descriptors/IrBuiltIns.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/descriptors/IrBuiltIns.kt index ad6591aaf92..0b6da1a1d79 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/descriptors/IrBuiltIns.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/descriptors/IrBuiltIns.kt @@ -180,24 +180,24 @@ class IrBuiltIns( val primitiveTypesWithComparisons = listOf(int, long, float, double) val primitiveFloatingPointTypes = listOf(float, double) - val lessFunByOperandType = primitiveTypesWithComparisons.defineComparisonOperatorForEachType("less") - val lessOrEqualFunByOperandType = primitiveTypesWithComparisons.defineComparisonOperatorForEachType("lessOrEqual") - val greaterOrEqualFunByOperandType = primitiveTypesWithComparisons.defineComparisonOperatorForEachType("greaterOrEqual") - val greaterFunByOperandType = primitiveTypesWithComparisons.defineComparisonOperatorForEachType("greater") + val lessFunByOperandType = primitiveTypesWithComparisons.defineComparisonOperatorForEachType(OperatorNames.LESS) + val lessOrEqualFunByOperandType = primitiveTypesWithComparisons.defineComparisonOperatorForEachType(OperatorNames.LESS_OR_EQUAL) + val greaterOrEqualFunByOperandType = primitiveTypesWithComparisons.defineComparisonOperatorForEachType(OperatorNames.GREATER_OR_EQUAL) + val greaterFunByOperandType = primitiveTypesWithComparisons.defineComparisonOperatorForEachType(OperatorNames.GREATER) val ieee754equalsFunByOperandType = primitiveFloatingPointTypes.associate { - it to defineOperator("ieee754equals", bool, listOf(it.makeNullable(), it.makeNullable())) + it to defineOperator(OperatorNames.IEEE754_EQUALS, bool, listOf(it.makeNullable(), it.makeNullable())) } - val eqeqeqFun = defineOperator("EQEQEQ", bool, listOf(anyN, anyN)) - val eqeqFun = defineOperator("EQEQ", bool, listOf(anyN, anyN)) - val throwNpeFun = defineOperator("THROW_NPE", nothing, listOf()) - val throwCceFun = defineOperator("THROW_CCE", nothing, listOf()) - val throwIseFun = defineOperator("THROW_ISE", nothing, listOf()) - val booleanNotFun = defineOperator("NOT", bool, listOf(bool)) - val noWhenBranchMatchedExceptionFun = defineOperator("noWhenBranchMatchedException", nothing, listOf()) - val illegalArgumentExceptionFun = defineOperator("illegalArgumentException", nothing, listOf(string)) + val eqeqeqFun = defineOperator(OperatorNames.EQEQEQ, bool, listOf(anyN, anyN)) + val eqeqFun = defineOperator(OperatorNames.EQEQ, bool, listOf(anyN, anyN)) + val throwNpeFun = defineOperator(OperatorNames.THROW_NPE, nothing, listOf()) + val throwCceFun = defineOperator(OperatorNames.THROW_CCE, nothing, listOf()) + val throwIseFun = defineOperator(OperatorNames.THROW_ISE, nothing, listOf()) + val booleanNotFun = defineOperator(OperatorNames.NOT, bool, listOf(bool)) + val noWhenBranchMatchedExceptionFun = defineOperator(OperatorNames.NO_WHEN_BRANCH_MATCHED_EXCEPTION, nothing, listOf()) + val illegalArgumentExceptionFun = defineOperator(OperatorNames.ILLEGAL_ARGUMENT_EXCEPTION, nothing, listOf(string)) val eqeqeq = eqeqeqFun.descriptor val eqeq = eqeqFun.descriptor @@ -253,4 +253,20 @@ class IrBuiltIns( companion object { val KOTLIN_INTERNAL_IR_FQN = FqName("kotlin.internal.ir") } + + object OperatorNames { + const val LESS = "less" + const val LESS_OR_EQUAL = "lessOrEqual" + const val GREATER = "greater" + const val GREATER_OR_EQUAL = "greaterOrEqual" + const val EQEQ = "EQEQ" + const val EQEQEQ = "EQEQEQ" + const val IEEE754_EQUALS = "ieee754equals" + const val NOT = "NOT" + const val THROW_NPE = "THROW_NPE" + const val THROW_CCE = "THROW_CCE" + const val THROW_ISE = "THROW_ISE" + const val NO_WHEN_BRANCH_MATCHED_EXCEPTION = "noWhenBranchMatchedException" + const val ILLEGAL_ARGUMENT_EXCEPTION = "illegalArgumentException " + } }