Fir2Ir: pass Fir2IrExtensions to backend
This commit is contained in:
committed by
Alexander Udalov
parent
3c3c1be543
commit
13d4d60afa
+2
-13
@@ -17,8 +17,6 @@ import org.jetbrains.kotlin.incremental.components.NoLookupLocation
|
||||
import org.jetbrains.kotlin.ir.IrBuiltIns
|
||||
import org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI
|
||||
import org.jetbrains.kotlin.ir.backend.jvm.serialization.JvmIrMangler
|
||||
import org.jetbrains.kotlin.ir.builders.declarations.addConstructor
|
||||
import org.jetbrains.kotlin.ir.builders.declarations.buildClass
|
||||
import org.jetbrains.kotlin.ir.declarations.*
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrExternalPackageFragmentImpl
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrFactoryImpl
|
||||
@@ -173,17 +171,8 @@ open class JvmGeneratorExtensionsImpl(
|
||||
private val specialAnnotationConstructors = mutableListOf<IrConstructor>()
|
||||
|
||||
private fun createSpecialAnnotationClass(fqn: FqName, parent: IrPackageFragment) =
|
||||
IrFactoryImpl.buildClass {
|
||||
kind = ClassKind.ANNOTATION_CLASS
|
||||
name = fqn.shortName()
|
||||
}.apply {
|
||||
createImplicitParameterDeclarationWithWrappedDescriptor()
|
||||
this.parent = parent
|
||||
addConstructor {
|
||||
isPrimary = true
|
||||
}.also { constructor ->
|
||||
specialAnnotationConstructors.add(constructor)
|
||||
}
|
||||
IrFactoryImpl.createSpecialAnnotationClass(fqn, parent).apply {
|
||||
specialAnnotationConstructors.add(constructors.single())
|
||||
}
|
||||
|
||||
override fun createCustomSuperConstructorCall(
|
||||
|
||||
+3
-5
@@ -8,10 +8,8 @@ package org.jetbrains.kotlin.backend.jvm
|
||||
import org.jetbrains.kotlin.analyzer.hasJdkCapability
|
||||
import org.jetbrains.kotlin.backend.common.extensions.IrGenerationExtension
|
||||
import org.jetbrains.kotlin.backend.common.extensions.IrPluginContextImpl
|
||||
import org.jetbrains.kotlin.backend.common.phaser.CompilerPhase
|
||||
import org.jetbrains.kotlin.backend.common.phaser.PhaseConfig
|
||||
import org.jetbrains.kotlin.backend.common.phaser.invokeToplevel
|
||||
import org.jetbrains.kotlin.backend.common.phaser.then
|
||||
import org.jetbrains.kotlin.backend.common.serialization.DescriptorByIdSignatureFinderImpl
|
||||
import org.jetbrains.kotlin.backend.jvm.intrinsics.IrIntrinsicMethods
|
||||
import org.jetbrains.kotlin.backend.jvm.ir.getIoFile
|
||||
@@ -64,7 +62,7 @@ open class JvmIrCodegenFactory(
|
||||
val symbolTable: SymbolTable,
|
||||
val phaseConfig: PhaseConfig?,
|
||||
val irProviders: List<IrProvider>,
|
||||
val extensions: JvmGeneratorExtensionsImpl,
|
||||
val extensions: JvmGeneratorExtensions,
|
||||
val backendExtension: JvmBackendExtension,
|
||||
val notifyCodegenStart: () -> Unit
|
||||
) : CodegenFactory.BackendInput
|
||||
@@ -294,11 +292,11 @@ open class JvmIrCodegenFactory(
|
||||
state: GenerationState,
|
||||
irModuleFragment: IrModuleFragment,
|
||||
symbolTable: SymbolTable,
|
||||
extensions: JvmGeneratorExtensionsImpl,
|
||||
extensions: JvmGeneratorExtensions,
|
||||
backendExtension: JvmBackendExtension,
|
||||
notifyCodegenStart: () -> Unit = {}
|
||||
) {
|
||||
val irProviders = configureBuiltInsAndGenerateIrProvidersInFrontendIRMode(irModuleFragment, symbolTable, extensions)
|
||||
val irProviders = configureBuiltInsAndGenerateIrProvidersInFrontendIRMode(irModuleFragment, symbolTable, jvmGeneratorExtensions)
|
||||
generateModule(
|
||||
state,
|
||||
JvmIrBackendInput(irModuleFragment, symbolTable, phaseConfig, irProviders, extensions, backendExtension, notifyCodegenStart)
|
||||
|
||||
@@ -8,6 +8,7 @@ package org.jetbrains.kotlin.ir.util
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.ir.*
|
||||
import org.jetbrains.kotlin.ir.builders.declarations.addConstructor
|
||||
import org.jetbrains.kotlin.ir.builders.declarations.buildClass
|
||||
import org.jetbrains.kotlin.ir.builders.declarations.buildReceiverParameter
|
||||
import org.jetbrains.kotlin.ir.builders.declarations.buildTypeParameter
|
||||
import org.jetbrains.kotlin.ir.declarations.*
|
||||
@@ -986,6 +987,18 @@ fun IrClass.createImplicitParameterDeclarationWithWrappedDescriptor() {
|
||||
thisReceiver = buildReceiverParameter(this, IrDeclarationOrigin.INSTANCE_RECEIVER, symbol.typeWithParameters(typeParameters))
|
||||
}
|
||||
|
||||
fun IrFactory.createSpecialAnnotationClass(fqn: FqName, parent: IrPackageFragment) =
|
||||
buildClass {
|
||||
kind = ClassKind.ANNOTATION_CLASS
|
||||
name = fqn.shortName()
|
||||
}.apply {
|
||||
createImplicitParameterDeclarationWithWrappedDescriptor()
|
||||
this.parent = parent
|
||||
addConstructor {
|
||||
isPrimary = true
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun isElseBranch(branch: IrBranch) = branch is IrElseBranch || ((branch.condition as? IrConst<Boolean>)?.value == true)
|
||||
|
||||
@@ -1242,4 +1255,4 @@ private fun computeAllOverridden(function: IrSimpleFunction, result: MutableSet<
|
||||
}
|
||||
|
||||
fun IrBuiltIns.getKFunctionType(returnType: IrType, parameterTypes: List<IrType>) =
|
||||
kFunctionN(parameterTypes.size).typeWith(parameterTypes + returnType)
|
||||
kFunctionN(parameterTypes.size).typeWith(parameterTypes + returnType)
|
||||
|
||||
Reference in New Issue
Block a user