[JS IR] Generate debug info for JS switch statements
#KT-46276
This commit is contained in:
committed by
Space Team
parent
b2b7958b62
commit
fe0e9db3aa
+3
-2
@@ -10,6 +10,7 @@ import org.jetbrains.kotlin.backend.common.lower.FinallyBlocksLowering
|
||||
import org.jetbrains.kotlin.ir.backend.js.JsStatementOrigins
|
||||
import org.jetbrains.kotlin.backend.common.lower.ReturnableBlockTransformer
|
||||
import org.jetbrains.kotlin.backend.common.lower.coroutines.loweredSuspendFunctionReturnType
|
||||
import org.jetbrains.kotlin.ir.UNDEFINED_OFFSET
|
||||
import org.jetbrains.kotlin.ir.backend.js.JsCommonBackendContext
|
||||
import org.jetbrains.kotlin.ir.backend.js.ir.JsIrBuilder
|
||||
import org.jetbrains.kotlin.ir.builders.*
|
||||
@@ -85,7 +86,7 @@ class JsSuspendFunctionsLowering(ctx: JsCommonBackendContext) : AbstractSuspendF
|
||||
|
||||
val unit = context.irBuiltIns.unitType
|
||||
|
||||
val switch = IrWhenImpl(body.startOffset, body.endOffset, unit, JsStatementOrigins.COROUTINE_SWITCH)
|
||||
val switch = IrWhenImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, unit, JsStatementOrigins.COROUTINE_SWITCH)
|
||||
val stateVar = JsIrBuilder.buildVar(context.irBuiltIns.intType, stateMachineFunction)
|
||||
val switchBlock = IrBlockImpl(switch.startOffset, switch.endOffset, switch.type).apply {
|
||||
statements += stateVar
|
||||
@@ -284,4 +285,4 @@ class JsSuspendFunctionsLowering(ctx: JsCommonBackendContext) : AbstractSuspendF
|
||||
val functionReturnType = scope.scopeOwnerSymbol.assertedCast<IrSimpleFunctionSymbol> { "Expected function symbol" }.owner.returnType
|
||||
+irReturn(generateDelegatedCall(functionReturnType, call))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -179,7 +179,7 @@ class SwitchOptimizer(private val context: JsGenerationContext, private val isEx
|
||||
|
||||
|
||||
fun tryOptimize(irWhen: IrWhen): JsStatement? {
|
||||
return detectSwitch(irWhen)?.let { buildJsSwitch(it) }
|
||||
return detectSwitch(irWhen)?.let { buildJsSwitch(it).withSource(irWhen, context) }
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
+5
-1
@@ -1,4 +1,4 @@
|
||||
// IGNORE_BACKEND: JS_IR
|
||||
|
||||
// FILE: test.kt
|
||||
fun box(): Int {
|
||||
if (
|
||||
@@ -25,3 +25,7 @@ inline fun getB(): Int {
|
||||
// test.kt:8 box
|
||||
|
||||
// EXPECTATIONS JS_IR
|
||||
// test.kt:14 box
|
||||
// test.kt:5 box
|
||||
// test.kt:11 getA
|
||||
// test.kt:14 box
|
||||
|
||||
+13
-1
@@ -114,31 +114,43 @@ fun box() {
|
||||
|
||||
// EXPECTATIONS JS_IR
|
||||
// test.kt:29 box
|
||||
// test.kt:4 stringSwitch
|
||||
// test.kt:5 stringSwitch
|
||||
// test.kt:11 stringSwitch
|
||||
// test.kt:11 stringSwitch
|
||||
// test.kt:12 stringSwitch
|
||||
// test.kt:19 stringSwitch
|
||||
// test.kt:18 stringSwitch
|
||||
// test.kt:21 stringSwitch
|
||||
// test.kt:26 stringSwitch
|
||||
// test.kt:30 box
|
||||
// test.kt:4 stringSwitch
|
||||
// test.kt:6 stringSwitch
|
||||
// test.kt:11 stringSwitch
|
||||
// test.kt:11 stringSwitch
|
||||
// test.kt:13 stringSwitch
|
||||
// test.kt:19 stringSwitch
|
||||
// test.kt:18 stringSwitch
|
||||
// test.kt:22 stringSwitch
|
||||
// test.kt:26 stringSwitch
|
||||
// test.kt:31 box
|
||||
// test.kt:4 stringSwitch
|
||||
// test.kt:7 stringSwitch
|
||||
// test.kt:11 stringSwitch
|
||||
// test.kt:11 stringSwitch
|
||||
// test.kt:14 stringSwitch
|
||||
// test.kt:19 stringSwitch
|
||||
// test.kt:18 stringSwitch
|
||||
// test.kt:23 stringSwitch
|
||||
// test.kt:26 stringSwitch
|
||||
// test.kt:32 box
|
||||
// test.kt:4 stringSwitch
|
||||
// test.kt:8 stringSwitch
|
||||
// test.kt:11 stringSwitch
|
||||
// test.kt:11 stringSwitch
|
||||
// test.kt:15 stringSwitch
|
||||
// test.kt:19 stringSwitch
|
||||
// test.kt:18 stringSwitch
|
||||
// test.kt:24 stringSwitch
|
||||
// test.kt:26 stringSwitch
|
||||
// test.kt:33 box
|
||||
// test.kt:33 box
|
||||
|
||||
+10
-1
@@ -97,24 +97,33 @@ fun box() {
|
||||
|
||||
// EXPECTATIONS JS_IR
|
||||
// test.kt:26 box
|
||||
// test.kt:4 stringSwitch
|
||||
// test.kt:5 stringSwitch
|
||||
// test.kt:10 stringSwitch
|
||||
// test.kt:10 stringSwitch
|
||||
// test.kt:11 stringSwitch
|
||||
// test.kt:17 stringSwitch
|
||||
// test.kt:16 stringSwitch
|
||||
// test.kt:19 stringSwitch
|
||||
// test.kt:23 stringSwitch
|
||||
// test.kt:27 box
|
||||
// test.kt:4 stringSwitch
|
||||
// test.kt:6 stringSwitch
|
||||
// test.kt:10 stringSwitch
|
||||
// test.kt:10 stringSwitch
|
||||
// test.kt:12 stringSwitch
|
||||
// test.kt:17 stringSwitch
|
||||
// test.kt:16 stringSwitch
|
||||
// test.kt:20 stringSwitch
|
||||
// test.kt:23 stringSwitch
|
||||
// test.kt:28 box
|
||||
// test.kt:4 stringSwitch
|
||||
// test.kt:7 stringSwitch
|
||||
// test.kt:10 stringSwitch
|
||||
// test.kt:10 stringSwitch
|
||||
// test.kt:13 stringSwitch
|
||||
// test.kt:17 stringSwitch
|
||||
// test.kt:16 stringSwitch
|
||||
// test.kt:21 stringSwitch
|
||||
// test.kt:23 stringSwitch
|
||||
// test.kt:29 box
|
||||
// test.kt:29 box
|
||||
|
||||
+15
-1
@@ -121,23 +121,37 @@ fun box() {
|
||||
|
||||
// EXPECTATIONS JS_IR
|
||||
// test.kt:18 box
|
||||
// test.kt:4 foo
|
||||
// test.kt:5 foo
|
||||
// test.kt:4 foo
|
||||
// test.kt:6 foo
|
||||
// test.kt:4 foo
|
||||
// test.kt:10 foo
|
||||
// test.kt:13 foo
|
||||
// test.kt:10 foo
|
||||
// test.kt:15 foo
|
||||
// test.kt:10 foo
|
||||
// test.kt:12 foo
|
||||
// test.kt:4 foo
|
||||
// test.kt:10 foo
|
||||
// test.kt:13 foo
|
||||
// test.kt:10 foo
|
||||
// test.kt:15 foo
|
||||
// test.kt:10 foo
|
||||
// test.kt:15 foo
|
||||
// test.kt:10 foo
|
||||
// test.kt:11 foo
|
||||
// test.kt:4 foo
|
||||
// test.kt:6 foo
|
||||
// test.kt:4 foo
|
||||
// test.kt:10 foo
|
||||
// test.kt:13 foo
|
||||
// test.kt:10 foo
|
||||
// test.kt:15 foo
|
||||
// test.kt:10 foo
|
||||
// test.kt:12 foo
|
||||
// test.kt:4 foo
|
||||
// test.kt:10 foo
|
||||
// test.kt:13 foo
|
||||
// test.kt:10 foo
|
||||
// test.kt:15 foo
|
||||
@@ -145,4 +159,4 @@ fun box() {
|
||||
// test.kt:15 foo
|
||||
// test.kt:10 foo
|
||||
// test.kt:15 foo
|
||||
// test.kt:19 box
|
||||
// test.kt:19 box
|
||||
|
||||
@@ -50,17 +50,20 @@ fun box() {
|
||||
|
||||
// EXPECTATIONS JS_IR
|
||||
// test.kt:16 box
|
||||
// test.kt:5 foo
|
||||
// test.kt:6 foo
|
||||
// test.kt:10 foo
|
||||
// test.kt:11 foo
|
||||
// test.kt:13 foo
|
||||
// test.kt:17 box
|
||||
// test.kt:5 foo
|
||||
// test.kt:7 foo
|
||||
// test.kt:10 foo
|
||||
// test.kt:11 foo
|
||||
// test.kt:13 foo
|
||||
// test.kt:18 box
|
||||
// test.kt:5 foo
|
||||
// test.kt:8 foo
|
||||
// test.kt:10 foo
|
||||
// test.kt:13 foo
|
||||
// test.kt:19 box
|
||||
// test.kt:19 box
|
||||
|
||||
+2
-1
@@ -24,4 +24,5 @@ fun box() {
|
||||
|
||||
// EXPECTATIONS JS_IR
|
||||
// test.kt:4 box
|
||||
// test.kt:12 box
|
||||
// test.kt:4 box
|
||||
// test.kt:12 box
|
||||
|
||||
+7
-1
@@ -84,12 +84,18 @@ fun box() {
|
||||
|
||||
// EXPECTATIONS JS_IR
|
||||
// test.kt:26 box
|
||||
// test.kt:4 foo
|
||||
// test.kt:13 foo
|
||||
// test.kt:15 foo
|
||||
// test.kt:22 foo
|
||||
// test.kt:27 box
|
||||
// test.kt:4 foo
|
||||
// test.kt:13 foo
|
||||
// test.kt:17 foo
|
||||
// test.kt:22 foo
|
||||
// test.kt:28 box
|
||||
// test.kt:4 foo
|
||||
// test.kt:13 foo
|
||||
// test.kt:19 foo
|
||||
// test.kt:22 foo
|
||||
// test.kt:29 box
|
||||
// test.kt:29 box
|
||||
|
||||
@@ -58,17 +58,23 @@ fun box() {
|
||||
// EXPECTATIONS JS_IR
|
||||
// test.kt:26 box
|
||||
// test.kt:4 foo
|
||||
// test.kt:4 foo
|
||||
// test.kt:13 foo
|
||||
// test.kt:13 foo
|
||||
// test.kt:15 foo
|
||||
// test.kt:22 foo
|
||||
// test.kt:27 box
|
||||
// test.kt:4 foo
|
||||
// test.kt:4 foo
|
||||
// test.kt:13 foo
|
||||
// test.kt:13 foo
|
||||
// test.kt:17 foo
|
||||
// test.kt:22 foo
|
||||
// test.kt:28 box
|
||||
// test.kt:4 foo
|
||||
// test.kt:4 foo
|
||||
// test.kt:13 foo
|
||||
// test.kt:13 foo
|
||||
// test.kt:19 foo
|
||||
// test.kt:22 foo
|
||||
// test.kt:29 box
|
||||
// test.kt:29 box
|
||||
|
||||
+2
-1
@@ -26,4 +26,5 @@ fun box() {
|
||||
// EXPECTATIONS JS_IR
|
||||
// test.kt:4 box
|
||||
// test.kt:5 box
|
||||
// test.kt:16 box
|
||||
// test.kt:5 box
|
||||
// test.kt:16 box
|
||||
|
||||
+15
-1
@@ -73,17 +73,24 @@ fun box() {
|
||||
// EXPECTATIONS JS_IR
|
||||
// test.kt:18 box
|
||||
// test.kt:4 foo
|
||||
// test.kt:4 foo
|
||||
// test.kt:5 foo
|
||||
// test.kt:4 foo
|
||||
// test.kt:4 foo
|
||||
// test.kt:6 foo
|
||||
// test.kt:4 foo
|
||||
// test.kt:4 foo
|
||||
// test.kt:10 foo
|
||||
// test.kt:10 foo
|
||||
// test.kt:13 foo
|
||||
// test.kt:10 foo
|
||||
// test.kt:15 foo
|
||||
// test.kt:10 foo
|
||||
// test.kt:10 foo
|
||||
// test.kt:12 foo
|
||||
// test.kt:4 foo
|
||||
// test.kt:4 foo
|
||||
// test.kt:10 foo
|
||||
// test.kt:10 foo
|
||||
// test.kt:13 foo
|
||||
// test.kt:10 foo
|
||||
@@ -91,17 +98,24 @@ fun box() {
|
||||
// test.kt:10 foo
|
||||
// test.kt:15 foo
|
||||
// test.kt:10 foo
|
||||
// test.kt:10 foo
|
||||
// test.kt:11 foo
|
||||
// test.kt:4 foo
|
||||
// test.kt:4 foo
|
||||
// test.kt:6 foo
|
||||
// test.kt:4 foo
|
||||
// test.kt:4 foo
|
||||
// test.kt:10 foo
|
||||
// test.kt:10 foo
|
||||
// test.kt:13 foo
|
||||
// test.kt:10 foo
|
||||
// test.kt:15 foo
|
||||
// test.kt:10 foo
|
||||
// test.kt:10 foo
|
||||
// test.kt:12 foo
|
||||
// test.kt:4 foo
|
||||
// test.kt:4 foo
|
||||
// test.kt:10 foo
|
||||
// test.kt:10 foo
|
||||
// test.kt:13 foo
|
||||
// test.kt:10 foo
|
||||
@@ -110,4 +124,4 @@ fun box() {
|
||||
// test.kt:15 foo
|
||||
// test.kt:10 foo
|
||||
// test.kt:15 foo
|
||||
// test.kt:19 box
|
||||
// test.kt:19 box
|
||||
|
||||
+15
-1
@@ -123,36 +123,50 @@ fun box() {
|
||||
// EXPECTATIONS JS_IR
|
||||
// test.kt:22 box
|
||||
// test.kt:5 foo
|
||||
// test.kt:4 foo
|
||||
// test.kt:7 foo
|
||||
// test.kt:5 foo
|
||||
// test.kt:4 foo
|
||||
// test.kt:8 foo
|
||||
// test.kt:5 foo
|
||||
// test.kt:4 foo
|
||||
// test.kt:13 foo
|
||||
// test.kt:12 foo
|
||||
// test.kt:17 foo
|
||||
// test.kt:12 foo
|
||||
// test.kt:19 foo
|
||||
// test.kt:13 foo
|
||||
// test.kt:12 foo
|
||||
// test.kt:16 foo
|
||||
// test.kt:5 foo
|
||||
// test.kt:4 foo
|
||||
// test.kt:13 foo
|
||||
// test.kt:12 foo
|
||||
// test.kt:17 foo
|
||||
// test.kt:12 foo
|
||||
// test.kt:19 foo
|
||||
// test.kt:12 foo
|
||||
// test.kt:19 foo
|
||||
// test.kt:13 foo
|
||||
// test.kt:12 foo
|
||||
// test.kt:15 foo
|
||||
// test.kt:5 foo
|
||||
// test.kt:4 foo
|
||||
// test.kt:8 foo
|
||||
// test.kt:5 foo
|
||||
// test.kt:4 foo
|
||||
// test.kt:13 foo
|
||||
// test.kt:12 foo
|
||||
// test.kt:17 foo
|
||||
// test.kt:12 foo
|
||||
// test.kt:19 foo
|
||||
// test.kt:13 foo
|
||||
// test.kt:12 foo
|
||||
// test.kt:16 foo
|
||||
// test.kt:5 foo
|
||||
// test.kt:4 foo
|
||||
// test.kt:13 foo
|
||||
// test.kt:12 foo
|
||||
// test.kt:17 foo
|
||||
// test.kt:12 foo
|
||||
// test.kt:19 foo
|
||||
@@ -160,4 +174,4 @@ fun box() {
|
||||
// test.kt:19 foo
|
||||
// test.kt:12 foo
|
||||
// test.kt:19 foo
|
||||
// test.kt:23 box
|
||||
// test.kt:23 box
|
||||
|
||||
Reference in New Issue
Block a user