Skip to content

Commit

Permalink
Rename compiler dependent and independent phases.
Browse files Browse the repository at this point in the history
  • Loading branch information
FilipDolnik committed Apr 17, 2024
1 parent c2ebaf0 commit 7801962
Show file tree
Hide file tree
Showing 48 changed files with 138 additions and 144 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package co.touchlab.skie.phases

interface ClassExportCorePhase : ClassExportPhase<ClassExportPhase.Context>

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package co.touchlab.skie.phases

interface KirCorePhase : KirPhase<KirPhase.Context>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package co.touchlab.skie.phases

interface LinkCorePhase : LinkPhase<LinkPhase.Context>
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package co.touchlab.skie.phases.analytics

import co.touchlab.skie.phases.CompilerIndependentLinkPhase
import co.touchlab.skie.phases.LinkCorePhase
import co.touchlab.skie.phases.LinkPhase

// Cannot run in the background otherwise there is a risk of a deadlock
object LogSkiePerformanceAnalyticsPhase : CompilerIndependentLinkPhase {
object LogSkiePerformanceAnalyticsPhase : LinkCorePhase {

context(LinkPhase.Context)
override suspend fun execute() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ import co.touchlab.skie.kir.type.PointerKirType
import co.touchlab.skie.kir.type.SpecialOirKirType
import co.touchlab.skie.kir.type.TypeParameterUsageKirType
import co.touchlab.skie.kir.type.UnresolvedFlowKirType
import co.touchlab.skie.phases.CompilerIndependentKirPhase
import co.touchlab.skie.phases.KirCorePhase
import co.touchlab.skie.phases.KirPhase

class ConvertFlowsPhase(
context: KirPhase.Context,
) : CompilerIndependentKirPhase {
) : KirCorePhase {

private val kirProvider = context.kirProvider

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ import co.touchlab.skie.kir.element.KirCallableDeclaration
import co.touchlab.skie.kir.element.KirFunction
import co.touchlab.skie.kir.element.KirOverridableDeclaration
import co.touchlab.skie.kir.util.getEntireOverrideHierarchy
import co.touchlab.skie.phases.CompilerIndependentKirPhase
import co.touchlab.skie.phases.KirCorePhase
import co.touchlab.skie.phases.KirPhase

class UnifyFlowConfigurationForOverridesPhase(
context: KirPhase.Context,
) : CompilerIndependentKirPhase {
) : KirCorePhase {

private val kirProvider = context.kirProvider

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package co.touchlab.skie.phases.kir

import co.touchlab.skie.phases.CompilerIndependentKirPhase
import co.touchlab.skie.phases.KirCorePhase
import co.touchlab.skie.phases.KirPhase

object InitializeKirMembersCachePhase : CompilerIndependentKirPhase {
object InitializeKirMembersCachePhase : KirCorePhase {

context(KirPhase.Context)
override suspend fun execute() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package co.touchlab.skie.phases.other

import co.touchlab.skie.phases.CompilerIndependentLinkPhase
import co.touchlab.skie.phases.LinkCorePhase
import co.touchlab.skie.phases.LinkPhase

object AwaitAllBackgroundJobsPhase : CompilerIndependentLinkPhase {
object AwaitAllBackgroundJobsPhase : LinkCorePhase {

context(LinkPhase.Context)
override suspend fun execute() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package co.touchlab.skie.phases.other

import co.touchlab.skie.phases.CompilerIndependentLinkPhase
import co.touchlab.skie.phases.LinkCorePhase
import co.touchlab.skie.phases.LinkPhase

object LinkObjectFilesPhase : CompilerIndependentLinkPhase {
object LinkObjectFilesPhase : LinkCorePhase {

context(LinkPhase.Context)
override suspend fun execute() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package co.touchlab.skie.phases.other

import co.touchlab.skie.phases.ClassExportPhase
import co.touchlab.skie.phases.CompilerIndependentClassExportPhase
import co.touchlab.skie.phases.ClassExportCorePhase

object VerifyModuleNamePhase : CompilerIndependentClassExportPhase {
object VerifyModuleNamePhase : ClassExportCorePhase {

private val problematicKeywords = listOf(
"associatedtype",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ package co.touchlab.skie.phases.other

import co.touchlab.skie.configuration.SwiftCompilerConfiguration
import co.touchlab.skie.phases.ClassExportPhase
import co.touchlab.skie.phases.CompilerIndependentClassExportPhase
import co.touchlab.skie.phases.ClassExportCorePhase

object VerifyNoBitcodeEmbeddingPhase : CompilerIndependentClassExportPhase {
object VerifyNoBitcodeEmbeddingPhase : ClassExportCorePhase {

context(ClassExportPhase.Context)
override suspend fun execute() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import co.touchlab.skie.configuration.SimpleFunctionConfiguration
import co.touchlab.skie.configuration.ValueParameterConfiguration
import co.touchlab.skie.configuration.provider.ConfigurationProvider
import co.touchlab.skie.configuration.provider.IdentifiedConfigurationTarget
import co.touchlab.skie.phases.CompilerDependentForegroundPhase
import co.touchlab.skie.phases.ForegroundCompilerPhase
import org.jetbrains.kotlin.backend.common.serialization.findPackage
import org.jetbrains.kotlin.descriptors.ClassDescriptor
import org.jetbrains.kotlin.descriptors.ConstructorDescriptor
Expand Down Expand Up @@ -138,19 +138,19 @@ class DescriptorConfigurationProvider(
}
}

context(CompilerDependentForegroundPhase.Context)
context(ForegroundCompilerPhase.Context)
val ClassDescriptor.configuration: ClassConfiguration
get() = descriptorConfigurationProvider.getConfiguration(this)

context(CompilerDependentForegroundPhase.Context)
context(ForegroundCompilerPhase.Context)
val SimpleFunctionDescriptor.configuration: SimpleFunctionConfiguration
get() = descriptorConfigurationProvider.getConfiguration(this)

context(CompilerDependentForegroundPhase.Context)
context(ForegroundCompilerPhase.Context)
val ConstructorDescriptor.configuration: ConstructorConfiguration
get() = descriptorConfigurationProvider.getConfiguration(this)

context(CompilerDependentForegroundPhase.Context)
context(ForegroundCompilerPhase.Context)
val FunctionDescriptor.configuration: FunctionConfiguration
get() = when (this) {
is SimpleFunctionDescriptor -> configuration
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ package co.touchlab.skie.context

import co.touchlab.skie.kir.descriptor.MutableDescriptorProvider
import co.touchlab.skie.kir.irbuilder.impl.DeclarationBuilderImpl
import co.touchlab.skie.phases.CompilerDependentClassExportPhase
import co.touchlab.skie.phases.CompilerDependentForegroundPhase
import co.touchlab.skie.phases.ClassExportCompilerPhase
import co.touchlab.skie.phases.ForegroundCompilerPhase

class ClassExportPhaseContext(
mainSkieContext: MainSkieContext,
) : CompilerDependentClassExportPhase.Context, CompilerDependentForegroundPhase.Context by mainSkieContext {
) : ClassExportCompilerPhase.Context, ForegroundCompilerPhase.Context by mainSkieContext {

override val context: ClassExportPhaseContext = this

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package co.touchlab.skie.context

import co.touchlab.skie.kir.irbuilder.impl.DeclarationBuilderImpl
import co.touchlab.skie.phases.CompilerDependentForegroundPhase
import co.touchlab.skie.phases.ForegroundCompilerPhase
import co.touchlab.skie.phases.DescriptorModificationPhase

class DescriptorModificationPhaseContext(
mainSkieContext: MainSkieContext,
) : DescriptorModificationPhase.Context, CompilerDependentForegroundPhase.Context by mainSkieContext {
) : DescriptorModificationPhase.Context, ForegroundCompilerPhase.Context by mainSkieContext {

override val context: DescriptorModificationPhaseContext = this

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@ import co.touchlab.skie.kir.descriptor.ObjCExportedInterfaceProvider
import co.touchlab.skie.kir.type.translation.KirCustomTypeMappers
import co.touchlab.skie.kir.type.translation.KirDeclarationTypeTranslator
import co.touchlab.skie.kir.type.translation.KirTypeTranslator
import co.touchlab.skie.phases.CompilerDependentKirPhase
import co.touchlab.skie.phases.CompilerDependentForegroundPhase
import co.touchlab.skie.phases.KirCompilerPhase
import co.touchlab.skie.phases.ForegroundCompilerPhase
import org.jetbrains.kotlin.backend.konan.objcexport.ObjCExportNamer

class KirPhaseContext(
mainSkieContext: MainSkieContext,
override val objCExportedInterfaceProvider: ObjCExportedInterfaceProvider,
) : CompilerDependentKirPhase.Context, CompilerDependentForegroundPhase.Context by mainSkieContext {
) : KirCompilerPhase.Context, ForegroundCompilerPhase.Context by mainSkieContext {

override val context: CompilerDependentKirPhase.Context = this
override val context: KirCompilerPhase.Context = this

override val kirProvider: KirProvider = KirProvider(lazy { descriptorKirProvider }, rootConfiguration).also {
mainSkieContext.kirProvider = it
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ package co.touchlab.skie.context

import co.touchlab.skie.kir.irbuilder.impl.DeclarationBuilderImpl
import co.touchlab.skie.kir.util.SkieSymbolTable
import co.touchlab.skie.phases.CompilerDependentForegroundPhase
import co.touchlab.skie.phases.ForegroundPhase
import co.touchlab.skie.phases.ForegroundCompilerPhase
import co.touchlab.skie.phases.KotlinIrPhase
import org.jetbrains.kotlin.backend.common.extensions.IrPluginContext
import org.jetbrains.kotlin.backend.common.extensions.IrPluginContextImpl
Expand All @@ -17,7 +16,7 @@ class KotlinIrPhaseContext(
mainSkieContext: MainSkieContext,
override val moduleFragment: IrModuleFragment,
override val pluginContext: IrPluginContext,
) : KotlinIrPhase.Context, CompilerDependentForegroundPhase.Context by mainSkieContext {
) : KotlinIrPhase.Context, ForegroundCompilerPhase.Context by mainSkieContext {

override val context: KotlinIrPhaseContext = this

Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
package co.touchlab.skie.context

import co.touchlab.skie.kir.descriptor.DescriptorKirProvider
import co.touchlab.skie.phases.CompilerDependentForegroundPhase
import co.touchlab.skie.phases.CompilerDependentLinkPhase
import co.touchlab.skie.phases.ForegroundCompilerPhase
import co.touchlab.skie.phases.LinkCompilerPhase
import java.nio.file.Path

class LinkPhaseContext(
private val mainSkieContext: MainSkieContext,
private val link: (additionalObjectFiles: List<Path>) -> Unit,
) : CompilerDependentLinkPhase.Context, CompilerDependentForegroundPhase.Context by mainSkieContext {
) : LinkCompilerPhase.Context, ForegroundCompilerPhase.Context by mainSkieContext {

override val context: CompilerDependentLinkPhase.Context = this
override val context: LinkCompilerPhase.Context = this

override val descriptorKirProvider: DescriptorKirProvider = mainSkieContext.descriptorKirProvider

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,12 @@ import co.touchlab.skie.kir.descriptor.MutableDescriptorProvider
import co.touchlab.skie.kir.descriptor.NativeDescriptorProvider
import co.touchlab.skie.kir.irbuilder.impl.DeclarationBuilderImpl
import co.touchlab.skie.phases.BackgroundPhase
import co.touchlab.skie.phases.ForegroundPhase
import co.touchlab.skie.phases.InitPhase
import co.touchlab.skie.phases.ScheduledPhase
import co.touchlab.skie.phases.util.StatefulScheduledPhase
import co.touchlab.skie.configuration.SwiftCompilerConfiguration
import co.touchlab.skie.configuration.SwiftCompilerConfiguration.BuildType
import co.touchlab.skie.phases.CompilerDependentForegroundPhase
import co.touchlab.skie.phases.ForegroundCompilerPhase
import kotlinx.coroutines.CoroutineExceptionHandler
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
Expand All @@ -36,7 +35,7 @@ class MainSkieContext internal constructor(
frontendServices: FrontendServices,
val mainModuleDescriptor: ModuleDescriptor,
exportedDependencies: Collection<ModuleDescriptor>,
) : CompilerDependentForegroundPhase.Context, BackgroundPhase.Context, InitPhase.Context by initPhaseContext {
) : ForegroundCompilerPhase.Context, BackgroundPhase.Context, InitPhase.Context by initPhaseContext {

private val skieCoroutineScope: CoroutineScope = CoroutineScope(Dispatchers.Default) + CoroutineExceptionHandler { _, _ ->
// Hides default stderr output because the exception is handled at the end of the job
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@ package co.touchlab.skie.context

import co.touchlab.skie.kir.irbuilder.impl.DeclarationBuilderImpl
import co.touchlab.skie.kir.util.SkieSymbolTable
import co.touchlab.skie.phases.CompilerDependentForegroundPhase
import co.touchlab.skie.phases.ForegroundPhase
import co.touchlab.skie.phases.ForegroundCompilerPhase
import co.touchlab.skie.phases.SymbolTablePhase
import org.jetbrains.kotlin.ir.util.SymbolTable

class SymbolTablePhaseContext(
mainSkieContext: MainSkieContext,
symbolTable: SymbolTable,
) : SymbolTablePhase.Context, CompilerDependentForegroundPhase.Context by mainSkieContext {
) : SymbolTablePhase.Context, ForegroundCompilerPhase.Context by mainSkieContext {

override val context: SymbolTablePhaseContext = this

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ package co.touchlab.skie.phases
import co.touchlab.skie.kir.descriptor.MutableDescriptorProvider
import co.touchlab.skie.kir.irbuilder.DeclarationBuilder

interface CompilerDependentClassExportPhase :
ClassExportPhase<CompilerDependentClassExportPhase.Context>,
CompilerDependentForegroundPhase<CompilerDependentClassExportPhase.Context> {
interface ClassExportCompilerPhase :
ClassExportPhase<ClassExportCompilerPhase.Context>,
ForegroundCompilerPhase<ClassExportCompilerPhase.Context> {

interface Context : ClassExportPhase.Context, CompilerDependentForegroundPhase.Context {
interface Context : ClassExportPhase.Context, ForegroundCompilerPhase.Context {

override val context: Context

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ package co.touchlab.skie.phases

import co.touchlab.skie.kir.irbuilder.DeclarationBuilder

interface DescriptorModificationPhase : CompilerDependentForegroundPhase<DescriptorModificationPhase.Context> {
interface DescriptorModificationPhase : ForegroundCompilerPhase<DescriptorModificationPhase.Context> {

interface Context : CompilerDependentForegroundPhase.Context {
interface Context : ForegroundCompilerPhase.Context {

override val context: Context

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import org.jetbrains.kotlin.backend.konan.KonanConfig
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
import org.jetbrains.kotlin.konan.target.AppleConfigurables

interface CompilerDependentForegroundPhase<in C : CompilerDependentForegroundPhase.Context> : ForegroundPhase<C> {
interface ForegroundCompilerPhase<in C : ForegroundCompilerPhase.Context> : ForegroundPhase<C> {

interface Context : ForegroundPhase.Context {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import co.touchlab.skie.kir.type.translation.KirDeclarationTypeTranslator
import co.touchlab.skie.kir.type.translation.KirTypeTranslator
import org.jetbrains.kotlin.backend.konan.objcexport.ObjCExportNamer

interface CompilerDependentKirPhase :
KirPhase<CompilerDependentKirPhase.Context>,
CompilerDependentForegroundPhase<CompilerDependentKirPhase.Context> {
interface KirCompilerPhase :
KirPhase<KirCompilerPhase.Context>,
ForegroundCompilerPhase<KirCompilerPhase.Context> {

interface Context : KirPhase.Context, CompilerDependentForegroundPhase.Context {
interface Context : KirPhase.Context, ForegroundCompilerPhase.Context {

override val context: Context

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import org.jetbrains.kotlin.backend.common.extensions.IrPluginContext
import org.jetbrains.kotlin.ir.IrBuiltIns
import org.jetbrains.kotlin.ir.declarations.IrModuleFragment

interface KotlinIrPhase : CompilerDependentForegroundPhase<KotlinIrPhase.Context> {
interface KotlinIrPhase : ForegroundCompilerPhase<KotlinIrPhase.Context> {

interface Context : CompilerDependentForegroundPhase.Context {
interface Context : ForegroundCompilerPhase.Context {

override val context: Context

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package co.touchlab.skie.phases

import co.touchlab.skie.kir.descriptor.DescriptorKirProvider

interface LinkCompilerPhase :
LinkPhase<LinkCompilerPhase.Context>,
ForegroundCompilerPhase<LinkCompilerPhase.Context> {

interface Context : LinkPhase.Context, ForegroundCompilerPhase.Context {

override val context: Context

val descriptorKirProvider: DescriptorKirProvider
}
}
Loading

0 comments on commit 7801962

Please sign in to comment.