[IR] Add KDoc for PhaserState, CompilerPhase and PhaseConfig classes
This commit is contained in:
+19
@@ -8,6 +8,15 @@ package org.jetbrains.kotlin.backend.common.phaser
|
|||||||
import org.jetbrains.kotlin.backend.common.LoggingContext
|
import org.jetbrains.kotlin.backend.common.LoggingContext
|
||||||
import kotlin.system.measureTimeMillis
|
import kotlin.system.measureTimeMillis
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents global compilation context and stores information about phases that were executed.
|
||||||
|
*
|
||||||
|
* @property alreadyDone A set of already executed phases.
|
||||||
|
* @property depth shows The index of the currently running phase.
|
||||||
|
* @property phaseCount A unique ID that can show the order in which phases were executed.
|
||||||
|
* @property stickyPostconditions A set of conditions that must be checked after each phase.
|
||||||
|
* When a condition is added into [stickyPostconditions], it will be executed each time some phase is executed, until we change [Data].
|
||||||
|
*/
|
||||||
class PhaserState<Data>(
|
class PhaserState<Data>(
|
||||||
val alreadyDone: MutableSet<AnyNamedPhase> = mutableSetOf(),
|
val alreadyDone: MutableSet<AnyNamedPhase> = mutableSetOf(),
|
||||||
var depth: Int = 0,
|
var depth: Int = 0,
|
||||||
@@ -27,7 +36,17 @@ inline fun <R, D> PhaserState<D>.downlevel(nlevels: Int, block: () -> R): R {
|
|||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents some compiler phase that can be executed.
|
||||||
|
*/
|
||||||
interface CompilerPhase<in Context : LoggingContext, Input, Output> {
|
interface CompilerPhase<in Context : LoggingContext, Input, Output> {
|
||||||
|
/**
|
||||||
|
* Executes this compiler phase. It accepts some parameter of type [Input] and transforms it into [Output].
|
||||||
|
*
|
||||||
|
* @param phaseConfig Controls which parts of the compilation pipeline are enabled and how the compiler should validate their invariants.
|
||||||
|
* @param phaserState The global context.
|
||||||
|
* @param context The local context in which the compiler stores all the necessary information for the given phase.
|
||||||
|
*/
|
||||||
fun invoke(phaseConfig: PhaseConfigurationService, phaserState: PhaserState<Input>, context: Context, input: Input): Output
|
fun invoke(phaseConfig: PhaseConfigurationService, phaserState: PhaserState<Input>, context: Context, input: Input): Output
|
||||||
|
|
||||||
fun getNamedSubphases(startDepth: Int = 0): List<Pair<Int, AbstractNamedCompilerPhase<Context, *, *>>> = emptyList()
|
fun getNamedSubphases(startDepth: Int = 0): List<Pair<Int, AbstractNamedCompilerPhase<Context, *, *>>> = emptyList()
|
||||||
|
|||||||
+4
@@ -33,6 +33,10 @@ class PhaseConfigBuilder(private val compoundPhase: CompilerPhase<*, *, *>) {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Phase configuration that defines and configures [CompilerPhase]s that the compiler should execute.
|
||||||
|
* It is defined before compilation and can't be modified in the process.
|
||||||
|
*/
|
||||||
class PhaseConfig(
|
class PhaseConfig(
|
||||||
private val compoundPhase: CompilerPhase<*, *, *>,
|
private val compoundPhase: CompilerPhase<*, *, *>,
|
||||||
private val phases: Map<String, AnyNamedPhase> = compoundPhase.toPhaseMap(),
|
private val phases: Map<String, AnyNamedPhase> = compoundPhase.toPhaseMap(),
|
||||||
|
|||||||
Reference in New Issue
Block a user