From 95433e8a82aec15b07e42545c31b42cd146b5395 Mon Sep 17 00:00:00 2001 From: Alexander Gorshenev Date: Wed, 30 Nov 2016 15:38:24 +0300 Subject: [PATCH] Moved a couple more Konan specific annotations to "konan" package --- .../kotlin/backend/konan/llvm/NameUtils.kt | 4 ++-- .../kotlin/backend/konan/llvm/RTTIGenerator.kt | 2 +- runtime/src/main/kotlin/konan/Annotations.kt | 18 ++++++++++++++++++ runtime/src/main/kotlin/kotlin/Annotations.kt | 17 ----------------- runtime/src/main/kotlin/kotlin/io/Console.kt | 8 ++++---- 5 files changed, 25 insertions(+), 24 deletions(-) diff --git a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/NameUtils.kt b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/NameUtils.kt index c16ab585969..8350886c90a 100644 --- a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/NameUtils.kt +++ b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/NameUtils.kt @@ -12,7 +12,7 @@ import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.types.TypeUtils -private val symbolNameAnnotation = FqName("kotlin.SymbolName") +private val symbolNameAnnotation = FqName("konan.SymbolName") fun typeToHashString(type: KotlinType): String { if (TypeUtils.isTypeParameter(type)) return "GENERIC" @@ -76,4 +76,4 @@ internal val ClassDescriptor.typeInfoSymbolName: String get() = "ktype:" + this.fqNameSafe.toString() internal val PropertyDescriptor.symbolName:String -get() = "kvar:${this.containingDeclaration.name.asString()}.${this.name.asString()}" \ No newline at end of file +get() = "kvar:${this.containingDeclaration.name.asString()}.${this.name.asString()}" diff --git a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/RTTIGenerator.kt b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/RTTIGenerator.kt index 37af81ad67b..3ded8146712 100644 --- a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/RTTIGenerator.kt +++ b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/RTTIGenerator.kt @@ -111,7 +111,7 @@ internal class RTTIGenerator(override val context: Context) : ContextUtils { } private fun exportTypeInfoIfRequired(classDesc: ClassDescriptor, typeInfoGlobal: LLVMValueRef?) { - val annot = classDesc.annotations.findAnnotation(FqName("kotlin.ExportTypeInfo")) + val annot = classDesc.annotations.findAnnotation(FqName("konan.ExportTypeInfo")) if (annot != null) { val nameValue = annot.allValueArguments.values.single() as StringValue // TODO: use LLVMAddAlias? diff --git a/runtime/src/main/kotlin/konan/Annotations.kt b/runtime/src/main/kotlin/konan/Annotations.kt index 59002456966..d322e5d4fe9 100644 --- a/runtime/src/main/kotlin/konan/Annotations.kt +++ b/runtime/src/main/kotlin/konan/Annotations.kt @@ -1,5 +1,23 @@ package konan +/** + * Forces the compiler to use specified symbol name for the target `external` function. + * + * TODO: changing symbol name breaks the binary compatibility, + * so it should probably be allowed on `internal` and `private` functions only. + */ +//@Target(AnnotationTarget.FUNCTION) +//@Retention(AnnotationRetention.SOURCE) +annotation class SymbolName(val name: String) + +/** + * Exports the TypeInfo of this class by given name to use it from runtime. + */ +//@Target(AnnotationTarget.CLASS) +//@Retention(AnnotationRetention.SOURCE) +annotation class ExportTypeInfo(val name: String) + + /** * Preserve the function entry point during global optimizations */ diff --git a/runtime/src/main/kotlin/kotlin/Annotations.kt b/runtime/src/main/kotlin/kotlin/Annotations.kt index 15ee8fc93c2..8d85ea32172 100644 --- a/runtime/src/main/kotlin/kotlin/Annotations.kt +++ b/runtime/src/main/kotlin/kotlin/Annotations.kt @@ -2,23 +2,6 @@ package kotlin // TODO: shouldn't these annotation be located in 'kotlin_native.internal' package? -/** - * Forces the compiler to use specified symbol name for the target `external` function. - * - * TODO: changing symbol name breaks the binary compatibility, - * so it should probably be allowed on `internal` and `private` functions only. - */ -//@Target(AnnotationTarget.FUNCTION) -//@Retention(AnnotationRetention.SOURCE) -annotation class SymbolName(val name: String) - -/** - * Exports the TypeInfo of this class by given name to use it from runtime. - */ -//@Target(AnnotationTarget.CLASS) -//@Retention(AnnotationRetention.SOURCE) -annotation class ExportTypeInfo(val name: String) - /** * Suppresses the given compilation warnings in the annotated element. * @property names names of the compiler diagnostics to suppress. diff --git a/runtime/src/main/kotlin/kotlin/io/Console.kt b/runtime/src/main/kotlin/kotlin/io/Console.kt index 2e9611a14d8..51d6af4b6be 100644 --- a/runtime/src/main/kotlin/kotlin/io/Console.kt +++ b/runtime/src/main/kotlin/kotlin/io/Console.kt @@ -1,6 +1,6 @@ package kotlin.io -@kotlin.SymbolName("Kotlin_io_Console_print") +@SymbolName("Kotlin_io_Console_print") external public fun print(message: String) /* TODO: use something like that. @@ -39,7 +39,7 @@ public fun print(message: Boolean) { print(message.toString()) } -@kotlin.SymbolName("Kotlin_io_Console_println") +@SymbolName("Kotlin_io_Console_println") external public fun println(message: String) // TODO: enable, once override by name is implemented. @@ -79,8 +79,8 @@ public fun println(message: T) { print(message.toString()) } */ -@kotlin.SymbolName("Kotlin_io_Console_println0") +@SymbolName("Kotlin_io_Console_println0") external public fun println() -@kotlin.SymbolName("Kotlin_io_Console_readLine") +@SymbolName("Kotlin_io_Console_readLine") external public fun readLine(): String