[IR BE] Delegate coroutine naming strategy to platform part
This commit is contained in:
+2
-4
@@ -33,7 +33,7 @@ abstract class AbstractSuspendFunctionsLowering<C : CommonBackendContext>(val co
|
||||
|
||||
protected abstract val stateMachineMethodName: Name
|
||||
protected abstract fun getCoroutineBaseClass(function: IrFunction): IrClassSymbol
|
||||
|
||||
protected abstract fun nameForCoroutineClass(function: IrFunction): Name
|
||||
|
||||
protected abstract fun buildStateMachine(
|
||||
originalBody: IrBody, stateMachineFunction: IrFunction,
|
||||
@@ -258,8 +258,6 @@ abstract class AbstractSuspendFunctionsLowering<C : CommonBackendContext>(val co
|
||||
val stateMachineFunction: IrFunction
|
||||
)
|
||||
|
||||
private var coroutineId = 0
|
||||
|
||||
private inner class CoroutineBuilder(val irFunction: IrFunction, val functionReference: IrFunctionReference?) {
|
||||
|
||||
private val startOffset = irFunction.startOffset
|
||||
@@ -273,7 +271,7 @@ abstract class AbstractSuspendFunctionsLowering<C : CommonBackendContext>(val co
|
||||
startOffset, endOffset,
|
||||
DECLARATION_ORIGIN_COROUTINE_IMPL,
|
||||
IrClassSymbolImpl(d),
|
||||
"${irFunction.name}COROUTINE\$${coroutineId++}".synthesizedName,
|
||||
nameForCoroutineClass(irFunction),
|
||||
ClassKind.CLASS,
|
||||
irFunction.visibility,
|
||||
Modality.FINAL,
|
||||
|
||||
+4
@@ -5,6 +5,7 @@
|
||||
|
||||
package org.jetbrains.kotlin.ir.backend.js.lower.coroutines
|
||||
|
||||
import org.jetbrains.kotlin.backend.common.descriptors.synthesizedName
|
||||
import org.jetbrains.kotlin.backend.common.ir.isSuspend
|
||||
import org.jetbrains.kotlin.backend.common.lower.AbstractSuspendFunctionsLowering
|
||||
import org.jetbrains.kotlin.ir.IrElement
|
||||
@@ -34,10 +35,13 @@ class JsSuspendFunctionsLowering(ctx: JsIrBackendContext) : AbstractSuspendFunct
|
||||
private val coroutineImplResultSymbolSetter = ctx.coroutineImplResultSymbolSetter
|
||||
|
||||
private var exceptionTrapId = -1
|
||||
private var coroutineId = 0
|
||||
|
||||
override val stateMachineMethodName = Name.identifier("doResume")
|
||||
override fun getCoroutineBaseClass(function: IrFunction) = context.ir.symbols.coroutineImpl
|
||||
|
||||
override fun nameForCoroutineClass(function: IrFunction) = "${function.name}COROUTINE\$${coroutineId++}".synthesizedName
|
||||
|
||||
override fun buildStateMachine(
|
||||
originalBody: IrBody,
|
||||
stateMachineFunction: IrFunction,
|
||||
|
||||
Reference in New Issue
Block a user