Backend: remove codegen factory from generation state

use it explicitly. This is a step in attempt to abstract dependencies
on PSI in the GenerationState and related places.
This commit is contained in:
Ilya Chernikov
2022-02-15 12:54:20 +03:00
committed by teamcity
parent 018782f0c7
commit da41fddabb
15 changed files with 37 additions and 50 deletions
@@ -310,8 +310,6 @@ object FirKotlinToJvmBytecodeCompiler {
(projectEnvironment as VfsBasedProjectEnvironment).project, ClassBuilderFactories.BINARIES,
moduleFragment.descriptor, dummyBindingContext, ktFiles,
moduleConfiguration
).codegenFactory(
codegenFactory
).withModule(
module
).onIndependentPartCompilationEnd(
@@ -133,7 +133,7 @@ object KotlinToJVMBytecodeCompiler {
val outputs = ArrayList<GenerationState>(chunk.size)
for (input in codegenInputs) {
outputs += runCodegen(input, input.state, result.bindingContext, diagnosticsReporter, environment.configuration)
outputs += runCodegen(input, input.state, codegenFactory, result.bindingContext, diagnosticsReporter, environment.configuration)
}
return writeOutputs(environment.project, projectConfiguration, chunk, outputs, mainClassFqName)
@@ -206,7 +206,7 @@ object KotlinToJVMBytecodeCompiler {
environment, environment.configuration, result, environment.getSourceFiles(), null, codegenFactory, backendInput,
diagnosticsReporter
)
return runCodegen(input, input.state, result.bindingContext, diagnosticsReporter, environment.configuration)
return runCodegen(input, input.state, codegenFactory, result.bindingContext, diagnosticsReporter, environment.configuration)
}
private fun convertToIr(environment: KotlinCoreEnvironment, result: AnalysisResult): Pair<CodegenFactory, CodegenFactory.BackendInput> {
@@ -321,7 +321,6 @@ object KotlinToJVMBytecodeCompiler {
sourceFiles,
configuration
)
.codegenFactory(codegenFactory)
.withModule(module)
.onIndependentPartCompilationEnd(createOutputFilesFlushingCallbackIfPossible(configuration))
.diagnosticReporter(diagnosticsReporter)
@@ -343,6 +342,7 @@ object KotlinToJVMBytecodeCompiler {
private fun runCodegen(
codegenInput: CodegenFactory.CodegenInput,
state: GenerationState,
codegenFactory: CodegenFactory,
bindingContext: BindingContext,
diagnosticsReporter: BaseDiagnosticsCollector,
configuration: CompilerConfiguration,
@@ -352,7 +352,7 @@ object KotlinToJVMBytecodeCompiler {
val performanceManager = configuration[CLIConfigurationKeys.PERF_MANAGER]
performanceManager?.notifyIRGenerationStarted()
state.codegenFactory.invokeCodegen(codegenInput)
codegenFactory.invokeCodegen(codegenInput)
CodegenFactory.doCheckCancelled(state)
state.factory.done()
@@ -222,8 +222,6 @@ fun generateCodeFromIr(
(environment.projectEnvironment as VfsBasedProjectEnvironment).project, ClassBuilderFactories.BINARIES,
input.irModuleFragment.descriptor, dummyBindingContext, emptyList()/* !! */,
input.configuration
).codegenFactory(
codegenFactory
).targetId(
input.targetId
).moduleName(