From 61e83a4db5c4c6dc7b41b5353945b98e811f1a2b Mon Sep 17 00:00:00 2001 From: Ilya Gorbunov Date: Mon, 7 Nov 2016 04:33:52 +0300 Subject: [PATCH] Remove obsolete range-related intrinsics from JS translator. --- .../intrinsic/functions/factories/LongOperationFIF.kt | 4 ++-- .../functions/factories/PrimitiveBinaryOperationFIF.java | 7 +++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/js/js.translator/src/org/jetbrains/kotlin/js/translate/intrinsic/functions/factories/LongOperationFIF.kt b/js/js.translator/src/org/jetbrains/kotlin/js/translate/intrinsic/functions/factories/LongOperationFIF.kt index f04c7a695b0..38f7d4780e9 100644 --- a/js/js.translator/src/org/jetbrains/kotlin/js/translate/intrinsic/functions/factories/LongOperationFIF.kt +++ b/js/js.translator/src/org/jetbrains/kotlin/js/translate/intrinsic/functions/factories/LongOperationFIF.kt @@ -32,11 +32,11 @@ object LongOperationFIF : FunctionIntrinsicFactory { val LONG_BINARY_OPERATION_LONG = pattern("Long.compareTo|rangeTo|plus|minus|times|div|mod|and|or|xor(Long)") val LONG_BIT_SHIFTS = pattern("Long.shl|shr|ushr(Int)") val LONG_BINARY_OPERATION_INTEGER = pattern("Long.compareTo|rangeTo|plus|minus|times|div|mod(Int|Short|Byte)") - val LONG_BINARY_OPERATION_FLOATING_POINT = pattern("Long.compareTo|rangeTo|plus|minus|times|div|mod(Double|Float)") + val LONG_BINARY_OPERATION_FLOATING_POINT = pattern("Long.compareTo|plus|minus|times|div|mod(Double|Float)") val INTEGER_BINARY_OPERATION_LONG = pattern("Int|Short|Byte.compareTo|rangeTo|plus|minus|times|div|mod(Long)") val CHAR_BINARY_OPERATION_LONG = pattern("Char.compareTo|rangeTo|plus|minus|times|div|mod(Long)") val LONG_BINARY_OPERATION_CHAR = pattern("Long.compareTo|rangeTo|plus|minus|times|div|mod(Char)") - val FLOATING_POINT_BINARY_OPERATION_LONG = pattern("Double|Float.compareTo|rangeTo|plus|minus|times|div|mod(Long)") + val FLOATING_POINT_BINARY_OPERATION_LONG = pattern("Double|Float.compareTo|plus|minus|times|div|mod(Long)") private val longBinaryIntrinsics = ( diff --git a/js/js.translator/src/org/jetbrains/kotlin/js/translate/intrinsic/functions/factories/PrimitiveBinaryOperationFIF.java b/js/js.translator/src/org/jetbrains/kotlin/js/translate/intrinsic/functions/factories/PrimitiveBinaryOperationFIF.java index bad606150e4..05c5d8ab8da 100644 --- a/js/js.translator/src/org/jetbrains/kotlin/js/translate/intrinsic/functions/factories/PrimitiveBinaryOperationFIF.java +++ b/js/js.translator/src/org/jetbrains/kotlin/js/translate/intrinsic/functions/factories/PrimitiveBinaryOperationFIF.java @@ -103,6 +103,9 @@ public enum PrimitiveBinaryOperationFIF implements FunctionIntrinsicFactory { private static final DescriptorPredicate BOOLEAN_OPERATIONS = pattern("Boolean.or|and|xor"); private static final DescriptorPredicate STRING_PLUS = pattern("String.plus"); + private static final DescriptorPredicate CHAR_RANGE_TO = pattern("Char.rangeTo(Char)"); + private static final DescriptorPredicate NUMBER_RANGE_TO = pattern("Byte|Short|Int.rangeTo(Byte|Short|Int)"); + private static final ImmutableMap BINARY_BITWISE_OPERATIONS = ImmutableMap.builder() .put("or", JsBinaryOperator.BIT_OR) .put("and", JsBinaryOperator.BIT_AND) @@ -119,7 +122,7 @@ public enum PrimitiveBinaryOperationFIF implements FunctionIntrinsicFactory { @Nullable @Override public FunctionIntrinsic getIntrinsic(@NotNull FunctionDescriptor descriptor) { - if (pattern("Char.rangeTo(Char)").apply(descriptor)) { + if (CHAR_RANGE_TO.apply(descriptor)) { return new RangeToIntrinsic(descriptor); } @@ -140,7 +143,7 @@ public enum PrimitiveBinaryOperationFIF implements FunctionIntrinsicFactory { if (pattern("Int|Short|Byte.div(Int|Short|Byte)").apply(descriptor)) { return INTEGER_DIVISION_INTRINSIC; } - if (descriptor.getName().equals(Name.identifier("rangeTo"))) { + if (NUMBER_RANGE_TO.apply(descriptor)) { return new RangeToIntrinsic(descriptor); } if (INT_WITH_BIT_OPERATIONS.apply(descriptor)) {