[K/N] Introduce more createFileLoweringPhase overloads
They simplify porting from the old builders
This commit is contained in:
committed by
Space Team
parent
fafa2b1a67
commit
f9d0755f94
+48
-21
@@ -48,46 +48,39 @@ internal val modulePhaseActions: Set<Action<IrModuleFragment, NativeGenerationSt
|
|||||||
nativeStateIrValidator.takeIf { validateAll }
|
nativeStateIrValidator.takeIf { validateAll }
|
||||||
)
|
)
|
||||||
|
|
||||||
internal val ReturnsInsertionPhase = createSimpleNamedCompilerPhase(
|
internal val ReturnsInsertionPhase = createFileLoweringPhase(
|
||||||
name = "ReturnsInsertion",
|
name = "ReturnsInsertion",
|
||||||
description = "Returns insertion for Unit functions",
|
description = "Returns insertion for Unit functions",
|
||||||
postactions = fileLoweringActions,
|
|
||||||
//prerequisite = setOf(autoboxPhase, coroutinesPhase, enumClassPhase), TODO: if there are no files in the module, this requirement fails.
|
//prerequisite = setOf(autoboxPhase, coroutinesPhase, enumClassPhase), TODO: if there are no files in the module, this requirement fails.
|
||||||
op = { context, irFile -> ReturnsInsertionLowering(context.context).lower(irFile) }
|
lowering = ::ReturnsInsertionLowering,
|
||||||
)
|
)
|
||||||
|
|
||||||
internal val InlineClassPropertyAccessorsPhase = createSimpleNamedCompilerPhase(
|
internal val InlineClassPropertyAccessorsPhase = createFileLoweringPhase(
|
||||||
name = "InlineClassPropertyAccessorsLowering",
|
name = "InlineClassPropertyAccessorsLowering",
|
||||||
description = "Inline class property accessors",
|
description = "Inline class property accessors",
|
||||||
postactions = fileLoweringActions,
|
lowering = ::InlineClassPropertyAccessorsLowering,
|
||||||
op = { context, irFile -> InlineClassPropertyAccessorsLowering(context.context).lower(irFile) }
|
|
||||||
)
|
)
|
||||||
|
|
||||||
internal val RedundantCoercionsCleaningPhase = createSimpleNamedCompilerPhase(
|
internal val RedundantCoercionsCleaningPhase = createFileLoweringPhase(
|
||||||
name = "RedundantCoercionsCleaning",
|
name = "RedundantCoercionsCleaning",
|
||||||
description = "Redundant coercions cleaning",
|
description = "Redundant coercions cleaning",
|
||||||
postactions = fileLoweringActions,
|
lowering = ::RedundantCoercionsCleaner,
|
||||||
op = { context, irFile -> RedundantCoercionsCleaner(context.context).lower(irFile) }
|
|
||||||
)
|
)
|
||||||
|
|
||||||
internal val PropertyAccessorInlinePhase = createSimpleNamedCompilerPhase(
|
internal val PropertyAccessorInlinePhase = createFileLoweringPhase(
|
||||||
name = "PropertyAccessorInline",
|
name = "PropertyAccessorInline",
|
||||||
description = "Property accessor inline lowering",
|
description = "Property accessor inline lowering",
|
||||||
postactions = fileLoweringActions
|
lowering = ::PropertyAccessorInlineLowering,
|
||||||
) { context, irFile ->
|
)
|
||||||
PropertyAccessorInlineLowering(context.context).lower(irFile)
|
|
||||||
}
|
|
||||||
|
|
||||||
internal val UnboxInlinePhase = createSimpleNamedCompilerPhase(
|
internal val UnboxInlinePhase = createFileLoweringPhase(
|
||||||
name = "UnboxInline",
|
name = "UnboxInline",
|
||||||
description = "Unbox functions inline lowering",
|
description = "Unbox functions inline lowering",
|
||||||
postactions = fileLoweringActions
|
lowering = ::UnboxInlineLowering,
|
||||||
) { context, irFile ->
|
)
|
||||||
UnboxInlineLowering(context.context).lower(irFile)
|
|
||||||
}
|
|
||||||
|
|
||||||
private val InlinePhase = createFileLoweringPhase(
|
private val InlinePhase = createFileLoweringPhase(
|
||||||
lowering = { context ->
|
lowering = { context: NativeGenerationState ->
|
||||||
object : FileLoweringPass {
|
object : FileLoweringPass {
|
||||||
override fun lower(irFile: IrFile) {
|
override fun lower(irFile: IrFile) {
|
||||||
FunctionInlining(context.context, NativeInlineFunctionResolver(context.context, context)).lower(irFile)
|
FunctionInlining(context.context, NativeInlineFunctionResolver(context.context, context)).lower(irFile)
|
||||||
@@ -136,7 +129,7 @@ private val ObjectClassesPhase = createFileLoweringPhase(
|
|||||||
)
|
)
|
||||||
|
|
||||||
private val CoroutinesPhase = createFileLoweringPhase(
|
private val CoroutinesPhase = createFileLoweringPhase(
|
||||||
lowering = { context ->
|
lowering = { context: NativeGenerationState ->
|
||||||
object : FileLoweringPass {
|
object : FileLoweringPass {
|
||||||
override fun lower(irFile: IrFile) {
|
override fun lower(irFile: IrFile) {
|
||||||
NativeSuspendFunctionsLowering(context).lower(irFile)
|
NativeSuspendFunctionsLowering(context).lower(irFile)
|
||||||
@@ -246,3 +239,37 @@ private fun createFileLoweringPhase(
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
private fun createFileLoweringPhase(
|
||||||
|
lowering: (Context) -> FileLoweringPass,
|
||||||
|
name: String,
|
||||||
|
description: String,
|
||||||
|
prerequisite: Set<AbstractNamedCompilerPhase<*, *, *>> = emptySet(),
|
||||||
|
): SimpleNamedCompilerPhase<NativeGenerationState, IrFile, IrFile> = createSimpleNamedCompilerPhase(
|
||||||
|
name,
|
||||||
|
description,
|
||||||
|
postactions = fileLoweringActions,
|
||||||
|
prerequisite = prerequisite,
|
||||||
|
outputIfNotEnabled = { _, _, _, irFile -> irFile },
|
||||||
|
op = { context, irFile ->
|
||||||
|
lowering(context.context).lower(irFile)
|
||||||
|
irFile
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
private fun createFileLoweringPhase(
|
||||||
|
op: (context: Context, irFile: IrFile) -> Unit,
|
||||||
|
name: String,
|
||||||
|
description: String,
|
||||||
|
prerequisite: Set<AbstractNamedCompilerPhase<*, *, *>> = emptySet(),
|
||||||
|
): SimpleNamedCompilerPhase<NativeGenerationState, IrFile, IrFile> = createSimpleNamedCompilerPhase(
|
||||||
|
name,
|
||||||
|
description,
|
||||||
|
postactions = fileLoweringActions,
|
||||||
|
prerequisite = prerequisite,
|
||||||
|
outputIfNotEnabled = { _, _, _, irFile -> irFile },
|
||||||
|
op = { context, irFile ->
|
||||||
|
op(context.context, irFile)
|
||||||
|
irFile
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user