Support IR API changes
(cherry picked from commit bcd76103c627cca0b654d295c0e0fbc1542caf41)
This commit is contained in:
committed by
Vasily Levchenko
parent
8bcee1e632
commit
585f4ae9ee
+2
-2
@@ -76,7 +76,7 @@ internal val Context.getBoxFunction: (IrClass) -> IrSimpleFunction by Context.la
|
|||||||
isFakeOverride = false,
|
isFakeOverride = false,
|
||||||
isOperator = false
|
isOperator = false
|
||||||
).also { function ->
|
).also { function ->
|
||||||
function.valueParameters.add(WrappedValueParameterDescriptor().let {
|
function.valueParameters = listOf(WrappedValueParameterDescriptor().let {
|
||||||
IrValueParameterImpl(
|
IrValueParameterImpl(
|
||||||
startOffset, endOffset,
|
startOffset, endOffset,
|
||||||
IrDeclarationOrigin.DEFINED,
|
IrDeclarationOrigin.DEFINED,
|
||||||
@@ -130,7 +130,7 @@ internal val Context.getUnboxFunction: (IrClass) -> IrSimpleFunction by Context.
|
|||||||
isFakeOverride = false,
|
isFakeOverride = false,
|
||||||
isOperator = false
|
isOperator = false
|
||||||
).also { function ->
|
).also { function ->
|
||||||
function.valueParameters.add(WrappedValueParameterDescriptor().let {
|
function.valueParameters = listOf(WrappedValueParameterDescriptor().let {
|
||||||
IrValueParameterImpl(
|
IrValueParameterImpl(
|
||||||
startOffset, endOffset,
|
startOffset, endOffset,
|
||||||
IrDeclarationOrigin.DEFINED,
|
IrDeclarationOrigin.DEFINED,
|
||||||
|
|||||||
+3
-3
@@ -126,7 +126,7 @@ internal class BuiltInFictitiousFunctionIrClassFactory(
|
|||||||
builtClassesMap.getOrPut(descriptor) {
|
builtClassesMap.getOrPut(descriptor) {
|
||||||
createClass(descriptor).apply {
|
createClass(descriptor).apply {
|
||||||
val functionClass = this
|
val functionClass = this
|
||||||
descriptor.declaredTypeParameters.mapTo(typeParameters) { typeParameterDescriptor ->
|
typeParameters += descriptor.declaredTypeParameters.map { typeParameterDescriptor ->
|
||||||
createTypeParameter(typeParameterDescriptor).also {
|
createTypeParameter(typeParameterDescriptor).also {
|
||||||
it.parent = this
|
it.parent = this
|
||||||
it.superTypes += irBuiltIns.anyNType
|
it.superTypes += irBuiltIns.anyNType
|
||||||
@@ -134,7 +134,7 @@ internal class BuiltInFictitiousFunctionIrClassFactory(
|
|||||||
}
|
}
|
||||||
|
|
||||||
val descriptorToIrParametersMap = typeParameters.map { it.descriptor to it }.toMap()
|
val descriptorToIrParametersMap = typeParameters.map { it.descriptor to it }.toMap()
|
||||||
descriptor.typeConstructor.supertypes.mapTo(superTypes) { superType ->
|
superTypes += descriptor.typeConstructor.supertypes.map { superType ->
|
||||||
val arguments = superType.arguments.map { argument ->
|
val arguments = superType.arguments.map { argument ->
|
||||||
val argumentClassifierDescriptor = argument.type.constructor.declarationDescriptor
|
val argumentClassifierDescriptor = argument.type.constructor.declarationDescriptor
|
||||||
val argumentClassifierSymbol = argumentClassifierDescriptor?.let { descriptorToIrParametersMap[it] }
|
val argumentClassifierSymbol = argumentClassifierDescriptor?.let { descriptorToIrParametersMap[it] }
|
||||||
@@ -165,7 +165,7 @@ internal class BuiltInFictitiousFunctionIrClassFactory(
|
|||||||
typeParameters.last().defaultType
|
typeParameters.last().defaultType
|
||||||
).apply {
|
).apply {
|
||||||
parent = functionClass
|
parent = functionClass
|
||||||
invokeFunctionDescriptor.valueParameters.mapTo(valueParameters) {
|
valueParameters += invokeFunctionDescriptor.valueParameters.map {
|
||||||
IrValueParameterImpl(
|
IrValueParameterImpl(
|
||||||
SYNTHETIC_OFFSET, SYNTHETIC_OFFSET,
|
SYNTHETIC_OFFSET, SYNTHETIC_OFFSET,
|
||||||
invokeFunctionOrigin,
|
invokeFunctionOrigin,
|
||||||
|
|||||||
+2
-2
@@ -170,9 +170,9 @@ internal class SpecialDeclarationsFactory(val context: Context) : KotlinMangler
|
|||||||
|
|
||||||
dispatchReceiverParameter = dispatchReceiver?.copyTo(this)
|
dispatchReceiverParameter = dispatchReceiver?.copyTo(this)
|
||||||
extensionReceiverParameter = extensionReceiver?.copyTo(this)
|
extensionReceiverParameter = extensionReceiver?.copyTo(this)
|
||||||
function.valueParameters.mapTo(valueParameters) { it.copyTo(this, type = valueParameterTypes[it.index]) }
|
valueParameters += function.valueParameters.map { it.copyTo(this, type = valueParameterTypes[it.index]) }
|
||||||
|
|
||||||
function.typeParameters.mapIndexedTo(typeParameters) { index, parameter ->
|
typeParameters += function.typeParameters.mapIndexed { index, parameter ->
|
||||||
WrappedTypeParameterDescriptor().let {
|
WrappedTypeParameterDescriptor().let {
|
||||||
IrTypeParameterImpl(
|
IrTypeParameterImpl(
|
||||||
startOffset, endOffset,
|
startOffset, endOffset,
|
||||||
|
|||||||
+1
-1
@@ -44,7 +44,7 @@ internal fun makeEntryPoint(context: Context): IrFunction {
|
|||||||
isFakeOverride = false,
|
isFakeOverride = false,
|
||||||
isOperator = false
|
isOperator = false
|
||||||
).also { function ->
|
).also { function ->
|
||||||
function.valueParameters.add(WrappedValueParameterDescriptor().let {
|
function.valueParameters = listOf(WrappedValueParameterDescriptor().let {
|
||||||
IrValueParameterImpl(
|
IrValueParameterImpl(
|
||||||
actualMain.startOffset, actualMain.startOffset,
|
actualMain.startOffset, actualMain.startOffset,
|
||||||
IrDeclarationOrigin.DEFINED,
|
IrDeclarationOrigin.DEFINED,
|
||||||
|
|||||||
+1
-1
@@ -1290,7 +1290,7 @@ private class ObjCBlockPointerValuePassing(
|
|||||||
irClass.addChild(invokeMethod)
|
irClass.addChild(invokeMethod)
|
||||||
invokeMethod.createDispatchReceiverParameter()
|
invokeMethod.createDispatchReceiverParameter()
|
||||||
|
|
||||||
(0 until parameterCount).mapTo(invokeMethod.valueParameters) { index ->
|
invokeMethod.valueParameters += (0 until parameterCount).map { index ->
|
||||||
val parameterDescriptor = WrappedValueParameterDescriptor()
|
val parameterDescriptor = WrappedValueParameterDescriptor()
|
||||||
val parameter = IrValueParameterImpl(
|
val parameter = IrValueParameterImpl(
|
||||||
startOffset, endOffset,
|
startOffset, endOffset,
|
||||||
|
|||||||
+2
-1
@@ -97,8 +97,9 @@ class IrFileImpl(entry: SourceManager.FileEntry) : IrFile {
|
|||||||
|
|
||||||
override val metadata: MetadataSource.File?
|
override val metadata: MetadataSource.File?
|
||||||
get() = TODO("not implemented")
|
get() = TODO("not implemented")
|
||||||
override val annotations: MutableList<IrConstructorCall>
|
override var annotations: List<IrConstructorCall>
|
||||||
get() = TODO("not implemented")
|
get() = TODO("not implemented")
|
||||||
|
set(_) = TODO("not implemented")
|
||||||
override val fqName: FqName
|
override val fqName: FqName
|
||||||
get() = TODO("not implemented")
|
get() = TODO("not implemented")
|
||||||
override val symbol: IrFileSymbol
|
override val symbol: IrFileSymbol
|
||||||
|
|||||||
+1
-1
@@ -53,7 +53,7 @@ internal interface DescriptorToIrTranslationMixin {
|
|||||||
descriptor = descriptor
|
descriptor = descriptor
|
||||||
).also { irClass ->
|
).also { irClass ->
|
||||||
symbolTable.withScope(descriptor) {
|
symbolTable.withScope(descriptor) {
|
||||||
descriptor.typeConstructor.supertypes.mapTo(irClass.superTypes) {
|
irClass.superTypes += descriptor.typeConstructor.supertypes.map {
|
||||||
it.toIrType()
|
it.toIrType()
|
||||||
}
|
}
|
||||||
irClass.generateAnnotations()
|
irClass.generateAnnotations()
|
||||||
|
|||||||
+3
-2
@@ -17,6 +17,7 @@ import org.jetbrains.kotlin.ir.declarations.*
|
|||||||
import org.jetbrains.kotlin.ir.descriptors.IrBuiltIns
|
import org.jetbrains.kotlin.ir.descriptors.IrBuiltIns
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrExpression
|
import org.jetbrains.kotlin.ir.expressions.IrExpression
|
||||||
import org.jetbrains.kotlin.ir.expressions.impl.IrEnumConstructorCallImpl
|
import org.jetbrains.kotlin.ir.expressions.impl.IrEnumConstructorCallImpl
|
||||||
|
import org.jetbrains.kotlin.ir.expressions.impl.IrExpressionBodyImpl
|
||||||
import org.jetbrains.kotlin.ir.util.*
|
import org.jetbrains.kotlin.ir.util.*
|
||||||
import org.jetbrains.kotlin.name.FqName
|
import org.jetbrains.kotlin.name.FqName
|
||||||
import org.jetbrains.kotlin.name.Name
|
import org.jetbrains.kotlin.name.Name
|
||||||
@@ -119,14 +120,14 @@ internal class CEnumClassGenerator(
|
|||||||
SYNTHETIC_OFFSET, SYNTHETIC_OFFSET,
|
SYNTHETIC_OFFSET, SYNTHETIC_OFFSET,
|
||||||
IrDeclarationOrigin.IR_EXTERNAL_DECLARATION_STUB, entryDescriptor
|
IrDeclarationOrigin.IR_EXTERNAL_DECLARATION_STUB, entryDescriptor
|
||||||
).also { enumEntry ->
|
).also { enumEntry ->
|
||||||
enumEntry.initializerExpression = IrEnumConstructorCallImpl(
|
enumEntry.initializerExpression = IrExpressionBodyImpl(IrEnumConstructorCallImpl(
|
||||||
SYNTHETIC_OFFSET, SYNTHETIC_OFFSET,
|
SYNTHETIC_OFFSET, SYNTHETIC_OFFSET,
|
||||||
type = irBuiltIns.unitType,
|
type = irBuiltIns.unitType,
|
||||||
symbol = symbolTable.referenceConstructor(enumDescriptor.unsubstitutedPrimaryConstructor!!),
|
symbol = symbolTable.referenceConstructor(enumDescriptor.unsubstitutedPrimaryConstructor!!),
|
||||||
typeArgumentsCount = 0 // enums can't be generic
|
typeArgumentsCount = 0 // enums can't be generic
|
||||||
).also {
|
).also {
|
||||||
it.putValueArgument(0, extractEnumEntryValue(entryDescriptor))
|
it.putValueArgument(0, extractEnumEntryValue(entryDescriptor))
|
||||||
}
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -509,6 +509,6 @@ private val Context.getLoweredInlineClassConstructor: (IrConstructor) -> IrSimpl
|
|||||||
).apply {
|
).apply {
|
||||||
descriptor.bind(this)
|
descriptor.bind(this)
|
||||||
parent = irConstructor.parent
|
parent = irConstructor.parent
|
||||||
irConstructor.valueParameters.mapTo(valueParameters) { it.copyTo(this) }
|
valueParameters += irConstructor.valueParameters.map { it.copyTo(this) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+2
-2
@@ -268,7 +268,7 @@ internal class CallableReferenceLowering(val context: Context): FileLoweringPass
|
|||||||
parent = functionReferenceClass
|
parent = functionReferenceClass
|
||||||
functionReferenceClass.declarations += this
|
functionReferenceClass.declarations += this
|
||||||
|
|
||||||
boundFunctionParameters.mapIndexedTo(valueParameters) { index, parameter ->
|
valueParameters += boundFunctionParameters.mapIndexed { index, parameter ->
|
||||||
parameter.copyTo(this, DECLARATION_ORIGIN_FUNCTION_REFERENCE_IMPL, index,
|
parameter.copyTo(this, DECLARATION_ORIGIN_FUNCTION_REFERENCE_IMPL, index,
|
||||||
type = parameter.type.substitute(typeArgumentsMap))
|
type = parameter.type.substitute(typeArgumentsMap))
|
||||||
}
|
}
|
||||||
@@ -328,7 +328,7 @@ internal class CallableReferenceLowering(val context: Context): FileLoweringPass
|
|||||||
|
|
||||||
this.createDispatchReceiverParameter()
|
this.createDispatchReceiverParameter()
|
||||||
|
|
||||||
superFunction.valueParameters.mapIndexedTo(valueParameters) { index, parameter ->
|
valueParameters += superFunction.valueParameters.mapIndexed { index, parameter ->
|
||||||
parameter.copyTo(function, DECLARATION_ORIGIN_FUNCTION_REFERENCE_IMPL, index,
|
parameter.copyTo(function, DECLARATION_ORIGIN_FUNCTION_REFERENCE_IMPL, index,
|
||||||
type = parameter.type.substitute(typeArgumentsMap))
|
type = parameter.type.substitute(typeArgumentsMap))
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -222,7 +222,7 @@ internal class EnumClassLowering(val context: Context) : ClassLoweringPass {
|
|||||||
enumEntries
|
enumEntries
|
||||||
.sortedBy { it.name }
|
.sortedBy { it.name }
|
||||||
.map {
|
.map {
|
||||||
val initializer = it.initializerExpression
|
val initializer = it.initializerExpression?.expression
|
||||||
val entryConstructorCall = when {
|
val entryConstructorCall = when {
|
||||||
initializer is IrConstructorCall -> initializer
|
initializer is IrConstructorCall -> initializer
|
||||||
|
|
||||||
@@ -289,7 +289,7 @@ internal class EnumClassLowering(val context: Context) : ClassLoweringPass {
|
|||||||
dispatchReceiver = irGet(instances)
|
dispatchReceiver = irGet(instances)
|
||||||
putValueArgument(0, irInt(it.index))
|
putValueArgument(0, irInt(it.index))
|
||||||
}
|
}
|
||||||
val initializer = it.value.initializerExpression!!
|
val initializer = it.value.initializerExpression!!.expression
|
||||||
initializer.setDeclarationsParent(constructor)
|
initializer.setDeclarationsParent(constructor)
|
||||||
when {
|
when {
|
||||||
initializer is IrConstructorCall -> +initInstanceCall(instance, initializer)
|
initializer is IrConstructorCall -> +initInstanceCall(instance, initializer)
|
||||||
|
|||||||
+1
-1
@@ -153,7 +153,7 @@ internal class EnumConstructorsLowering(val context: Context) : ClassLoweringPas
|
|||||||
|
|
||||||
loweredConstructor.valueParameters += createSynthesizedValueParameter(0, "name", context.irBuiltIns.stringType)
|
loweredConstructor.valueParameters += createSynthesizedValueParameter(0, "name", context.irBuiltIns.stringType)
|
||||||
loweredConstructor.valueParameters += createSynthesizedValueParameter(1, "ordinal", context.irBuiltIns.intType)
|
loweredConstructor.valueParameters += createSynthesizedValueParameter(1, "ordinal", context.irBuiltIns.intType)
|
||||||
constructor.valueParameters.mapTo(loweredConstructor.valueParameters) {
|
loweredConstructor.valueParameters += constructor.valueParameters.map {
|
||||||
it.copyTo(loweredConstructor, index = it.loweredIndex).apply {
|
it.copyTo(loweredConstructor, index = it.loweredIndex).apply {
|
||||||
loweredEnumConstructorParameters[it] = this
|
loweredEnumConstructorParameters[it] = this
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -262,9 +262,9 @@ private class InteropLoweringPart1(val context: Context) : BaseInteropIrTransfor
|
|||||||
resultDescriptor.bind(result)
|
resultDescriptor.bind(result)
|
||||||
result.parent = irClass
|
result.parent = irClass
|
||||||
result.createDispatchReceiverParameter()
|
result.createDispatchReceiverParameter()
|
||||||
constructor.valueParameters.mapTo(result.valueParameters) { it.copyTo(result) }
|
result.valueParameters += constructor.valueParameters.map { it.copyTo(result) }
|
||||||
|
|
||||||
result.overriddenSymbols.add(initMethod.symbol)
|
result.overriddenSymbols += initMethod.symbol
|
||||||
|
|
||||||
result.body = context.createIrBuilder(result.symbol).irBlockBody(result) {
|
result.body = context.createIrBuilder(result.symbol).irBlockBody(result) {
|
||||||
+irReturn(
|
+irReturn(
|
||||||
@@ -407,7 +407,7 @@ private class InteropLoweringPart1(val context: Context) : BaseInteropIrTransfor
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
parameterTypes.mapIndexedTo(newFunction.valueParameters) { index, type ->
|
newFunction.valueParameters += parameterTypes.mapIndexed { index, type ->
|
||||||
WrappedValueParameterDescriptor().let {
|
WrappedValueParameterDescriptor().let {
|
||||||
IrValueParameterImpl(
|
IrValueParameterImpl(
|
||||||
function.startOffset, function.endOffset,
|
function.startOffset, function.endOffset,
|
||||||
|
|||||||
Reference in New Issue
Block a user