JVM_IR: reorganize initialization of JvmGeneratorExtensionsImpl

CachedFields are now created at initialization.
Therefore we need CompilerConfiguration as a constructor parameter.
This commit is contained in:
Georgy Bronnikov
2021-06-07 17:52:17 +03:00
committed by TeamCityServer
parent 7bbc04b6a2
commit 20b76d4149
12 changed files with 36 additions and 42 deletions
@@ -198,10 +198,11 @@ open class KJvmReplCompilerBase<AnalyzerT : ReplCodeAnalyzerBase> protected cons
snippetKtFile: KtFile,
sourceFiles: List<KtFile>
): GenerationState {
val generatorExtensions = object : JvmGeneratorExtensionsImpl() {
val generatorExtensions = object : JvmGeneratorExtensionsImpl(compilationState.environment.configuration) {
override fun getPreviousScripts() = history.map { compilationState.symbolTable.referenceScript(it.item) }
}
val codegenFactory = JvmIrCodegenFactory(
compilationState.environment.configuration,
compilationState.environment.configuration.get(CLIConfigurationKeys.PHASE_CONFIG) ?: PhaseConfig(jvmPhases),
compilationState.mangler, compilationState.symbolTable, generatorExtensions
)
@@ -238,7 +238,8 @@ private fun generate(
).codegenFactory(
if (kotlinCompilerConfiguration.getBoolean(JVMConfigurationKeys.IR))
JvmIrCodegenFactory(
kotlinCompilerConfiguration.get(CLIConfigurationKeys.PHASE_CONFIG) ?: PhaseConfig(jvmPhases)
kotlinCompilerConfiguration,
kotlinCompilerConfiguration.get(CLIConfigurationKeys.PHASE_CONFIG) ?: PhaseConfig(jvmPhases),
) else DefaultCodegenFactory
).build().also {
KotlinCodegenFacade.compileCorrectFiles(it)