[IR] Introduce new IdSignatures
FileSignature, CompositeSignature, LocalSignature They are needed to make possible reference any non-local declaration via signature, including private signature, type parameters and so on. - Support those new signatures in proto and klibs - Rename `isPublic` -> `isPubliclyVisible` due to changed semantic - Fix FIR - clean up code
This commit is contained in:
committed by
TeamCityServer
parent
7139785036
commit
6cdac22a23
+1
-2
@@ -16,7 +16,6 @@ import org.jetbrains.kotlin.ir.declarations.IrClass
|
||||
import org.jetbrains.kotlin.ir.declarations.IrProperty
|
||||
import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
|
||||
import org.jetbrains.kotlin.ir.symbols.IrTypeParameterSymbol
|
||||
import org.jetbrains.kotlin.ir.symbols.isPublicApi
|
||||
import org.jetbrains.kotlin.ir.types.IrType
|
||||
import org.jetbrains.kotlin.ir.types.classifierOrFail
|
||||
import org.jetbrains.kotlin.ir.types.makeNullable
|
||||
@@ -300,7 +299,7 @@ private object IrTypeInlineClassesSupport : InlineClassesSupport<IrClass, IrType
|
||||
|
||||
override fun getNativePointedSuperclass(clazz: IrClass): IrClass? {
|
||||
var superClass: IrClass? = clazz
|
||||
while (superClass != null && (!superClass.symbol.isPublicApi || InteropIdSignatures.nativePointed != superClass.symbol.signature))
|
||||
while (superClass != null && InteropIdSignatures.nativePointed != superClass.symbol.signature)
|
||||
superClass = superClass.getSuperClassNotAny()
|
||||
return superClass
|
||||
}
|
||||
|
||||
+3
-5
@@ -14,7 +14,6 @@ import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor
|
||||
import org.jetbrains.kotlin.incremental.components.NoLookupLocation
|
||||
import org.jetbrains.kotlin.ir.declarations.*
|
||||
import org.jetbrains.kotlin.ir.expressions.IrConstructorCall
|
||||
import org.jetbrains.kotlin.ir.symbols.isPublicApi
|
||||
import org.jetbrains.kotlin.ir.types.classOrNull
|
||||
import org.jetbrains.kotlin.ir.types.getPublicSignature
|
||||
import org.jetbrains.kotlin.ir.util.*
|
||||
@@ -59,7 +58,7 @@ private fun IrClass.selfOrAnySuperClass(pred: (IrClass) -> Boolean): Boolean {
|
||||
}
|
||||
|
||||
internal fun IrClass.isObjCClass() = this.packageFqName != interopPackageName &&
|
||||
selfOrAnySuperClass { it.symbol.isPublicApi && objCObjectIdSignature == it.symbol.signature }
|
||||
selfOrAnySuperClass { objCObjectIdSignature == it.symbol.signature }
|
||||
|
||||
fun ClassDescriptor.isExternalObjCClass(): Boolean = this.isObjCClass() &&
|
||||
this.parentsWithSelf.filterIsInstance<ClassDescriptor>().any {
|
||||
@@ -78,11 +77,10 @@ fun ClassDescriptor.isObjCMetaClass(): Boolean = this.getAllSuperClassifiers().a
|
||||
}
|
||||
|
||||
fun IrClass.isObjCMetaClass(): Boolean = selfOrAnySuperClass {
|
||||
it.symbol.isPublicApi && objCClassIdSignature == it.symbol.signature
|
||||
objCClassIdSignature == it.symbol.signature
|
||||
}
|
||||
|
||||
fun IrClass.isObjCProtocolClass(): Boolean =
|
||||
symbol.isPublicApi && objCProtocolIdSignature == symbol.signature
|
||||
fun IrClass.isObjCProtocolClass(): Boolean = objCProtocolIdSignature == symbol.signature
|
||||
|
||||
fun ClassDescriptor.isObjCProtocolClass(): Boolean =
|
||||
this.fqNameSafe == objCProtocolFqName
|
||||
|
||||
+3
-2
@@ -10,8 +10,9 @@ import org.jetbrains.kotlin.backend.konan.MemoryModel
|
||||
import org.jetbrains.kotlin.backend.konan.llvm.*
|
||||
import org.jetbrains.kotlin.backend.konan.lower.ExpectToActualDefaultValueCopier
|
||||
import org.jetbrains.kotlin.backend.konan.objcexport.ObjCExport
|
||||
import org.jetbrains.kotlin.backend.konan.serialization.*
|
||||
import org.jetbrains.kotlin.cli.common.messages.AnalyzerWithCompilerReport
|
||||
import org.jetbrains.kotlin.backend.konan.serialization.KonanIdSignaturer
|
||||
import org.jetbrains.kotlin.backend.konan.serialization.KonanIrModuleSerializer
|
||||
import org.jetbrains.kotlin.backend.konan.serialization.KonanManglerDesc
|
||||
import org.jetbrains.kotlin.config.CommonConfigurationKeys
|
||||
import org.jetbrains.kotlin.config.languageVersionSettings
|
||||
import org.jetbrains.kotlin.ir.IrElement
|
||||
|
||||
+5
-3
@@ -5,10 +5,11 @@
|
||||
|
||||
package org.jetbrains.kotlin.backend.konan.llvm
|
||||
|
||||
import kotlinx.cinterop.*
|
||||
import kotlinx.cinterop.toCValues
|
||||
import llvm.*
|
||||
import org.jetbrains.kotlin.backend.konan.*
|
||||
import org.jetbrains.kotlin.backend.konan.descriptors.*
|
||||
import org.jetbrains.kotlin.backend.konan.descriptors.ClassLayoutBuilder
|
||||
import org.jetbrains.kotlin.backend.konan.descriptors.isTypedIntrinsic
|
||||
import org.jetbrains.kotlin.backend.konan.ir.*
|
||||
import org.jetbrains.kotlin.ir.IrElement
|
||||
import org.jetbrains.kotlin.ir.declarations.*
|
||||
@@ -18,6 +19,7 @@ import org.jetbrains.kotlin.ir.visitors.acceptChildrenVoid
|
||||
import org.jetbrains.kotlin.library.KotlinLibrary
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import kotlin.collections.set
|
||||
|
||||
internal fun createLlvmDeclarations(context: Context): LlvmDeclarations {
|
||||
val generator = DeclarationsGeneratorVisitor(context)
|
||||
@@ -107,7 +109,7 @@ private class DeclarationsGeneratorVisitor(override val context: Context) :
|
||||
}
|
||||
}
|
||||
|
||||
val objectNamer = Namer("object-")
|
||||
private val objectNamer = Namer("object-")
|
||||
|
||||
private fun getLocalName(parent: FqName, declaration: IrDeclaration): Name {
|
||||
if (declaration.isAnonymousObject) {
|
||||
|
||||
+7
-5
@@ -1,5 +1,6 @@
|
||||
package org.jetbrains.kotlin.backend.konan.serialization
|
||||
|
||||
import org.jetbrains.kotlin.backend.common.serialization.mangle.SpecialDeclarationType
|
||||
import org.jetbrains.kotlin.backend.common.serialization.signature.IdSignatureDescriptor
|
||||
import org.jetbrains.kotlin.backend.konan.descriptors.isFromInteropLibrary
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
@@ -9,12 +10,13 @@ import org.jetbrains.kotlin.resolve.descriptorUtil.module
|
||||
|
||||
class KonanIdSignaturer(private val mangler: KotlinMangler.DescriptorMangler) : IdSignatureDescriptor(mangler) {
|
||||
|
||||
override fun createSignatureBuilder(): DescriptorBasedSignatureBuilder =
|
||||
KonanDescriptorBasedSignatureBuilder(mangler)
|
||||
override fun createSignatureBuilder(type: SpecialDeclarationType): DescriptorBasedSignatureBuilder =
|
||||
KonanDescriptorBasedSignatureBuilder(mangler, type)
|
||||
|
||||
private class KonanDescriptorBasedSignatureBuilder(
|
||||
mangler: KotlinMangler.DescriptorMangler
|
||||
) : DescriptorBasedSignatureBuilder(mangler) {
|
||||
private inner class KonanDescriptorBasedSignatureBuilder(
|
||||
mangler: KotlinMangler.DescriptorMangler,
|
||||
type: SpecialDeclarationType
|
||||
) : DescriptorBasedSignatureBuilder(mangler, type) {
|
||||
|
||||
/**
|
||||
* We need a way to distinguish interop declarations from usual ones
|
||||
|
||||
+2
-2
@@ -131,7 +131,7 @@ internal class KonanIrLinker(
|
||||
private fun IdSignature.isInteropSignature(): Boolean = IdSignature.Flags.IS_NATIVE_INTEROP_LIBRARY.test()
|
||||
|
||||
override fun contains(idSig: IdSignature): Boolean {
|
||||
if (idSig.isPublic) {
|
||||
if (idSig.isPubliclyVisible) {
|
||||
if (idSig.isInteropSignature()) {
|
||||
// TODO: add descriptor cache??
|
||||
return descriptorByIdSignatureFinder.findDescriptorBySignature(idSig) != null
|
||||
@@ -178,7 +178,7 @@ internal class KonanIrLinker(
|
||||
private val declaredDeclaration = mutableMapOf<IdSignature, IrClass>()
|
||||
|
||||
private fun IdSignature.isForwardDeclarationSignature(): Boolean {
|
||||
if (isPublic) {
|
||||
if (isPubliclyVisible) {
|
||||
return packageFqName().run {
|
||||
startsWith(C_NAMES_NAME) || startsWith(OBJC_NAMES_NAME)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user