[K/N] Turn NativeGenerationState into PhaseContext
It allows to use NativeGenerationState as a PhaseContext in lowering and codegen phases.
This commit is contained in:
committed by
Space Team
parent
8a9acfcab0
commit
b8f9b07a5a
+7
-4
@@ -6,6 +6,7 @@
|
||||
package org.jetbrains.kotlin.backend.konan
|
||||
|
||||
import llvm.*
|
||||
import org.jetbrains.kotlin.backend.konan.driver.BasicPhaseContext
|
||||
import org.jetbrains.kotlin.backend.konan.llvm.*
|
||||
import org.jetbrains.kotlin.backend.konan.llvm.DebugInfo
|
||||
import org.jetbrains.kotlin.backend.konan.llvm.Llvm
|
||||
@@ -42,9 +43,11 @@ internal class FileLowerState {
|
||||
"$prefix${cStubCount++}"
|
||||
}
|
||||
|
||||
internal class NativeGenerationState(val context: Context, val cacheDeserializationStrategy: CacheDeserializationStrategy?) {
|
||||
private val config = context.config
|
||||
|
||||
internal class NativeGenerationState(
|
||||
config: KonanConfig,
|
||||
val context: Context,
|
||||
val cacheDeserializationStrategy: CacheDeserializationStrategy?
|
||||
) : BasicPhaseContext(config) {
|
||||
private val outputPath = config.cacheSupport.tryGetImplicitOutput(cacheDeserializationStrategy) ?: config.outputPath
|
||||
val outputFiles = OutputFiles(outputPath, config.target, config.produce)
|
||||
val tempFiles = run {
|
||||
@@ -118,7 +121,7 @@ internal class NativeGenerationState(val context: Context, val cacheDeserializat
|
||||
}
|
||||
|
||||
private var isDisposed = false
|
||||
fun dispose() {
|
||||
override fun dispose() {
|
||||
if (isDisposed) return
|
||||
|
||||
if (hasDebugInfo()) {
|
||||
|
||||
+6
-2
@@ -361,7 +361,11 @@ internal val umbrellaCompilation = SameTypeNamedCompilerPhase(
|
||||
for (file in files) {
|
||||
if (file.isFunctionInterfaceFile) continue
|
||||
|
||||
context.generationState = NativeGenerationState(context, CacheDeserializationStrategy.SingleFile(file.path, file.fqName.asString()))
|
||||
context.generationState = NativeGenerationState(
|
||||
context.config,
|
||||
context,
|
||||
CacheDeserializationStrategy.SingleFile(file.path, file.fqName.asString())
|
||||
)
|
||||
|
||||
module.files += file
|
||||
if (context.generationState.shouldDefineFunctionClasses)
|
||||
@@ -449,7 +453,7 @@ internal val createGenerationStatePhase = namedUnitPhase(
|
||||
description = "Create generation state",
|
||||
lower = object : CompilerPhase<Context, Unit, Unit> {
|
||||
override fun invoke(phaseConfig: PhaseConfigurationService, phaserState: PhaserState<Unit>, context: Context, input: Unit) {
|
||||
context.generationState = NativeGenerationState(context, context.config.libraryToCache?.strategy)
|
||||
context.generationState = NativeGenerationState(context.config, context, context.config.libraryToCache?.strategy)
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user