diff --git a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/JsIntrinsics.kt b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/JsIntrinsics.kt index ff0c1ec70f6..fc5b964e53d 100644 --- a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/JsIntrinsics.kt +++ b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/JsIntrinsics.kt @@ -9,9 +9,12 @@ import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.builtins.PrimitiveType import org.jetbrains.kotlin.ir.backend.js.ir.JsIrBuilder import org.jetbrains.kotlin.ir.backend.js.utils.Namer +import org.jetbrains.kotlin.ir.declarations.IrFunction +import org.jetbrains.kotlin.ir.declarations.IrProperty import org.jetbrains.kotlin.ir.declarations.impl.IrExternalPackageFragmentImpl import org.jetbrains.kotlin.ir.descriptors.IrBuiltIns import org.jetbrains.kotlin.ir.symbols.impl.IrExternalPackageFragmentSymbolImpl +import org.jetbrains.kotlin.ir.util.getPropertyGetter import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.psi2ir.findSingleFunction @@ -219,6 +222,20 @@ class JsIntrinsics(private val irBuiltIns: IrBuiltIns, val context: JsIrBackendC val jsArraySlice = unOp("slice") + // TODO move to IntrinsifyCallsLowering + val doNotIntrinsifyAnnotationSymbol = context.symbolTable.referenceClass(context.getInternalClass("DoNotIntrinsify")) + + // TODO move CharSequence-related stiff to IntrinsifyCallsLowering + val charSequenceClassSymbol = context.symbolTable.referenceClass(context.getClass(FqName("kotlin.CharSequence"))) + val charSequenceLengthPropertyGetterSymbol = charSequenceClassSymbol.owner.declarations.filterIsInstance().first { it.name.asString() == "length" }.getter!!.symbol + val charSequenceGetFunctionSymbol = charSequenceClassSymbol.owner.declarations.filterIsInstance().single { it.name.asString() == "get"}.symbol + val charSequenceSubSequenceFunctionSymbol = charSequenceClassSymbol.owner.declarations.filterIsInstance().single { it.name.asString() == "subSequence"}.symbol + + + val jsCharSequenceGet = getInternalFunction("charSequenceGet") + val jsCharSequenceLength = getInternalFunction("charSequenceLength") + val jsCharSequenceSubSequence = getInternalFunction("charSequenceSubSequence") + // Helpers: private fun getInternalFunction(name: String) = diff --git a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/IntrinsicifyCallsLowering.kt b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/IntrinsicifyCallsLowering.kt index c087142892c..9030ce86a26 100644 --- a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/IntrinsicifyCallsLowering.kt +++ b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/IntrinsicifyCallsLowering.kt @@ -162,6 +162,13 @@ class IntrinsicifyCallsLowering(private val context: JsIrBackendContext) : FileL } add(context.irBuiltIns.stringClass.lengthProperty, context.intrinsics.jsArrayLength, true) + add(context.irBuiltIns.stringClass.getFunction, intrinsics.jsCharSequenceGet.owner, true) + add(context.irBuiltIns.stringClass.owner.declarations.filterIsInstance().single { it.name.asString() == "subSequence"}.symbol, + intrinsics.jsCharSequenceSubSequence.owner, true) + + add(intrinsics.charSequenceLengthPropertyGetterSymbol, intrinsics.jsCharSequenceLength.owner, true) + add(intrinsics.charSequenceGetFunctionSymbol, intrinsics.jsCharSequenceGet.owner, true) + add(intrinsics.charSequenceSubSequenceFunctionSymbol, intrinsics.jsCharSequenceSubSequence.owner, true) } memberToTransformer.run { @@ -352,6 +359,10 @@ class IntrinsicifyCallsLowering(private val context: JsIrBackendContext) : FileL val symbol = call.symbol val declaration = symbol.owner + if (declaration.annotations.any { it.superQualifierSymbol == intrinsics.doNotIntrinsifyAnnotationSymbol }) { + return call + } + if (declaration.isDynamic() || declaration.isEffectivelyExternal()) { when (call.origin) { IrStatementOrigin.GET_PROPERTY -> { diff --git a/compiler/testData/codegen/box/controlStructures/forInCharSequenceMut.kt b/compiler/testData/codegen/box/controlStructures/forInCharSequenceMut.kt index 7b825e8d947..6f2b3414c02 100644 --- a/compiler/testData/codegen/box/controlStructures/forInCharSequenceMut.kt +++ b/compiler/testData/codegen/box/controlStructures/forInCharSequenceMut.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // WITH_RUNTIME fun box(): String { diff --git a/compiler/testData/codegen/box/controlStructures/forInCharSequenceWithIndex/forInCharSequenceWithIndex.kt b/compiler/testData/codegen/box/controlStructures/forInCharSequenceWithIndex/forInCharSequenceWithIndex.kt index b56ff79ebe6..1435bb37248 100644 --- a/compiler/testData/codegen/box/controlStructures/forInCharSequenceWithIndex/forInCharSequenceWithIndex.kt +++ b/compiler/testData/codegen/box/controlStructures/forInCharSequenceWithIndex/forInCharSequenceWithIndex.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // WITH_RUNTIME val cs: CharSequence = "abcd" diff --git a/compiler/testData/codegen/box/controlStructures/forInCharSequenceWithIndex/forInEmptyStringWithIndex.kt b/compiler/testData/codegen/box/controlStructures/forInCharSequenceWithIndex/forInEmptyStringWithIndex.kt index bcd3fd93915..490e0e6b01f 100644 --- a/compiler/testData/codegen/box/controlStructures/forInCharSequenceWithIndex/forInEmptyStringWithIndex.kt +++ b/compiler/testData/codegen/box/controlStructures/forInCharSequenceWithIndex/forInEmptyStringWithIndex.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // WITH_RUNTIME fun box(): String { diff --git a/compiler/testData/codegen/box/controlStructures/forInCharSequenceWithIndex/forInStringWithIndex.kt b/compiler/testData/codegen/box/controlStructures/forInCharSequenceWithIndex/forInStringWithIndex.kt index d64630e86c1..bcc212852ff 100644 --- a/compiler/testData/codegen/box/controlStructures/forInCharSequenceWithIndex/forInStringWithIndex.kt +++ b/compiler/testData/codegen/box/controlStructures/forInCharSequenceWithIndex/forInStringWithIndex.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // WITH_RUNTIME fun box(): String { diff --git a/compiler/testData/codegen/box/controlStructures/forInCharSequenceWithIndex/forInStringWithIndexNoElementVar.kt b/compiler/testData/codegen/box/controlStructures/forInCharSequenceWithIndex/forInStringWithIndexNoElementVar.kt index c4d2e0649bc..00fcb0608a0 100644 --- a/compiler/testData/codegen/box/controlStructures/forInCharSequenceWithIndex/forInStringWithIndexNoElementVar.kt +++ b/compiler/testData/codegen/box/controlStructures/forInCharSequenceWithIndex/forInStringWithIndexNoElementVar.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // WITH_RUNTIME val xs = "abcd" diff --git a/compiler/testData/codegen/box/controlStructures/forInCharSequenceWithIndex/forInStringWithIndexNoIndexVar.kt b/compiler/testData/codegen/box/controlStructures/forInCharSequenceWithIndex/forInStringWithIndexNoIndexVar.kt index d4b890ed581..3c6acafa997 100644 --- a/compiler/testData/codegen/box/controlStructures/forInCharSequenceWithIndex/forInStringWithIndexNoIndexVar.kt +++ b/compiler/testData/codegen/box/controlStructures/forInCharSequenceWithIndex/forInStringWithIndexNoIndexVar.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // WITH_RUNTIME val xs = "abcd" diff --git a/compiler/testData/codegen/box/controlStructures/forInCharSequenceWithIndex/forInStringWithIndexWithExplicitlyTypedIndexVariable.kt b/compiler/testData/codegen/box/controlStructures/forInCharSequenceWithIndex/forInStringWithIndexWithExplicitlyTypedIndexVariable.kt index 8112c4bc342..fd72df19e45 100644 --- a/compiler/testData/codegen/box/controlStructures/forInCharSequenceWithIndex/forInStringWithIndexWithExplicitlyTypedIndexVariable.kt +++ b/compiler/testData/codegen/box/controlStructures/forInCharSequenceWithIndex/forInStringWithIndexWithExplicitlyTypedIndexVariable.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // WITH_RUNTIME val xs = "abcd" diff --git a/compiler/testData/codegen/box/coroutines/featureIntersection/tailrec/realStringEscape.kt b/compiler/testData/codegen/box/coroutines/featureIntersection/tailrec/realStringEscape.kt index 93f55d3a968..8a48c18620d 100644 --- a/compiler/testData/codegen/box/coroutines/featureIntersection/tailrec/realStringEscape.kt +++ b/compiler/testData/codegen/box/coroutines/featureIntersection/tailrec/realStringEscape.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // IGNORE_BACKEND: JVM_IR // WITH_RUNTIME // WITH_COROUTINES diff --git a/compiler/testData/codegen/box/coroutines/mergeNullAndString.kt b/compiler/testData/codegen/box/coroutines/mergeNullAndString.kt index 68b896259be..a411b05d2ad 100644 --- a/compiler/testData/codegen/box/coroutines/mergeNullAndString.kt +++ b/compiler/testData/codegen/box/coroutines/mergeNullAndString.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // IGNORE_BACKEND: JVM_IR // WITH_RUNTIME // WITH_COROUTINES diff --git a/compiler/testData/codegen/box/coroutines/suspendFunctionTypeCall/localVal.kt b/compiler/testData/codegen/box/coroutines/suspendFunctionTypeCall/localVal.kt index b2a3831cea6..645c130ade2 100644 --- a/compiler/testData/codegen/box/coroutines/suspendFunctionTypeCall/localVal.kt +++ b/compiler/testData/codegen/box/coroutines/suspendFunctionTypeCall/localVal.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // IGNORE_BACKEND: JVM_IR // WITH_RUNTIME // WITH_COROUTINES diff --git a/compiler/testData/codegen/box/coroutines/suspendFunctionTypeCall/suspendModifier.kt b/compiler/testData/codegen/box/coroutines/suspendFunctionTypeCall/suspendModifier.kt index a01fb6636a3..941476e8be7 100644 --- a/compiler/testData/codegen/box/coroutines/suspendFunctionTypeCall/suspendModifier.kt +++ b/compiler/testData/codegen/box/coroutines/suspendFunctionTypeCall/suspendModifier.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // IGNORE_BACKEND: JVM_IR // WITH_RUNTIME // COMMON_COROUTINES_TEST diff --git a/compiler/testData/codegen/box/diagnostics/functions/tailRecursion/realStringEscape.kt b/compiler/testData/codegen/box/diagnostics/functions/tailRecursion/realStringEscape.kt index fa8d7987f6b..effd859f18a 100644 --- a/compiler/testData/codegen/box/diagnostics/functions/tailRecursion/realStringEscape.kt +++ b/compiler/testData/codegen/box/diagnostics/functions/tailRecursion/realStringEscape.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // DONT_RUN_GENERATED_CODE: JS fun escapeChar(c : Char) : String? = when (c) { diff --git a/compiler/testData/codegen/box/extensionFunctions/simple.kt b/compiler/testData/codegen/box/extensionFunctions/simple.kt index f15de3314fc..101e52661bf 100644 --- a/compiler/testData/codegen/box/extensionFunctions/simple.kt +++ b/compiler/testData/codegen/box/extensionFunctions/simple.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR fun StringBuilder.first() = this.get(0) fun foo() = StringBuilder("foo").first() diff --git a/compiler/testData/codegen/box/intrinsics/stringFromCollection.kt b/compiler/testData/codegen/box/intrinsics/stringFromCollection.kt index 76b1c2d4936..bd15b7bf3f3 100644 --- a/compiler/testData/codegen/box/intrinsics/stringFromCollection.kt +++ b/compiler/testData/codegen/box/intrinsics/stringFromCollection.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR fun box(): String { val list = ArrayList() list.add("0") diff --git a/compiler/testData/codegen/box/primitiveTypes/kt4098.kt b/compiler/testData/codegen/box/primitiveTypes/kt4098.kt index f900a09f6d2..a74f18feeac 100644 --- a/compiler/testData/codegen/box/primitiveTypes/kt4098.kt +++ b/compiler/testData/codegen/box/primitiveTypes/kt4098.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR fun box(): String { val c: Char? = '0' c!!.toInt() diff --git a/compiler/testData/codegen/box/primitiveTypes/kt4210.kt b/compiler/testData/codegen/box/primitiveTypes/kt4210.kt index eede80c9606..4f3b16d0e6e 100644 --- a/compiler/testData/codegen/box/primitiveTypes/kt4210.kt +++ b/compiler/testData/codegen/box/primitiveTypes/kt4210.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR fun box(): String { val s: String? = "abc" val c = s?.get(0)!! - 'b' diff --git a/compiler/testData/codegen/box/primitiveTypes/kt518.kt b/compiler/testData/codegen/box/primitiveTypes/kt518.kt index 066eaf09a57..f1ec08f1c2f 100644 --- a/compiler/testData/codegen/box/primitiveTypes/kt518.kt +++ b/compiler/testData/codegen/box/primitiveTypes/kt518.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR fun foo(i : Int?, a : Any?) { i?.plus(1) diff --git a/compiler/testData/codegen/box/ranges/contains/generated/charSequenceIndices.kt b/compiler/testData/codegen/box/ranges/contains/generated/charSequenceIndices.kt index 6471d6678bc..7f6d4ac8921 100644 --- a/compiler/testData/codegen/box/ranges/contains/generated/charSequenceIndices.kt +++ b/compiler/testData/codegen/box/ranges/contains/generated/charSequenceIndices.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // Auto-generated by GenerateInRangeExpressionTestData. Do not edit! // WITH_RUNTIME diff --git a/compiler/testData/codegen/box/ranges/expression/simpleRangeWithNonConstantEnds.kt b/compiler/testData/codegen/box/ranges/expression/simpleRangeWithNonConstantEnds.kt index 402cf5cb712..347489bab2e 100644 --- a/compiler/testData/codegen/box/ranges/expression/simpleRangeWithNonConstantEnds.kt +++ b/compiler/testData/codegen/box/ranges/expression/simpleRangeWithNonConstantEnds.kt @@ -1,9 +1,6 @@ // TODO: muted automatically, investigate should it be ran for JVM_IR or not // IGNORE_BACKEND: JVM_IR -// TODO: muted automatically, investigate should it be ran for JS_IR or not -// IGNORE_BACKEND: JS_IR - // Auto-generated by org.jetbrains.kotlin.generators.tests.GenerateRangesCodegenTestData. DO NOT EDIT! // WITH_RUNTIME diff --git a/compiler/testData/codegen/box/ranges/forInIndices/forInCharSequenceIndices.kt b/compiler/testData/codegen/box/ranges/forInIndices/forInCharSequenceIndices.kt index 30d22f33a68..1600771fa32 100644 --- a/compiler/testData/codegen/box/ranges/forInIndices/forInCharSequenceIndices.kt +++ b/compiler/testData/codegen/box/ranges/forInIndices/forInCharSequenceIndices.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // WITH_RUNTIME fun test(s: CharSequence): Int { diff --git a/compiler/testData/codegen/box/ranges/forInIndices/kt13241_CharSequence.kt b/compiler/testData/codegen/box/ranges/forInIndices/kt13241_CharSequence.kt index 03d1e1c42ba..a0d45d7698e 100644 --- a/compiler/testData/codegen/box/ranges/forInIndices/kt13241_CharSequence.kt +++ b/compiler/testData/codegen/box/ranges/forInIndices/kt13241_CharSequence.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // WITH_RUNTIME import kotlin.test.assertEquals diff --git a/compiler/testData/codegen/box/ranges/forInReversed/forInReversedCharSequenceIndices.kt b/compiler/testData/codegen/box/ranges/forInReversed/forInReversedCharSequenceIndices.kt index 71e1ff0a7b8..826bb3ffb5d 100644 --- a/compiler/testData/codegen/box/ranges/forInReversed/forInReversedCharSequenceIndices.kt +++ b/compiler/testData/codegen/box/ranges/forInReversed/forInReversedCharSequenceIndices.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // WITH_RUNTIME import kotlin.test.* diff --git a/compiler/testData/codegen/box/ranges/forInStringVarUpdatedInLoopBody.kt b/compiler/testData/codegen/box/ranges/forInStringVarUpdatedInLoopBody.kt index 3d3369924a5..c616a47e41f 100644 --- a/compiler/testData/codegen/box/ranges/forInStringVarUpdatedInLoopBody.kt +++ b/compiler/testData/codegen/box/ranges/forInStringVarUpdatedInLoopBody.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // WITH_RUNTIME fun box(): String { diff --git a/compiler/testData/codegen/box/ranges/literal/simpleRangeWithNonConstantEnds.kt b/compiler/testData/codegen/box/ranges/literal/simpleRangeWithNonConstantEnds.kt index db6ae1bbd0a..a7f86f298f5 100644 --- a/compiler/testData/codegen/box/ranges/literal/simpleRangeWithNonConstantEnds.kt +++ b/compiler/testData/codegen/box/ranges/literal/simpleRangeWithNonConstantEnds.kt @@ -1,9 +1,6 @@ // TODO: muted automatically, investigate should it be ran for JVM_IR or not // IGNORE_BACKEND: JVM_IR -// TODO: muted automatically, investigate should it be ran for JS_IR or not -// IGNORE_BACKEND: JS_IR - // Auto-generated by org.jetbrains.kotlin.generators.tests.GenerateRangesCodegenTestData. DO NOT EDIT! // WITH_RUNTIME diff --git a/compiler/testData/codegen/box/strings/forInString.kt b/compiler/testData/codegen/box/strings/forInString.kt index e33b0c40d14..f5bcbbde7be 100644 --- a/compiler/testData/codegen/box/strings/forInString.kt +++ b/compiler/testData/codegen/box/strings/forInString.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // WITH_RUNTIME fun foo(): Int { diff --git a/compiler/testData/codegen/box/strings/kt3571.kt b/compiler/testData/codegen/box/strings/kt3571.kt index e3cff3b9a7e..960a37656a0 100644 --- a/compiler/testData/codegen/box/strings/kt3571.kt +++ b/compiler/testData/codegen/box/strings/kt3571.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR class Thing(delegate: CharSequence) : CharSequence by delegate fun box(): String { diff --git a/compiler/testData/codegen/box/strings/kt5389_stringBuilderGet.kt b/compiler/testData/codegen/box/strings/kt5389_stringBuilderGet.kt index 968b99728c4..c6547b517a4 100644 --- a/compiler/testData/codegen/box/strings/kt5389_stringBuilderGet.kt +++ b/compiler/testData/codegen/box/strings/kt5389_stringBuilderGet.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR fun box(): String { val sb = StringBuilder("OK") return "${sb.get(0)}${sb[1]}" diff --git a/compiler/testData/codegen/box/strings/kt5956.kt b/compiler/testData/codegen/box/strings/kt5956.kt index ed7706920d2..037ee9ac1dc 100644 --- a/compiler/testData/codegen/box/strings/kt5956.kt +++ b/compiler/testData/codegen/box/strings/kt5956.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // KT-5956 java.lang.AbstractMethodError: test.Thing.subSequence(II)Ljava/lang/CharSequence class Thing(val delegate: CharSequence) : CharSequence { diff --git a/compiler/tests/org/jetbrains/kotlin/generators/tests/GenerateRangesCodegenTestData.java b/compiler/tests/org/jetbrains/kotlin/generators/tests/GenerateRangesCodegenTestData.java index 8c1e8ae073c..92dc36d853f 100644 --- a/compiler/tests/org/jetbrains/kotlin/generators/tests/GenerateRangesCodegenTestData.java +++ b/compiler/tests/org/jetbrains/kotlin/generators/tests/GenerateRangesCodegenTestData.java @@ -122,8 +122,7 @@ public class GenerateRangesCodegenTestData { private static final List IGNORED_FOR_JS_BACKEND = Collections.emptyList(); private static final List IGNORED_FOR_JS_IR_BACKEND = Arrays.asList("inexactDownToMinValue.kt", - "inexactToMaxValue.kt", - "simpleRangeWithNonConstantEnds.kt"); + "inexactToMaxValue.kt"); private static final List IGNORED_FOR_NATIVE_BACKEND = Collections.emptyList(); diff --git a/js/js.translator/testData/box/expression/for/forIteratesOverLiteralRange.kt b/js/js.translator/testData/box/expression/for/forIteratesOverLiteralRange.kt index 113e04523e4..89e5723e1a1 100644 --- a/js/js.translator/testData/box/expression/for/forIteratesOverLiteralRange.kt +++ b/js/js.translator/testData/box/expression/for/forIteratesOverLiteralRange.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // EXPECTED_REACHABLE_NODES: 1230 package foo diff --git a/js/js.translator/testData/box/expression/stringClass/extensionMethods.kt b/js/js.translator/testData/box/expression/stringClass/extensionMethods.kt index 1e910361669..fda17cca13b 100644 --- a/js/js.translator/testData/box/expression/stringClass/extensionMethods.kt +++ b/js/js.translator/testData/box/expression/stringClass/extensionMethods.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // EXPECTED_REACHABLE_NODES: 1250 package foo diff --git a/js/js.translator/testData/box/inlineEvaluationOrder/continueInExtractedDoWhile.kt b/js/js.translator/testData/box/inlineEvaluationOrder/continueInExtractedDoWhile.kt index 7387d0ed924..8a83a0019e2 100644 --- a/js/js.translator/testData/box/inlineEvaluationOrder/continueInExtractedDoWhile.kt +++ b/js/js.translator/testData/box/inlineEvaluationOrder/continueInExtractedDoWhile.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // EXPECTED_REACHABLE_NODES: 1286 package foo diff --git a/js/js.translator/testData/box/inlineEvaluationOrder/whileConditionExtracted.kt b/js/js.translator/testData/box/inlineEvaluationOrder/whileConditionExtracted.kt index 8eb43e67313..aad73d8a960 100644 --- a/js/js.translator/testData/box/inlineEvaluationOrder/whileConditionExtracted.kt +++ b/js/js.translator/testData/box/inlineEvaluationOrder/whileConditionExtracted.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // EXPECTED_REACHABLE_NODES: 1284 // See KT-8005 package foo diff --git a/js/js.translator/testData/box/inlineMultiFile/tryCatch.kt b/js/js.translator/testData/box/inlineMultiFile/tryCatch.kt index 6f1ba1e798b..57470843b52 100644 --- a/js/js.translator/testData/box/inlineMultiFile/tryCatch.kt +++ b/js/js.translator/testData/box/inlineMultiFile/tryCatch.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // EXPECTED_REACHABLE_NODES: 1300 /* * Copy of JVM-backend test diff --git a/js/js.translator/testData/box/inlineMultiFile/tryCatch2.kt b/js/js.translator/testData/box/inlineMultiFile/tryCatch2.kt index ede35e424ce..ef32e8a3606 100644 --- a/js/js.translator/testData/box/inlineMultiFile/tryCatch2.kt +++ b/js/js.translator/testData/box/inlineMultiFile/tryCatch2.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // EXPECTED_REACHABLE_NODES: 1303 /* * Copy of JVM-backend test diff --git a/js/js.translator/testData/box/nameClashes/extensionFunctionAndProperty.kt b/js/js.translator/testData/box/nameClashes/extensionFunctionAndProperty.kt index f64fededab3..b2886e35e01 100644 --- a/js/js.translator/testData/box/nameClashes/extensionFunctionAndProperty.kt +++ b/js/js.translator/testData/box/nameClashes/extensionFunctionAndProperty.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // EXPECTED_REACHABLE_NODES: 1524 package foo diff --git a/js/js.translator/testData/box/nameClashes/localFunctions.kt b/js/js.translator/testData/box/nameClashes/localFunctions.kt index aea0077078c..8baf0a9fc23 100644 --- a/js/js.translator/testData/box/nameClashes/localFunctions.kt +++ b/js/js.translator/testData/box/nameClashes/localFunctions.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // EXPECTED_REACHABLE_NODES: 1288 var log = "" diff --git a/libraries/stdlib/js/irRuntime/charSequence.kt b/libraries/stdlib/js/irRuntime/charSequence.kt new file mode 100644 index 00000000000..ca815d184ff --- /dev/null +++ b/libraries/stdlib/js/irRuntime/charSequence.kt @@ -0,0 +1,38 @@ +/* + * Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license + * that can be found in the license/LICENSE.txt file. + */ + +package kotlin.js + +internal annotation class DoNotIntrinsify + +@PublishedApi +@DoNotIntrinsify +internal fun charSequenceGet(a: CharSequence, index: Int): Char { + return if (a is String) { + Char(a.asDynamic().charCodeAt(index).unsafeCast()) + } else { + a[index] + } +} + +@PublishedApi +@DoNotIntrinsify +internal fun charSequenceLength(a: CharSequence): Int { + return if (a is String) { + a.asDynamic().length.unsafeCast() + } else { + a.length + } +} + +@PublishedApi +@DoNotIntrinsify +internal fun charSequenceSubSequence(a: CharSequence, startIndex: Int, endIndex: Int): CharSequence { + return if (a is String) { + a.asDynamic().substring(startIndex, endIndex).unsafeCast() + } else { + a.subSequence(startIndex, endIndex) + } +}