JVM IR: introduce CodegenFactory.convertToIr

The steps of psi2ir and JVM backend need to be separated in the API
because in case of cyclic module dependencies (which are allowed in JPS)
psi2ir should be run first on all sources, and then JVM backend on each
module separately. `CodegenFactory.convertToIr` does nothing in the old
backend.

Also, move the ignoreErrors to GenerationState for simplicity.
This commit is contained in:
Alexander Udalov
2021-09-13 23:42:32 +02:00
parent bfeb9c219d
commit 5d6ca27c93
9 changed files with 79 additions and 38 deletions
@@ -19,6 +19,7 @@ import org.jetbrains.kotlin.cli.common.messages.MessageCollectorBasedReporter
import org.jetbrains.kotlin.cli.common.repl.LineId
import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment
import org.jetbrains.kotlin.codegen.ClassBuilderFactories
import org.jetbrains.kotlin.codegen.CodegenFactory
import org.jetbrains.kotlin.codegen.KotlinCodegenFacade
import org.jetbrains.kotlin.codegen.state.GenerationState
import org.jetbrains.kotlin.config.JVMConfigurationKeys
@@ -200,7 +201,10 @@ open class KJvmReplCompilerBase<AnalyzerT : ReplCodeAnalyzerBase>(
.codegenFactory(codegenFactory)
.build()
generationState.codegenFactory.generateModule(generationState, generationState.files)
codegenFactory.generateModule(
generationState,
codegenFactory.convertToIr(CodegenFactory.IrConversionInput.fromGenerationState(generationState)),
)
return generationState
}