[K/N] Move KonanMangler to a new common module
^KT-61248 Fixed
This commit is contained in:
committed by
teamcity
parent
d1127f1a31
commit
ddfd94b3b2
@@ -81,6 +81,7 @@
|
||||
/compiler/ir/serialization.common/ "Kotlin Native"
|
||||
/compiler/ir/serialization.js/ "Kotlin JS"
|
||||
/compiler/ir/serialization.jvm/ "Kotlin JVM"
|
||||
/compiler/ir/serialization.native/ "Kotlin Native"
|
||||
/compiler/javac-wrapper/ "Kotlin Compiler Core"
|
||||
/compiler/light-classes/ "Kotlin IDE Analysis Core"
|
||||
/compiler/plugin-api/ "Kotlin Compiler Core"
|
||||
|
||||
@@ -108,6 +108,7 @@ val irCompilerModules = arrayOf(
|
||||
":compiler:ir.serialization.common",
|
||||
":compiler:ir.serialization.js",
|
||||
":compiler:ir.serialization.jvm",
|
||||
":compiler:ir.serialization.native",
|
||||
":compiler:ir.objcinterop",
|
||||
":compiler:ir.backend.common",
|
||||
":compiler:ir.interpreter",
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
## KLIB serialization: Kotlin/Native
|
||||
|
||||
This module contains Kotlin/Native-specific classes related to serializing IR to KLIBs.
|
||||
@@ -0,0 +1,18 @@
|
||||
plugins {
|
||||
kotlin("jvm")
|
||||
id("jps-compatible")
|
||||
}
|
||||
|
||||
dependencies {
|
||||
api(project(":compiler:ir.tree"))
|
||||
api(project(":compiler:ir.serialization.common"))
|
||||
|
||||
implementation(project(":compiler:ir.objcinterop"))
|
||||
implementation(project(":core:compiler.common.native"))
|
||||
|
||||
compileOnly(intellijCore())
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
"main" { projectDefault() }
|
||||
}
|
||||
+20
-44
@@ -1,3 +1,8 @@
|
||||
/*
|
||||
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.backend.konan.serialization
|
||||
|
||||
import org.jetbrains.kotlin.backend.common.serialization.mangle.KotlinExportChecker
|
||||
@@ -9,13 +14,25 @@ import org.jetbrains.kotlin.backend.common.serialization.mangle.descriptor.Descr
|
||||
import org.jetbrains.kotlin.backend.common.serialization.mangle.ir.IrBasedKotlinManglerImpl
|
||||
import org.jetbrains.kotlin.backend.common.serialization.mangle.ir.IrExportCheckerVisitor
|
||||
import org.jetbrains.kotlin.backend.common.serialization.mangle.ir.IrMangleComputer
|
||||
import org.jetbrains.kotlin.backend.konan.*
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI
|
||||
import org.jetbrains.kotlin.ir.declarations.*
|
||||
import org.jetbrains.kotlin.ir.objcinterop.*
|
||||
import org.jetbrains.kotlin.ir.types.getClass
|
||||
import org.jetbrains.kotlin.ir.util.hasAnnotation
|
||||
import org.jetbrains.kotlin.name.NativeRuntimeNames
|
||||
import org.jetbrains.kotlin.name.NativeStandardInteropNames
|
||||
|
||||
private val annotationsToTreatAsExported = listOf(
|
||||
NativeRuntimeNames.Annotations.symbolNameClassId,
|
||||
NativeRuntimeNames.Annotations.gcUnsafeCallClassId,
|
||||
NativeRuntimeNames.Annotations.exportForCppRuntimeClassId,
|
||||
NativeRuntimeNames.Annotations.cNameClassId,
|
||||
NativeRuntimeNames.Annotations.exportForCompilerClassId,
|
||||
)
|
||||
|
||||
private val IrConstructor.isObjCConstructor: Boolean
|
||||
get() = hasAnnotation(NativeStandardInteropNames.objCConstructorClassId)
|
||||
|
||||
abstract class AbstractKonanIrMangler(
|
||||
private val withReturnType: Boolean,
|
||||
@@ -29,28 +46,7 @@ abstract class AbstractKonanIrMangler(
|
||||
override fun IrDeclaration.isPlatformSpecificExport(): Boolean {
|
||||
if (this is IrSimpleFunction) if (isFakeOverride) return false
|
||||
|
||||
// TODO: revise
|
||||
if (annotations.hasAnnotation(RuntimeNames.symbolNameAnnotation)) {
|
||||
// Treat any `@SymbolName` declaration as exported.
|
||||
return true
|
||||
}
|
||||
if (annotations.hasAnnotation(KonanFqNames.gcUnsafeCall)) {
|
||||
// Treat any `@GCUnsafeCall` declaration as exported.
|
||||
return true
|
||||
}
|
||||
if (annotations.hasAnnotation(RuntimeNames.exportForCppRuntime)) {
|
||||
// Treat any `@ExportForCppRuntime` declaration as exported.
|
||||
return true
|
||||
}
|
||||
if (annotations.hasAnnotation(RuntimeNames.cnameAnnotation)) {
|
||||
// Treat `@CName` declaration as exported.
|
||||
return true
|
||||
}
|
||||
if (annotations.hasAnnotation(RuntimeNames.exportForCompilerAnnotation)) {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
return annotationsToTreatAsExported.any(this::hasAnnotation)
|
||||
}
|
||||
|
||||
private inner class KonanIrExportChecker(compatibleMode: Boolean) : IrExportCheckerVisitor(compatibleMode) {
|
||||
@@ -125,28 +121,8 @@ abstract class AbstractKonanDescriptorMangler : DescriptorBasedKotlinManglerImpl
|
||||
if (this is SimpleFunctionDescriptor) {
|
||||
if (kind == CallableMemberDescriptor.Kind.FAKE_OVERRIDE) return false
|
||||
}
|
||||
// TODO: revise
|
||||
if (annotations.hasAnnotation(RuntimeNames.symbolNameAnnotation)) {
|
||||
// Treat any `@SymbolName` declaration as exported.
|
||||
return true
|
||||
}
|
||||
if (annotations.hasAnnotation(KonanFqNames.gcUnsafeCall)) {
|
||||
// Treat any `@GCUnsafeCall` declaration as exported.
|
||||
return true
|
||||
}
|
||||
if (annotations.hasAnnotation(RuntimeNames.exportForCppRuntime)) {
|
||||
// Treat any `@ExportForCppRuntime` declaration as exported.
|
||||
return true
|
||||
}
|
||||
if (annotations.hasAnnotation(RuntimeNames.cnameAnnotation)) {
|
||||
// Treat `@CName` declaration as exported.
|
||||
return true
|
||||
}
|
||||
if (annotations.hasAnnotation(RuntimeNames.exportForCompilerAnnotation)) {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
return annotationsToTreatAsExported.any { annotations.hasAnnotation(it.asSingleFqName()) }
|
||||
}
|
||||
|
||||
|
||||
@@ -171,6 +171,7 @@ dependencies {
|
||||
compilerApi project(":kotlin-util-klib")
|
||||
compilerApi project(":kotlin-util-klib-metadata")
|
||||
compilerApi project(":compiler:ir.serialization.common")
|
||||
compilerApi project(":compiler:ir.serialization.native")
|
||||
compilerApi project(":compiler:fir:fir-serialization")
|
||||
compilerApi project(":compiler:fir:native")
|
||||
compilerApi project(":compiler:ir.psi2ir")
|
||||
|
||||
@@ -69,6 +69,7 @@ include ":benchmarks",
|
||||
":compiler:ir.serialization.common",
|
||||
":compiler:ir.serialization.jvm",
|
||||
":compiler:ir.serialization.js",
|
||||
":compiler:ir.serialization.native",
|
||||
":compiler:ir.interpreter",
|
||||
":compiler:backend.js",
|
||||
":compiler:backend.wasm",
|
||||
@@ -684,6 +685,7 @@ project(':compiler:backend.jvm.entrypoint').projectDir = "$rootDir/compiler/ir/b
|
||||
project(':compiler:ir.serialization.common').projectDir = "$rootDir/compiler/ir/serialization.common" as File
|
||||
project(':compiler:ir.serialization.jvm').projectDir = "$rootDir/compiler/ir/serialization.jvm" as File
|
||||
project(':compiler:ir.serialization.js').projectDir = "$rootDir/compiler/ir/serialization.js" as File
|
||||
project(':compiler:ir.serialization.native').projectDir = "$rootDir/compiler/ir/serialization.native" as File
|
||||
project(':compiler:ir.interpreter').projectDir = "$rootDir/compiler/ir/ir.interpreter" as File
|
||||
project(':kotlin-util-io').projectDir = "$rootDir/compiler/util-io" as File
|
||||
project(':kotlin-util-klib').projectDir = "$rootDir/compiler/util-klib" as File
|
||||
|
||||
Reference in New Issue
Block a user