JVM IR: take IrFunction in IrTypeMapper.mapFunctionName/mapReturnType
This commit is contained in:
+7
-4
@@ -5,7 +5,6 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.backend.jvm.codegen
|
package org.jetbrains.kotlin.backend.jvm.codegen
|
||||||
|
|
||||||
import org.jetbrains.kotlin.backend.common.ir.returnType
|
|
||||||
import org.jetbrains.kotlin.backend.common.lower.BOUND_RECEIVER_PARAMETER
|
import org.jetbrains.kotlin.backend.common.lower.BOUND_RECEIVER_PARAMETER
|
||||||
import org.jetbrains.kotlin.backend.jvm.JvmLoweredDeclarationOrigin
|
import org.jetbrains.kotlin.backend.jvm.JvmLoweredDeclarationOrigin
|
||||||
import org.jetbrains.kotlin.backend.jvm.intrinsics.IrIntrinsicMethods
|
import org.jetbrains.kotlin.backend.jvm.intrinsics.IrIntrinsicMethods
|
||||||
@@ -659,7 +658,11 @@ class ExpressionCodegen(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun visitReturn(expression: IrReturn, data: BlockInfo): PromisedValue {
|
override fun visitReturn(expression: IrReturn, data: BlockInfo): PromisedValue {
|
||||||
val owner = expression.returnTargetSymbol.owner
|
val returnTarget = expression.returnTargetSymbol.owner
|
||||||
|
val owner =
|
||||||
|
returnTarget as? IrFunction
|
||||||
|
?: (returnTarget as? IrReturnableBlock)?.inlineFunctionSymbol?.owner
|
||||||
|
?: error("Unsupported IrReturnTarget: $returnTarget")
|
||||||
//TODO: should be owner != irFunction
|
//TODO: should be owner != irFunction
|
||||||
val isNonLocalReturn =
|
val isNonLocalReturn =
|
||||||
typeMapper.mapFunctionName(owner, OwnerKind.IMPLEMENTATION) != typeMapper.mapFunctionName(irFunction, OwnerKind.IMPLEMENTATION)
|
typeMapper.mapFunctionName(owner, OwnerKind.IMPLEMENTATION) != typeMapper.mapFunctionName(irFunction, OwnerKind.IMPLEMENTATION)
|
||||||
@@ -675,7 +678,7 @@ class ExpressionCodegen(
|
|||||||
val target = data.findBlock<ReturnableBlockInfo> { it.returnSymbol == expression.returnTargetSymbol }
|
val target = data.findBlock<ReturnableBlockInfo> { it.returnSymbol == expression.returnTargetSymbol }
|
||||||
val returnType = typeMapper.mapReturnType(owner)
|
val returnType = typeMapper.mapReturnType(owner)
|
||||||
val afterReturnLabel = Label()
|
val afterReturnLabel = Label()
|
||||||
expression.value.accept(this, data).coerce(returnType, owner.returnType(context)).materialize()
|
expression.value.accept(this, data).coerce(returnType, owner.returnType).materialize()
|
||||||
generateFinallyBlocksIfNeeded(returnType, afterReturnLabel, data, target)
|
generateFinallyBlocksIfNeeded(returnType, afterReturnLabel, data, target)
|
||||||
expression.markLineNumber(startOffset = true)
|
expression.markLineNumber(startOffset = true)
|
||||||
if (target != null) {
|
if (target != null) {
|
||||||
@@ -683,7 +686,7 @@ class ExpressionCodegen(
|
|||||||
mv.fixStackAndJump(target.returnLabel)
|
mv.fixStackAndJump(target.returnLabel)
|
||||||
} else {
|
} else {
|
||||||
if (isNonLocalReturn) {
|
if (isNonLocalReturn) {
|
||||||
generateGlobalReturnFlag(mv, (owner as IrFunction).name.asString())
|
generateGlobalReturnFlag(mv, owner.name.asString())
|
||||||
}
|
}
|
||||||
mv.areturn(returnType)
|
mv.areturn(returnType)
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-4
@@ -51,14 +51,14 @@ class IrTypeMapper(private val context: JvmBackendContext) {
|
|||||||
fun mapFieldSignature(irField: IrField) =
|
fun mapFieldSignature(irField: IrField) =
|
||||||
kotlinTypeMapper.mapFieldSignature(irField.type.toKotlinType(), irField.descriptor)
|
kotlinTypeMapper.mapFieldSignature(irField.type.toKotlinType(), irField.descriptor)
|
||||||
|
|
||||||
fun mapFunctionName(irReturnTarget: IrReturnTarget, ownerKind: OwnerKind): String =
|
fun mapFunctionName(irFunction: IrFunction, ownerKind: OwnerKind): String =
|
||||||
kotlinTypeMapper.mapFunctionName(irReturnTarget.descriptor, ownerKind)
|
kotlinTypeMapper.mapFunctionName(irFunction.descriptor, ownerKind)
|
||||||
|
|
||||||
fun mapImplementationOwner(irDeclaration: IrDeclaration): Type =
|
fun mapImplementationOwner(irDeclaration: IrDeclaration): Type =
|
||||||
kotlinTypeMapper.mapImplementationOwner(irDeclaration.descriptor)
|
kotlinTypeMapper.mapImplementationOwner(irDeclaration.descriptor)
|
||||||
|
|
||||||
fun mapReturnType(irReturnTarget: IrReturnTarget): Type =
|
fun mapReturnType(irFunction: IrFunction): Type =
|
||||||
kotlinTypeMapper.mapReturnType(irReturnTarget.descriptor)
|
kotlinTypeMapper.mapReturnType(irFunction.descriptor)
|
||||||
|
|
||||||
fun mapSignatureSkipGeneric(f: IrFunction, kind: OwnerKind = OwnerKind.IMPLEMENTATION): JvmMethodSignature =
|
fun mapSignatureSkipGeneric(f: IrFunction, kind: OwnerKind = OwnerKind.IMPLEMENTATION): JvmMethodSignature =
|
||||||
kotlinTypeMapper.mapSignatureSkipGeneric(f.descriptor, kind)
|
kotlinTypeMapper.mapSignatureSkipGeneric(f.descriptor, kind)
|
||||||
|
|||||||
Reference in New Issue
Block a user