[klib tool] Add option to print ir
Dumping the IR from a klib is useful for debugging klib compilations. ^KT-58877
This commit is contained in:
@@ -52,6 +52,7 @@ fun IrFile.dumpTreesFromLineNumber(lineNumber: Int, options: DumpIrTreeOptions =
|
|||||||
* the file facade class (see [IrDeclarationOrigin.FILE_CLASS])
|
* the file facade class (see [IrDeclarationOrigin.FILE_CLASS])
|
||||||
* @property printFlagsInDeclarationReferences If `false`, flags like `fake_override`, `inline` etc. are not printed in rendered declaration
|
* @property printFlagsInDeclarationReferences If `false`, flags like `fake_override`, `inline` etc. are not printed in rendered declaration
|
||||||
* references.
|
* references.
|
||||||
|
* @property printSignatures Whether to print signatures for nodes that have public signatures
|
||||||
*/
|
*/
|
||||||
data class DumpIrTreeOptions(
|
data class DumpIrTreeOptions(
|
||||||
val normalizeNames: Boolean = false,
|
val normalizeNames: Boolean = false,
|
||||||
@@ -59,6 +60,7 @@ data class DumpIrTreeOptions(
|
|||||||
val verboseErrorTypes: Boolean = true,
|
val verboseErrorTypes: Boolean = true,
|
||||||
val printFacadeClassInFqNames: Boolean = true,
|
val printFacadeClassInFqNames: Boolean = true,
|
||||||
val printFlagsInDeclarationReferences: Boolean = true,
|
val printFlagsInDeclarationReferences: Boolean = true,
|
||||||
|
val printSignatures: Boolean = false,
|
||||||
)
|
)
|
||||||
|
|
||||||
private fun IrFile.shouldSkipDump(): Boolean {
|
private fun IrFile.shouldSkipDump(): Boolean {
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ class RenderIrElementVisitor(private val options: DumpIrTreeOptions = DumpIrTree
|
|||||||
renderClassWithRenderer(declaration, null, options)
|
renderClassWithRenderer(declaration, null, options)
|
||||||
|
|
||||||
override fun visitEnumEntry(declaration: IrEnumEntry, data: Nothing?) =
|
override fun visitEnumEntry(declaration: IrEnumEntry, data: Nothing?) =
|
||||||
renderEnumEntry(declaration)
|
renderEnumEntry(declaration, options)
|
||||||
|
|
||||||
override fun visitField(declaration: IrField, data: Nothing?) =
|
override fun visitField(declaration: IrField, data: Nothing?) =
|
||||||
renderField(declaration, null, options)
|
renderField(declaration, null, options)
|
||||||
@@ -260,7 +260,9 @@ class RenderIrElementVisitor(private val options: DumpIrTreeOptions = DumpIrTree
|
|||||||
override fun visitSimpleFunction(declaration: IrSimpleFunction, data: Nothing?): String =
|
override fun visitSimpleFunction(declaration: IrSimpleFunction, data: Nothing?): String =
|
||||||
declaration.runTrimEnd {
|
declaration.runTrimEnd {
|
||||||
"FUN ${renderOriginIfNonTrivial()}" +
|
"FUN ${renderOriginIfNonTrivial()}" +
|
||||||
"name:$name visibility:$visibility modality:$modality " +
|
"name:$name " +
|
||||||
|
renderSignatureIfEnabled(options.printSignatures) +
|
||||||
|
"visibility:$visibility modality:$modality " +
|
||||||
renderTypeParameters() + " " +
|
renderTypeParameters() + " " +
|
||||||
renderValueParameterTypes() + " " +
|
renderValueParameterTypes() + " " +
|
||||||
"returnType:${renderReturnType(this@RenderIrElementVisitor, options)} " +
|
"returnType:${renderReturnType(this@RenderIrElementVisitor, options)} " +
|
||||||
@@ -277,6 +279,7 @@ class RenderIrElementVisitor(private val options: DumpIrTreeOptions = DumpIrTree
|
|||||||
override fun visitConstructor(declaration: IrConstructor, data: Nothing?): String =
|
override fun visitConstructor(declaration: IrConstructor, data: Nothing?): String =
|
||||||
declaration.runTrimEnd {
|
declaration.runTrimEnd {
|
||||||
"CONSTRUCTOR ${renderOriginIfNonTrivial()}" +
|
"CONSTRUCTOR ${renderOriginIfNonTrivial()}" +
|
||||||
|
renderSignatureIfEnabled(options.printSignatures) +
|
||||||
"visibility:$visibility " +
|
"visibility:$visibility " +
|
||||||
renderTypeParameters() + " " +
|
renderTypeParameters() + " " +
|
||||||
renderValueParameterTypes() + " " +
|
renderValueParameterTypes() + " " +
|
||||||
@@ -287,7 +290,9 @@ class RenderIrElementVisitor(private val options: DumpIrTreeOptions = DumpIrTree
|
|||||||
override fun visitProperty(declaration: IrProperty, data: Nothing?): String =
|
override fun visitProperty(declaration: IrProperty, data: Nothing?): String =
|
||||||
declaration.runTrimEnd {
|
declaration.runTrimEnd {
|
||||||
"PROPERTY ${renderOriginIfNonTrivial()}" +
|
"PROPERTY ${renderOriginIfNonTrivial()}" +
|
||||||
"name:$name visibility:$visibility modality:$modality " +
|
"name:$name " +
|
||||||
|
renderSignatureIfEnabled(options.printSignatures) +
|
||||||
|
"visibility:$visibility modality:$modality " +
|
||||||
renderPropertyFlags()
|
renderPropertyFlags()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -303,7 +308,7 @@ class RenderIrElementVisitor(private val options: DumpIrTreeOptions = DumpIrTree
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun visitEnumEntry(declaration: IrEnumEntry, data: Nothing?): String =
|
override fun visitEnumEntry(declaration: IrEnumEntry, data: Nothing?): String =
|
||||||
renderEnumEntry(declaration)
|
renderEnumEntry(declaration, options)
|
||||||
|
|
||||||
override fun visitAnonymousInitializer(declaration: IrAnonymousInitializer, data: Nothing?): String =
|
override fun visitAnonymousInitializer(declaration: IrAnonymousInitializer, data: Nothing?): String =
|
||||||
"ANONYMOUS_INITIALIZER isStatic=${declaration.isStatic}"
|
"ANONYMOUS_INITIALIZER isStatic=${declaration.isStatic}"
|
||||||
@@ -330,7 +335,9 @@ class RenderIrElementVisitor(private val options: DumpIrTreeOptions = DumpIrTree
|
|||||||
override fun visitTypeAlias(declaration: IrTypeAlias, data: Nothing?): String =
|
override fun visitTypeAlias(declaration: IrTypeAlias, data: Nothing?): String =
|
||||||
declaration.run {
|
declaration.run {
|
||||||
"TYPEALIAS ${declaration.renderOriginIfNonTrivial()}" +
|
"TYPEALIAS ${declaration.renderOriginIfNonTrivial()}" +
|
||||||
"name:$name visibility:$visibility expandedType:${expandedType.render()}" +
|
"name:$name " +
|
||||||
|
renderSignatureIfEnabled(options.printSignatures) +
|
||||||
|
"visibility:$visibility expandedType:${expandedType.render()}" +
|
||||||
renderTypeAliasFlags()
|
renderTypeAliasFlags()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -540,6 +547,9 @@ internal fun DescriptorRenderer.renderDescriptor(descriptor: DeclarationDescript
|
|||||||
else
|
else
|
||||||
render(descriptor)
|
render(descriptor)
|
||||||
|
|
||||||
|
private fun IrDeclarationWithName.renderSignatureIfEnabled(printSignatures: Boolean): String =
|
||||||
|
if (printSignatures) symbol.signature?.let { "signature:${it.render()} " }.orEmpty() else ""
|
||||||
|
|
||||||
internal fun IrDeclaration.renderOriginIfNonTrivial(): String =
|
internal fun IrDeclaration.renderOriginIfNonTrivial(): String =
|
||||||
if (origin != IrDeclarationOrigin.DEFINED) "$origin " else ""
|
if (origin != IrDeclarationOrigin.DEFINED) "$origin " else ""
|
||||||
|
|
||||||
@@ -872,17 +882,22 @@ private fun StringBuilder.renderAsAnnotationArgument(irElement: IrElement?, rend
|
|||||||
private fun renderClassWithRenderer(declaration: IrClass, renderer: RenderIrElementVisitor?, options: DumpIrTreeOptions) =
|
private fun renderClassWithRenderer(declaration: IrClass, renderer: RenderIrElementVisitor?, options: DumpIrTreeOptions) =
|
||||||
declaration.runTrimEnd {
|
declaration.runTrimEnd {
|
||||||
"CLASS ${renderOriginIfNonTrivial()}" +
|
"CLASS ${renderOriginIfNonTrivial()}" +
|
||||||
"$kind name:$name modality:$modality visibility:$visibility " +
|
"$kind name:$name " +
|
||||||
|
renderSignatureIfEnabled(options.printSignatures) +
|
||||||
|
"modality:$modality visibility:$visibility " +
|
||||||
renderClassFlags() +
|
renderClassFlags() +
|
||||||
"superTypes:[${superTypes.joinToString(separator = "; ") { it.renderTypeWithRenderer(renderer, options) }}]"
|
"superTypes:[${superTypes.joinToString(separator = "; ") { it.renderTypeWithRenderer(renderer, options) }}]"
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun renderEnumEntry(declaration: IrEnumEntry) = declaration.runTrimEnd {
|
private fun renderEnumEntry(declaration: IrEnumEntry, options: DumpIrTreeOptions) = declaration.runTrimEnd {
|
||||||
"ENUM_ENTRY ${renderOriginIfNonTrivial()}name:$name"
|
"ENUM_ENTRY " +
|
||||||
|
renderOriginIfNonTrivial() +
|
||||||
|
"name:$name " +
|
||||||
|
renderSignatureIfEnabled(options.printSignatures)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun renderField(declaration: IrField, renderer: RenderIrElementVisitor?, options: DumpIrTreeOptions) = declaration.runTrimEnd {
|
private fun renderField(declaration: IrField, renderer: RenderIrElementVisitor?, options: DumpIrTreeOptions) = declaration.runTrimEnd {
|
||||||
"FIELD ${renderOriginIfNonTrivial()}name:$name type:${
|
"FIELD ${renderOriginIfNonTrivial()}name:$name ${renderSignatureIfEnabled(options.printSignatures)}type:${
|
||||||
type.renderTypeWithRenderer(
|
type.renderTypeWithRenderer(
|
||||||
renderer,
|
renderer,
|
||||||
options
|
options
|
||||||
@@ -894,6 +909,7 @@ private fun renderTypeParameter(declaration: IrTypeParameter, renderer: RenderIr
|
|||||||
declaration.runTrimEnd {
|
declaration.runTrimEnd {
|
||||||
"TYPE_PARAMETER ${renderOriginIfNonTrivial()}" +
|
"TYPE_PARAMETER ${renderOriginIfNonTrivial()}" +
|
||||||
"name:$name index:$index variance:$variance " +
|
"name:$name index:$index variance:$variance " +
|
||||||
|
renderSignatureIfEnabled(options.printSignatures) +
|
||||||
"superTypes:[${
|
"superTypes:[${
|
||||||
superTypes.joinToString(separator = "; ") {
|
superTypes.joinToString(separator = "; ") {
|
||||||
it.renderTypeWithRenderer(
|
it.renderTypeWithRenderer(
|
||||||
|
|||||||
@@ -6,7 +6,16 @@
|
|||||||
package org.jetbrains.kotlin.cli.klib
|
package org.jetbrains.kotlin.cli.klib
|
||||||
|
|
||||||
// TODO: Extract `library` package as a shared jar?
|
// TODO: Extract `library` package as a shared jar?
|
||||||
|
import org.jetbrains.kotlin.backend.common.linkage.partial.PartialLinkageSupportForLinker
|
||||||
|
import org.jetbrains.kotlin.backend.common.overrides.FakeOverrideBuilder
|
||||||
|
import org.jetbrains.kotlin.backend.common.serialization.BasicIrModuleDeserializer
|
||||||
|
import org.jetbrains.kotlin.backend.common.serialization.DeserializationStrategy
|
||||||
|
import org.jetbrains.kotlin.backend.common.serialization.IrModuleDeserializer
|
||||||
|
import org.jetbrains.kotlin.backend.common.serialization.KotlinIrLinker
|
||||||
import org.jetbrains.kotlin.backend.common.serialization.metadata.DynamicTypeDeserializer
|
import org.jetbrains.kotlin.backend.common.serialization.metadata.DynamicTypeDeserializer
|
||||||
|
import org.jetbrains.kotlin.backend.konan.serialization.KonanIdSignaturer
|
||||||
|
import org.jetbrains.kotlin.backend.konan.serialization.KonanManglerDesc
|
||||||
|
import org.jetbrains.kotlin.backend.konan.serialization.KonanManglerIr
|
||||||
import org.jetbrains.kotlin.builtins.konan.KonanBuiltIns
|
import org.jetbrains.kotlin.builtins.konan.KonanBuiltIns
|
||||||
import org.jetbrains.kotlin.config.ApiVersion
|
import org.jetbrains.kotlin.config.ApiVersion
|
||||||
import org.jetbrains.kotlin.config.LanguageVersion
|
import org.jetbrains.kotlin.config.LanguageVersion
|
||||||
@@ -14,19 +23,29 @@ import org.jetbrains.kotlin.config.LanguageVersionSettingsImpl
|
|||||||
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
|
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
|
||||||
import org.jetbrains.kotlin.descriptors.impl.ModuleDescriptorImpl
|
import org.jetbrains.kotlin.descriptors.impl.ModuleDescriptorImpl
|
||||||
import org.jetbrains.kotlin.descriptors.konan.isNativeStdlib
|
import org.jetbrains.kotlin.descriptors.konan.isNativeStdlib
|
||||||
|
import org.jetbrains.kotlin.ir.IrBuiltIns
|
||||||
|
import org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI
|
||||||
|
import org.jetbrains.kotlin.ir.builders.TranslationPluginContext
|
||||||
|
import org.jetbrains.kotlin.ir.declarations.impl.IrFactoryImpl
|
||||||
|
import org.jetbrains.kotlin.ir.types.IrTypeSystemContextImpl
|
||||||
|
import org.jetbrains.kotlin.ir.util.DumpIrTreeOptions
|
||||||
|
import org.jetbrains.kotlin.ir.util.IrMessageLogger
|
||||||
|
import org.jetbrains.kotlin.ir.util.SymbolTable
|
||||||
|
import org.jetbrains.kotlin.ir.util.dump
|
||||||
import org.jetbrains.kotlin.konan.file.File
|
import org.jetbrains.kotlin.konan.file.File
|
||||||
import org.jetbrains.kotlin.konan.library.KonanLibrary
|
import org.jetbrains.kotlin.konan.library.KonanLibrary
|
||||||
import org.jetbrains.kotlin.konan.library.resolverByName
|
import org.jetbrains.kotlin.konan.library.resolverByName
|
||||||
import org.jetbrains.kotlin.konan.target.Distribution
|
import org.jetbrains.kotlin.konan.target.Distribution
|
||||||
import org.jetbrains.kotlin.konan.target.PlatformManager
|
import org.jetbrains.kotlin.konan.target.PlatformManager
|
||||||
import org.jetbrains.kotlin.konan.util.DependencyDirectories
|
import org.jetbrains.kotlin.konan.util.DependencyDirectories
|
||||||
import org.jetbrains.kotlin.konan.util.DependencyProcessor
|
|
||||||
import org.jetbrains.kotlin.konan.util.KonanHomeProvider
|
import org.jetbrains.kotlin.konan.util.KonanHomeProvider
|
||||||
import org.jetbrains.kotlin.library.KLIB_FILE_EXTENSION_WITH_DOT
|
import org.jetbrains.kotlin.library.*
|
||||||
import org.jetbrains.kotlin.library.metadata.KlibMetadataFactories
|
import org.jetbrains.kotlin.library.metadata.KlibMetadataFactories
|
||||||
import org.jetbrains.kotlin.library.metadata.KlibMetadataProtoBuf
|
import org.jetbrains.kotlin.library.metadata.KlibMetadataProtoBuf
|
||||||
|
import org.jetbrains.kotlin.library.metadata.kotlinLibrary
|
||||||
import org.jetbrains.kotlin.library.metadata.parseModuleHeader
|
import org.jetbrains.kotlin.library.metadata.parseModuleHeader
|
||||||
import org.jetbrains.kotlin.library.unpackZippedKonanLibraryTo
|
import org.jetbrains.kotlin.psi2ir.descriptors.IrBuiltInsOverDescriptors
|
||||||
|
import org.jetbrains.kotlin.psi2ir.generators.TypeTranslatorImpl
|
||||||
import org.jetbrains.kotlin.storage.LockBasedStorageManager
|
import org.jetbrains.kotlin.storage.LockBasedStorageManager
|
||||||
import org.jetbrains.kotlin.util.Logger
|
import org.jetbrains.kotlin.util.Logger
|
||||||
import org.jetbrains.kotlin.util.removeSuffixIfPresent
|
import org.jetbrains.kotlin.util.removeSuffixIfPresent
|
||||||
@@ -39,13 +58,14 @@ fun printUsage() {
|
|||||||
println("where the commands are:")
|
println("where the commands are:")
|
||||||
println("\tinfo\tgeneral information about the library")
|
println("\tinfo\tgeneral information about the library")
|
||||||
println("\tinstall\tinstall the library to the local repository")
|
println("\tinstall\tinstall the library to the local repository")
|
||||||
|
println("\tdump-ir\tprint out the intermediate representation (IR) for the library (to be used for debugging purposes only)")
|
||||||
println("\tcontents\tlist contents of the library")
|
println("\tcontents\tlist contents of the library")
|
||||||
println("\tsignatures\tlist of ID signatures in the library")
|
println("\tsignatures\tlist of ID signatures in the library")
|
||||||
println("\tremove\tremove the library from the local repository")
|
println("\tremove\tremove the library from the local repository")
|
||||||
println("and the options are:")
|
println("and the options are:")
|
||||||
println("\t-repository <path>\twork with the specified repository")
|
println("\t-repository <path>\twork with the specified repository")
|
||||||
println("\t-target <name>\tinspect specifics of the given target")
|
println("\t-target <name>\tinspect specifics of the given target")
|
||||||
println("\t-print-signatures [true|false]\tprint ID signature for every declaration (only for \"contents\" command)")
|
println("\t-print-signatures [true|false]\tprint ID signature for every declaration (only for \"contents\" and \"dump-ir\" commands)")
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun parseArgs(args: Array<String>): Map<String, List<String>> {
|
private fun parseArgs(args: Array<String>): Map<String, List<String>> {
|
||||||
@@ -86,11 +106,18 @@ fun error(text: String): Nothing {
|
|||||||
kotlin.error("error: $text")
|
kotlin.error("error: $text")
|
||||||
}
|
}
|
||||||
|
|
||||||
object KlibToolLogger : Logger {
|
object KlibToolLogger : Logger, IrMessageLogger {
|
||||||
override fun warning(message: String) = org.jetbrains.kotlin.cli.klib.warn(message)
|
override fun warning(message: String) = warn(message)
|
||||||
override fun error(message: String) = org.jetbrains.kotlin.cli.klib.warn(message)
|
override fun error(message: String) = warn(message)
|
||||||
override fun fatal(message: String) = org.jetbrains.kotlin.cli.klib.error(message)
|
override fun fatal(message: String) = org.jetbrains.kotlin.cli.klib.error(message)
|
||||||
override fun log(message: String) = println(message)
|
override fun log(message: String) = println(message)
|
||||||
|
override fun report(severity: IrMessageLogger.Severity, message: String, location: IrMessageLogger.Location?) {
|
||||||
|
when (severity) {
|
||||||
|
IrMessageLogger.Severity.INFO -> log(message)
|
||||||
|
IrMessageLogger.Severity.WARNING -> warning(message)
|
||||||
|
IrMessageLogger.Severity.ERROR -> error(message)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(Dmitrii Krasnov): I'm not sure that we should put konan distribution dir here
|
// TODO(Dmitrii Krasnov): I'm not sure that we should put konan distribution dir here
|
||||||
@@ -165,6 +192,61 @@ class Library(val libraryNameOrPath: String, val requestedRepository: String?, v
|
|||||||
library?.libraryFile?.deleteRecursively()
|
library?.libraryFile?.deleteRecursively()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class KlibToolLinker(
|
||||||
|
module: ModuleDescriptor, irBuiltIns: IrBuiltIns, symbolTable: SymbolTable
|
||||||
|
) : KotlinIrLinker(module, KlibToolLogger, irBuiltIns, symbolTable, emptyList()) {
|
||||||
|
override val fakeOverrideBuilder = FakeOverrideBuilder(
|
||||||
|
linker = this,
|
||||||
|
symbolTable = symbolTable,
|
||||||
|
mangler = KonanManglerIr,
|
||||||
|
typeSystem = IrTypeSystemContextImpl(builtIns),
|
||||||
|
friendModules = emptyMap(),
|
||||||
|
partialLinkageSupport = PartialLinkageSupportForLinker.DISABLED,
|
||||||
|
)
|
||||||
|
override val translationPluginContext: TranslationPluginContext
|
||||||
|
get() = TODO("Not needed for ir dumping")
|
||||||
|
|
||||||
|
override fun createModuleDeserializer(moduleDescriptor: ModuleDescriptor, klib: KotlinLibrary?, strategyResolver: (String) -> DeserializationStrategy): IrModuleDeserializer {
|
||||||
|
return KlibToolModuleDeserializer(moduleDescriptor, klib ?: error("Expecting kotlin library for $moduleDescriptor"), strategyResolver)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun isBuiltInModule(moduleDescriptor: ModuleDescriptor): Boolean {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
inner class KlibToolModuleDeserializer(
|
||||||
|
module: ModuleDescriptor,
|
||||||
|
klib: KotlinLibrary,
|
||||||
|
strategyResolver: (String) -> DeserializationStrategy
|
||||||
|
) : BasicIrModuleDeserializer(
|
||||||
|
this,
|
||||||
|
module,
|
||||||
|
klib,
|
||||||
|
strategyResolver,
|
||||||
|
klib.versions.abiVersion ?: KotlinAbiVersion.CURRENT
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
@OptIn(ObsoleteDescriptorBasedAPI::class)
|
||||||
|
fun ir(output: Appendable, printSignatures: Boolean) {
|
||||||
|
val module = loadModule()
|
||||||
|
if (module.kotlinLibrary.isInterop) error("Deserializing IR from IR-less libraries is not supported yet")
|
||||||
|
val versionSpec = LanguageVersionSettingsImpl(currentLanguageVersion, currentApiVersion)
|
||||||
|
val idSignaturer = KonanIdSignaturer(KonanManglerDesc)
|
||||||
|
val symbolTable = SymbolTable(idSignaturer, IrFactoryImpl)
|
||||||
|
val typeTranslator = TypeTranslatorImpl(symbolTable, versionSpec, module)
|
||||||
|
val irBuiltIns = IrBuiltInsOverDescriptors(module.builtIns, typeTranslator, symbolTable)
|
||||||
|
val linker = KlibToolLinker(module, irBuiltIns, symbolTable)
|
||||||
|
module.allDependencyModules.forEach {
|
||||||
|
linker.deserializeOnlyHeaderModule(it, it.kotlinLibrary)
|
||||||
|
linker.resolveModuleDeserializer(it, null).init()
|
||||||
|
}
|
||||||
|
val irFragment = linker.deserializeFullModule(module, module.kotlinLibrary)
|
||||||
|
linker.resolveModuleDeserializer(module, null).init()
|
||||||
|
linker.modulesWithReachableTopLevels.forEach(IrModuleDeserializer::deserializeReachableDeclarations)
|
||||||
|
output.append(irFragment.dump(DumpIrTreeOptions(printSignatures = printSignatures)))
|
||||||
|
}
|
||||||
|
|
||||||
fun contents(output: Appendable, printSignatures: Boolean) {
|
fun contents(output: Appendable, printSignatures: Boolean) {
|
||||||
val module = loadModule()
|
val module = loadModule()
|
||||||
val signatureRenderer = if (printSignatures) DefaultKlibSignatureRenderer("// ID signature: ") else KlibSignatureRenderer.NO_SIGNATURE
|
val signatureRenderer = if (printSignatures) DefaultKlibSignatureRenderer("// ID signature: ") else KlibSignatureRenderer.NO_SIGNATURE
|
||||||
@@ -231,6 +313,7 @@ fun main(args: Array<String>) {
|
|||||||
val library = Library(command.library, repository, target)
|
val library = Library(command.library, repository, target)
|
||||||
|
|
||||||
when (command.verb) {
|
when (command.verb) {
|
||||||
|
"dump-ir" -> library.ir(System.out, printSignatures)
|
||||||
"contents" -> library.contents(System.out, printSignatures)
|
"contents" -> library.contents(System.out, printSignatures)
|
||||||
"signatures" -> library.signatures(System.out)
|
"signatures" -> library.signatures(System.out)
|
||||||
"info" -> library.info()
|
"info" -> library.info()
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
MODULE_FRAGMENT name:<class.kt>
|
||||||
|
FILE fqName:test fileName:class.kt
|
||||||
|
CLASS CLASS name:A modality:FINAL visibility:public superTypes:[<unbound IrClassPublicSymbolImpl>]
|
||||||
|
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:test.A
|
||||||
|
CONSTRUCTOR visibility:public <> () returnType:test.A [primary]
|
||||||
|
BLOCK_BODY
|
||||||
|
DELEGATING_CONSTRUCTOR_CALL 'UNBOUND IrConstructorPublicSymbolImpl'
|
||||||
|
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:A modality:FINAL visibility:public superTypes:[<unbound IrClassPublicSymbolImpl>]'
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
// FIR_IDENTICAL
|
||||||
|
package test
|
||||||
|
|
||||||
|
class A {
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
MODULE_FRAGMENT name:<class.kt>
|
||||||
|
FILE fqName:test fileName:class.kt
|
||||||
|
CLASS CLASS name:A signature:test/A|null[0] modality:FINAL visibility:public superTypes:[<unbound IrClassPublicSymbolImpl>]
|
||||||
|
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:test.A
|
||||||
|
CONSTRUCTOR signature:test/A.<init>|<init>(){}[0] visibility:public <> () returnType:test.A [primary]
|
||||||
|
BLOCK_BODY
|
||||||
|
DELEGATING_CONSTRUCTOR_CALL 'UNBOUND IrConstructorPublicSymbolImpl'
|
||||||
|
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:A signature:test/A|null[0] modality:FINAL visibility:public superTypes:[<unbound IrClassPublicSymbolImpl>]'
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
MODULE_FRAGMENT name:<constructor.kt>
|
||||||
|
FILE fqName:test fileName:constructor.kt
|
||||||
|
CLASS CLASS name:A modality:FINAL visibility:public superTypes:[<unbound IrClassPublicSymbolImpl>]
|
||||||
|
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:test.A
|
||||||
|
CONSTRUCTOR visibility:public <> (x:<unbound IrClassPublicSymbolImpl>) returnType:test.A [primary]
|
||||||
|
VALUE_PARAMETER name:x index:0 type:<unbound IrClassPublicSymbolImpl>
|
||||||
|
BLOCK_BODY
|
||||||
|
DELEGATING_CONSTRUCTOR_CALL 'UNBOUND IrConstructorPublicSymbolImpl'
|
||||||
|
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:A modality:FINAL visibility:public superTypes:[<unbound IrClassPublicSymbolImpl>]'
|
||||||
|
PROPERTY name:x visibility:public modality:FINAL [val]
|
||||||
|
FIELD PROPERTY_BACKING_FIELD name:x type:<unbound IrClassPublicSymbolImpl> visibility:private [final]
|
||||||
|
EXPRESSION_BODY
|
||||||
|
GET_VAR 'x: <unbound IrClassPublicSymbolImpl> declared in test.A.<init>' type=<unbound IrClassPublicSymbolImpl> origin=INITIALIZE_PROPERTY_FROM_PARAMETER
|
||||||
|
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-x> visibility:public modality:FINAL <> ($this:test.A) returnType:<unbound IrClassPublicSymbolImpl>
|
||||||
|
correspondingProperty: PROPERTY name:x visibility:public modality:FINAL [val]
|
||||||
|
$this: VALUE_PARAMETER name:<this> type:test.A
|
||||||
|
BLOCK_BODY
|
||||||
|
RETURN type=<unbound IrClassPublicSymbolImpl> from='public final fun <get-x> (): <unbound IrClassPublicSymbolImpl> declared in test.A'
|
||||||
|
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:x type:<unbound IrClassPublicSymbolImpl> visibility:private [final]' type=<unbound IrClassPublicSymbolImpl> origin=null
|
||||||
|
receiver: GET_VAR '<this>: test.A declared in test.A.<get-x>' type=test.A origin=null
|
||||||
|
CLASS OBJECT name:Companion modality:FINAL visibility:public [companion] superTypes:[<unbound IrClassPublicSymbolImpl>]
|
||||||
|
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:test.A.Companion
|
||||||
|
CONSTRUCTOR visibility:private <> () returnType:test.A.Companion [primary]
|
||||||
|
BLOCK_BODY
|
||||||
|
DELEGATING_CONSTRUCTOR_CALL 'UNBOUND IrConstructorPublicSymbolImpl'
|
||||||
|
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS OBJECT name:Companion modality:FINAL visibility:public [companion] superTypes:[<unbound IrClassPublicSymbolImpl>]'
|
||||||
|
FUN name:create visibility:public modality:FINAL <> ($this:test.A.Companion, x:<unbound IrClassPublicSymbolImpl>) returnType:test.A
|
||||||
|
$this: VALUE_PARAMETER name:<this> type:test.A.Companion
|
||||||
|
VALUE_PARAMETER name:x index:0 type:<unbound IrClassPublicSymbolImpl>
|
||||||
|
BLOCK_BODY
|
||||||
|
RETURN type=<unbound IrClassPublicSymbolImpl> from='public final fun create (x: <unbound IrClassPublicSymbolImpl>): test.A declared in test.A.Companion'
|
||||||
|
CONSTRUCTOR_CALL 'public constructor <init> (x: <unbound IrClassPublicSymbolImpl>) [primary] declared in test.A' type=test.A origin=null
|
||||||
|
x: CALL 'UNBOUND IrSimpleFunctionPublicSymbolImpl' type=<unbound IrClassPublicSymbolImpl> origin=MUL
|
||||||
|
$this: GET_VAR 'x: <unbound IrClassPublicSymbolImpl> declared in test.A.Companion.create' type=<unbound IrClassPublicSymbolImpl> origin=null
|
||||||
|
1: CONST Int type=<unbound IrClassPublicSymbolImpl> value=2
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
// FIR_IDENTICAL
|
||||||
|
package test
|
||||||
|
|
||||||
|
class A constructor(val x: Int) {
|
||||||
|
companion object {
|
||||||
|
fun create(x: Int): A = A(x * 2)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
MODULE_FRAGMENT name:<constructor.kt>
|
||||||
|
FILE fqName:test fileName:constructor.kt
|
||||||
|
CLASS CLASS name:A signature:test/A|null[0] modality:FINAL visibility:public superTypes:[<unbound IrClassPublicSymbolImpl>]
|
||||||
|
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:test.A
|
||||||
|
CONSTRUCTOR signature:test/A.<init>|<init>(kotlin.Int){}[0] visibility:public <> (x:<unbound IrClassPublicSymbolImpl>) returnType:test.A [primary]
|
||||||
|
VALUE_PARAMETER name:x index:0 type:<unbound IrClassPublicSymbolImpl>
|
||||||
|
BLOCK_BODY
|
||||||
|
DELEGATING_CONSTRUCTOR_CALL 'UNBOUND IrConstructorPublicSymbolImpl'
|
||||||
|
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:A signature:test/A|null[0] modality:FINAL visibility:public superTypes:[<unbound IrClassPublicSymbolImpl>]'
|
||||||
|
PROPERTY name:x signature:test/A.x|{}x[0] visibility:public modality:FINAL [val]
|
||||||
|
FIELD PROPERTY_BACKING_FIELD name:x signature:[ test/A.x|{}x[0] <- Local[<BF>|FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.Int visibility:private [final]] ] type:<unbound IrClassPublicSymbolImpl> visibility:private [final]
|
||||||
|
EXPRESSION_BODY
|
||||||
|
GET_VAR 'x: <unbound IrClassPublicSymbolImpl> declared in test.A.<init>' type=<unbound IrClassPublicSymbolImpl> origin=INITIALIZE_PROPERTY_FROM_PARAMETER
|
||||||
|
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-x> signature:test/A.x.<get-x>|<get-x>(){}[0] visibility:public modality:FINAL <> ($this:test.A) returnType:<unbound IrClassPublicSymbolImpl>
|
||||||
|
correspondingProperty: PROPERTY name:x signature:test/A.x|{}x[0] visibility:public modality:FINAL [val]
|
||||||
|
$this: VALUE_PARAMETER name:<this> type:test.A
|
||||||
|
BLOCK_BODY
|
||||||
|
RETURN type=<unbound IrClassPublicSymbolImpl> from='public final fun <get-x> (): <unbound IrClassPublicSymbolImpl> declared in test.A'
|
||||||
|
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:x signature:[ test/A.x|{}x[0] <- Local[<BF>|FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.Int visibility:private [final]] ] type:<unbound IrClassPublicSymbolImpl> visibility:private [final]' type=<unbound IrClassPublicSymbolImpl> origin=null
|
||||||
|
receiver: GET_VAR '<this>: test.A declared in test.A.<get-x>' type=test.A origin=null
|
||||||
|
CLASS OBJECT name:Companion signature:test/A.Companion|null[0] modality:FINAL visibility:public [companion] superTypes:[<unbound IrClassPublicSymbolImpl>]
|
||||||
|
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:test.A.Companion
|
||||||
|
CONSTRUCTOR signature:test/A.Companion.<init>|<init>(){}[0] visibility:private <> () returnType:test.A.Companion [primary]
|
||||||
|
BLOCK_BODY
|
||||||
|
DELEGATING_CONSTRUCTOR_CALL 'UNBOUND IrConstructorPublicSymbolImpl'
|
||||||
|
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS OBJECT name:Companion signature:test/A.Companion|null[0] modality:FINAL visibility:public [companion] superTypes:[<unbound IrClassPublicSymbolImpl>]'
|
||||||
|
FUN name:create signature:test/A.Companion.create|create(kotlin.Int){}[0] visibility:public modality:FINAL <> ($this:test.A.Companion, x:<unbound IrClassPublicSymbolImpl>) returnType:test.A
|
||||||
|
$this: VALUE_PARAMETER name:<this> type:test.A.Companion
|
||||||
|
VALUE_PARAMETER name:x index:0 type:<unbound IrClassPublicSymbolImpl>
|
||||||
|
BLOCK_BODY
|
||||||
|
RETURN type=<unbound IrClassPublicSymbolImpl> from='public final fun create (x: <unbound IrClassPublicSymbolImpl>): test.A declared in test.A.Companion'
|
||||||
|
CONSTRUCTOR_CALL 'public constructor <init> (x: <unbound IrClassPublicSymbolImpl>) [primary] declared in test.A' type=test.A origin=null
|
||||||
|
x: CALL 'UNBOUND IrSimpleFunctionPublicSymbolImpl' type=<unbound IrClassPublicSymbolImpl> origin=MUL
|
||||||
|
$this: GET_VAR 'x: <unbound IrClassPublicSymbolImpl> declared in test.A.Companion.create' type=<unbound IrClassPublicSymbolImpl> origin=null
|
||||||
|
1: CONST Int type=<unbound IrClassPublicSymbolImpl> value=2
|
||||||
+42
@@ -0,0 +1,42 @@
|
|||||||
|
MODULE_FRAGMENT name:<enum.kt>
|
||||||
|
FILE fqName:test fileName:enum.kt
|
||||||
|
CLASS ENUM_CLASS name:Color modality:FINAL visibility:public superTypes:[<unbound IrClassPublicSymbolImpl><test.Color>]
|
||||||
|
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:test.Color
|
||||||
|
CONSTRUCTOR visibility:private <> (rgb:<unbound IrClassPublicSymbolImpl>) returnType:test.Color [primary]
|
||||||
|
VALUE_PARAMETER name:rgb index:0 type:<unbound IrClassPublicSymbolImpl>
|
||||||
|
BLOCK_BODY
|
||||||
|
ENUM_CONSTRUCTOR_CALL 'UNBOUND IrConstructorPublicSymbolImpl'
|
||||||
|
<1>: test.Color
|
||||||
|
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS ENUM_CLASS name:Color modality:FINAL visibility:public superTypes:[<unbound IrClassPublicSymbolImpl><test.Color>]'
|
||||||
|
PROPERTY name:rgb visibility:public modality:FINAL [val]
|
||||||
|
FIELD PROPERTY_BACKING_FIELD name:rgb type:<unbound IrClassPublicSymbolImpl> visibility:private [final]
|
||||||
|
EXPRESSION_BODY
|
||||||
|
GET_VAR 'rgb: <unbound IrClassPublicSymbolImpl> declared in test.Color.<init>' type=<unbound IrClassPublicSymbolImpl> origin=INITIALIZE_PROPERTY_FROM_PARAMETER
|
||||||
|
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-rgb> visibility:public modality:FINAL <> ($this:test.Color) returnType:<unbound IrClassPublicSymbolImpl>
|
||||||
|
correspondingProperty: PROPERTY name:rgb visibility:public modality:FINAL [val]
|
||||||
|
$this: VALUE_PARAMETER name:<this> type:test.Color
|
||||||
|
BLOCK_BODY
|
||||||
|
RETURN type=<unbound IrClassPublicSymbolImpl> from='public final fun <get-rgb> (): <unbound IrClassPublicSymbolImpl> declared in test.Color'
|
||||||
|
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:rgb type:<unbound IrClassPublicSymbolImpl> visibility:private [final]' type=<unbound IrClassPublicSymbolImpl> origin=null
|
||||||
|
receiver: GET_VAR '<this>: test.Color declared in test.Color.<get-rgb>' type=test.Color origin=null
|
||||||
|
ENUM_ENTRY name:RED
|
||||||
|
init: EXPRESSION_BODY
|
||||||
|
ENUM_CONSTRUCTOR_CALL 'private constructor <init> (rgb: <unbound IrClassPublicSymbolImpl>) [primary] declared in test.Color'
|
||||||
|
rgb: CONST Int type=<unbound IrClassPublicSymbolImpl> value=16711680
|
||||||
|
ENUM_ENTRY name:GREEN
|
||||||
|
init: EXPRESSION_BODY
|
||||||
|
ENUM_CONSTRUCTOR_CALL 'private constructor <init> (rgb: <unbound IrClassPublicSymbolImpl>) [primary] declared in test.Color'
|
||||||
|
rgb: CONST Int type=<unbound IrClassPublicSymbolImpl> value=65280
|
||||||
|
ENUM_ENTRY name:BLUE
|
||||||
|
init: EXPRESSION_BODY
|
||||||
|
ENUM_CONSTRUCTOR_CALL 'private constructor <init> (rgb: <unbound IrClassPublicSymbolImpl>) [primary] declared in test.Color'
|
||||||
|
rgb: CONST Int type=<unbound IrClassPublicSymbolImpl> value=255
|
||||||
|
FUN ENUM_CLASS_SPECIAL_MEMBER name:values visibility:public modality:FINAL <> () returnType:<unbound IrClassPublicSymbolImpl><test.Color>
|
||||||
|
SYNTHETIC_BODY kind=ENUM_VALUES
|
||||||
|
FUN ENUM_CLASS_SPECIAL_MEMBER name:valueOf visibility:public modality:FINAL <> (value:<unbound IrClassPublicSymbolImpl>) returnType:test.Color
|
||||||
|
VALUE_PARAMETER name:value index:0 type:<unbound IrClassPublicSymbolImpl>
|
||||||
|
SYNTHETIC_BODY kind=ENUM_VALUEOF
|
||||||
|
PROPERTY ENUM_CLASS_SPECIAL_MEMBER name:entries visibility:public modality:FINAL [val]
|
||||||
|
FUN ENUM_CLASS_SPECIAL_MEMBER name:<get-entries> visibility:public modality:FINAL <> () returnType:<unbound IrClassPublicSymbolImpl><test.Color>
|
||||||
|
correspondingProperty: PROPERTY ENUM_CLASS_SPECIAL_MEMBER name:entries visibility:public modality:FINAL [val]
|
||||||
|
SYNTHETIC_BODY kind=ENUM_ENTRIES
|
||||||
+8
@@ -0,0 +1,8 @@
|
|||||||
|
// FIR_IDENTICAL
|
||||||
|
package test
|
||||||
|
|
||||||
|
enum class Color(val rgb: Int) {
|
||||||
|
RED(0xFF0000),
|
||||||
|
GREEN(0x00FF00),
|
||||||
|
BLUE(0x0000FF)
|
||||||
|
}
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
MODULE_FRAGMENT name:<enum.kt>
|
||||||
|
FILE fqName:test fileName:enum.kt
|
||||||
|
CLASS ENUM_CLASS name:Color signature:test/Color|null[0] modality:FINAL visibility:public superTypes:[<unbound IrClassPublicSymbolImpl><test.Color>]
|
||||||
|
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:test.Color
|
||||||
|
CONSTRUCTOR signature:test/Color.<init>|<init>(kotlin.Int){}[0] visibility:private <> (rgb:<unbound IrClassPublicSymbolImpl>) returnType:test.Color [primary]
|
||||||
|
VALUE_PARAMETER name:rgb index:0 type:<unbound IrClassPublicSymbolImpl>
|
||||||
|
BLOCK_BODY
|
||||||
|
ENUM_CONSTRUCTOR_CALL 'UNBOUND IrConstructorPublicSymbolImpl'
|
||||||
|
<1>: test.Color
|
||||||
|
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS ENUM_CLASS name:Color signature:test/Color|null[0] modality:FINAL visibility:public superTypes:[<unbound IrClassPublicSymbolImpl><test.Color>]'
|
||||||
|
PROPERTY name:rgb signature:test/Color.rgb|{}rgb[0] visibility:public modality:FINAL [val]
|
||||||
|
FIELD PROPERTY_BACKING_FIELD name:rgb signature:[ test/Color.rgb|{}rgb[0] <- Local[<BF>|FIELD PROPERTY_BACKING_FIELD name:rgb type:kotlin.Int visibility:private [final]] ] type:<unbound IrClassPublicSymbolImpl> visibility:private [final]
|
||||||
|
EXPRESSION_BODY
|
||||||
|
GET_VAR 'rgb: <unbound IrClassPublicSymbolImpl> declared in test.Color.<init>' type=<unbound IrClassPublicSymbolImpl> origin=INITIALIZE_PROPERTY_FROM_PARAMETER
|
||||||
|
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-rgb> signature:test/Color.rgb.<get-rgb>|<get-rgb>(){}[0] visibility:public modality:FINAL <> ($this:test.Color) returnType:<unbound IrClassPublicSymbolImpl>
|
||||||
|
correspondingProperty: PROPERTY name:rgb signature:test/Color.rgb|{}rgb[0] visibility:public modality:FINAL [val]
|
||||||
|
$this: VALUE_PARAMETER name:<this> type:test.Color
|
||||||
|
BLOCK_BODY
|
||||||
|
RETURN type=<unbound IrClassPublicSymbolImpl> from='public final fun <get-rgb> (): <unbound IrClassPublicSymbolImpl> declared in test.Color'
|
||||||
|
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:rgb signature:[ test/Color.rgb|{}rgb[0] <- Local[<BF>|FIELD PROPERTY_BACKING_FIELD name:rgb type:kotlin.Int visibility:private [final]] ] type:<unbound IrClassPublicSymbolImpl> visibility:private [final]' type=<unbound IrClassPublicSymbolImpl> origin=null
|
||||||
|
receiver: GET_VAR '<this>: test.Color declared in test.Color.<get-rgb>' type=test.Color origin=null
|
||||||
|
ENUM_ENTRY name:RED signature:test/Color.RED|null[0]
|
||||||
|
init: EXPRESSION_BODY
|
||||||
|
ENUM_CONSTRUCTOR_CALL 'private constructor <init> (rgb: <unbound IrClassPublicSymbolImpl>) [primary] declared in test.Color'
|
||||||
|
rgb: CONST Int type=<unbound IrClassPublicSymbolImpl> value=16711680
|
||||||
|
ENUM_ENTRY name:GREEN signature:test/Color.GREEN|null[0]
|
||||||
|
init: EXPRESSION_BODY
|
||||||
|
ENUM_CONSTRUCTOR_CALL 'private constructor <init> (rgb: <unbound IrClassPublicSymbolImpl>) [primary] declared in test.Color'
|
||||||
|
rgb: CONST Int type=<unbound IrClassPublicSymbolImpl> value=65280
|
||||||
|
ENUM_ENTRY name:BLUE signature:test/Color.BLUE|null[0]
|
||||||
|
init: EXPRESSION_BODY
|
||||||
|
ENUM_CONSTRUCTOR_CALL 'private constructor <init> (rgb: <unbound IrClassPublicSymbolImpl>) [primary] declared in test.Color'
|
||||||
|
rgb: CONST Int type=<unbound IrClassPublicSymbolImpl> value=255
|
||||||
|
FUN ENUM_CLASS_SPECIAL_MEMBER name:values signature:test/Color.values|values#static(){}[0] visibility:public modality:FINAL <> () returnType:<unbound IrClassPublicSymbolImpl><test.Color>
|
||||||
|
SYNTHETIC_BODY kind=ENUM_VALUES
|
||||||
|
FUN ENUM_CLASS_SPECIAL_MEMBER name:valueOf signature:test/Color.valueOf|valueOf#static(kotlin.String){}[0] visibility:public modality:FINAL <> (value:<unbound IrClassPublicSymbolImpl>) returnType:test.Color
|
||||||
|
VALUE_PARAMETER name:value index:0 type:<unbound IrClassPublicSymbolImpl>
|
||||||
|
SYNTHETIC_BODY kind=ENUM_VALUEOF
|
||||||
|
PROPERTY ENUM_CLASS_SPECIAL_MEMBER name:entries signature:test/Color.entries|#static{}entries[0] visibility:public modality:FINAL [val]
|
||||||
|
FUN ENUM_CLASS_SPECIAL_MEMBER name:<get-entries> signature:test/Color.entries.<get-entries>|<get-entries>#static(){}[0] visibility:public modality:FINAL <> () returnType:<unbound IrClassPublicSymbolImpl><test.Color>
|
||||||
|
correspondingProperty: PROPERTY ENUM_CLASS_SPECIAL_MEMBER name:entries signature:test/Color.entries|#static{}entries[0] visibility:public modality:FINAL [val]
|
||||||
|
SYNTHETIC_BODY kind=ENUM_ENTRIES
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
MODULE_FRAGMENT name:<field.kt>
|
||||||
|
FILE fqName:test fileName:field.kt
|
||||||
|
CLASS CLASS name:A modality:FINAL visibility:public superTypes:[<unbound IrClassPublicSymbolImpl>]
|
||||||
|
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:test.A
|
||||||
|
CONSTRUCTOR visibility:public <> () returnType:test.A [primary]
|
||||||
|
BLOCK_BODY
|
||||||
|
DELEGATING_CONSTRUCTOR_CALL 'UNBOUND IrConstructorPublicSymbolImpl'
|
||||||
|
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:A modality:FINAL visibility:public superTypes:[<unbound IrClassPublicSymbolImpl>]'
|
||||||
|
PROPERTY name:x visibility:public modality:FINAL [var]
|
||||||
|
FIELD PROPERTY_BACKING_FIELD name:x type:<unbound IrClassPublicSymbolImpl> visibility:private
|
||||||
|
EXPRESSION_BODY
|
||||||
|
CONST Int type=<unbound IrClassPublicSymbolImpl> value=5
|
||||||
|
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-x> visibility:public modality:FINAL <> ($this:test.A) returnType:<unbound IrClassPublicSymbolImpl>
|
||||||
|
correspondingProperty: PROPERTY name:x visibility:public modality:FINAL [var]
|
||||||
|
$this: VALUE_PARAMETER name:<this> type:test.A
|
||||||
|
BLOCK_BODY
|
||||||
|
RETURN type=<unbound IrClassPublicSymbolImpl> from='public final fun <get-x> (): <unbound IrClassPublicSymbolImpl> declared in test.A'
|
||||||
|
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:x type:<unbound IrClassPublicSymbolImpl> visibility:private' type=<unbound IrClassPublicSymbolImpl> origin=null
|
||||||
|
receiver: GET_VAR '<this>: test.A declared in test.A.<get-x>' type=test.A origin=null
|
||||||
|
FUN DEFAULT_PROPERTY_ACCESSOR name:<set-x> visibility:public modality:FINAL <> ($this:test.A, <set-?>:<unbound IrClassPublicSymbolImpl>) returnType:<unbound IrClassPublicSymbolImpl>
|
||||||
|
correspondingProperty: PROPERTY name:x visibility:public modality:FINAL [var]
|
||||||
|
$this: VALUE_PARAMETER name:<this> type:test.A
|
||||||
|
VALUE_PARAMETER name:<set-?> index:0 type:<unbound IrClassPublicSymbolImpl>
|
||||||
|
BLOCK_BODY
|
||||||
|
SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:x type:<unbound IrClassPublicSymbolImpl> visibility:private' type=<unbound IrClassPublicSymbolImpl> origin=null
|
||||||
|
receiver: GET_VAR '<this>: test.A declared in test.A.<set-x>' type=test.A origin=null
|
||||||
|
value: GET_VAR '<set-?>: <unbound IrClassPublicSymbolImpl> declared in test.A.<set-x>' type=<unbound IrClassPublicSymbolImpl> origin=null
|
||||||
|
PROPERTY name:y visibility:public modality:FINAL [val]
|
||||||
|
FIELD PROPERTY_BACKING_FIELD name:y type:<unbound IrClassPublicSymbolImpl> visibility:private [final]
|
||||||
|
EXPRESSION_BODY
|
||||||
|
CONST Int type=<unbound IrClassPublicSymbolImpl> value=10
|
||||||
|
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-y> visibility:public modality:FINAL <> ($this:test.A) returnType:<unbound IrClassPublicSymbolImpl>
|
||||||
|
correspondingProperty: PROPERTY name:y visibility:public modality:FINAL [val]
|
||||||
|
$this: VALUE_PARAMETER name:<this> type:test.A
|
||||||
|
BLOCK_BODY
|
||||||
|
RETURN type=<unbound IrClassPublicSymbolImpl> from='public final fun <get-y> (): <unbound IrClassPublicSymbolImpl> declared in test.A'
|
||||||
|
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:y type:<unbound IrClassPublicSymbolImpl> visibility:private [final]' type=<unbound IrClassPublicSymbolImpl> origin=null
|
||||||
|
receiver: GET_VAR '<this>: test.A declared in test.A.<get-y>' type=test.A origin=null
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
// FIR_IDENTICAL
|
||||||
|
package test
|
||||||
|
|
||||||
|
class A {
|
||||||
|
var x: Int = 5
|
||||||
|
final val y: Int = 10
|
||||||
|
}
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
MODULE_FRAGMENT name:<field.kt>
|
||||||
|
FILE fqName:test fileName:field.kt
|
||||||
|
CLASS CLASS name:A signature:test/A|null[0] modality:FINAL visibility:public superTypes:[<unbound IrClassPublicSymbolImpl>]
|
||||||
|
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:test.A
|
||||||
|
CONSTRUCTOR signature:test/A.<init>|<init>(){}[0] visibility:public <> () returnType:test.A [primary]
|
||||||
|
BLOCK_BODY
|
||||||
|
DELEGATING_CONSTRUCTOR_CALL 'UNBOUND IrConstructorPublicSymbolImpl'
|
||||||
|
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:A signature:test/A|null[0] modality:FINAL visibility:public superTypes:[<unbound IrClassPublicSymbolImpl>]'
|
||||||
|
PROPERTY name:x signature:test/A.x|{}x[0] visibility:public modality:FINAL [var]
|
||||||
|
FIELD PROPERTY_BACKING_FIELD name:x signature:[ test/A.x|{}x[0] <- Local[<BF>|FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.Int visibility:private] ] type:<unbound IrClassPublicSymbolImpl> visibility:private
|
||||||
|
EXPRESSION_BODY
|
||||||
|
CONST Int type=<unbound IrClassPublicSymbolImpl> value=5
|
||||||
|
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-x> signature:test/A.x.<get-x>|<get-x>(){}[0] visibility:public modality:FINAL <> ($this:test.A) returnType:<unbound IrClassPublicSymbolImpl>
|
||||||
|
correspondingProperty: PROPERTY name:x signature:test/A.x|{}x[0] visibility:public modality:FINAL [var]
|
||||||
|
$this: VALUE_PARAMETER name:<this> type:test.A
|
||||||
|
BLOCK_BODY
|
||||||
|
RETURN type=<unbound IrClassPublicSymbolImpl> from='public final fun <get-x> (): <unbound IrClassPublicSymbolImpl> declared in test.A'
|
||||||
|
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:x signature:[ test/A.x|{}x[0] <- Local[<BF>|FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.Int visibility:private] ] type:<unbound IrClassPublicSymbolImpl> visibility:private' type=<unbound IrClassPublicSymbolImpl> origin=null
|
||||||
|
receiver: GET_VAR '<this>: test.A declared in test.A.<get-x>' type=test.A origin=null
|
||||||
|
FUN DEFAULT_PROPERTY_ACCESSOR name:<set-x> signature:test/A.x.<set-x>|<set-x>(kotlin.Int){}[0] visibility:public modality:FINAL <> ($this:test.A, <set-?>:<unbound IrClassPublicSymbolImpl>) returnType:<unbound IrClassPublicSymbolImpl>
|
||||||
|
correspondingProperty: PROPERTY name:x signature:test/A.x|{}x[0] visibility:public modality:FINAL [var]
|
||||||
|
$this: VALUE_PARAMETER name:<this> type:test.A
|
||||||
|
VALUE_PARAMETER name:<set-?> index:0 type:<unbound IrClassPublicSymbolImpl>
|
||||||
|
BLOCK_BODY
|
||||||
|
SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:x signature:[ test/A.x|{}x[0] <- Local[<BF>|FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.Int visibility:private] ] type:<unbound IrClassPublicSymbolImpl> visibility:private' type=<unbound IrClassPublicSymbolImpl> origin=null
|
||||||
|
receiver: GET_VAR '<this>: test.A declared in test.A.<set-x>' type=test.A origin=null
|
||||||
|
value: GET_VAR '<set-?>: <unbound IrClassPublicSymbolImpl> declared in test.A.<set-x>' type=<unbound IrClassPublicSymbolImpl> origin=null
|
||||||
|
PROPERTY name:y signature:test/A.y|{}y[0] visibility:public modality:FINAL [val]
|
||||||
|
FIELD PROPERTY_BACKING_FIELD name:y signature:[ test/A.y|{}y[0] <- Local[<BF>|FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.Int visibility:private] ] type:<unbound IrClassPublicSymbolImpl> visibility:private [final]
|
||||||
|
EXPRESSION_BODY
|
||||||
|
CONST Int type=<unbound IrClassPublicSymbolImpl> value=10
|
||||||
|
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-y> signature:test/A.y.<get-y>|<get-y>(){}[0] visibility:public modality:FINAL <> ($this:test.A) returnType:<unbound IrClassPublicSymbolImpl>
|
||||||
|
correspondingProperty: PROPERTY name:y signature:test/A.y|{}y[0] visibility:public modality:FINAL [val]
|
||||||
|
$this: VALUE_PARAMETER name:<this> type:test.A
|
||||||
|
BLOCK_BODY
|
||||||
|
RETURN type=<unbound IrClassPublicSymbolImpl> from='public final fun <get-y> (): <unbound IrClassPublicSymbolImpl> declared in test.A'
|
||||||
|
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:y signature:[ test/A.y|{}y[0] <- Local[<BF>|FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.Int visibility:private] ] type:<unbound IrClassPublicSymbolImpl> visibility:private [final]' type=<unbound IrClassPublicSymbolImpl> origin=null
|
||||||
|
receiver: GET_VAR '<this>: test.A declared in test.A.<get-y>' type=test.A origin=null
|
||||||
+22
@@ -0,0 +1,22 @@
|
|||||||
|
MODULE_FRAGMENT name:<fun.kt>
|
||||||
|
FILE fqName:test fileName:fun.kt
|
||||||
|
CLASS CLASS name:A modality:FINAL visibility:public superTypes:[<unbound IrClassPublicSymbolImpl>]
|
||||||
|
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:test.A
|
||||||
|
CONSTRUCTOR visibility:public <> () returnType:test.A [primary]
|
||||||
|
BLOCK_BODY
|
||||||
|
DELEGATING_CONSTRUCTOR_CALL 'UNBOUND IrConstructorPublicSymbolImpl'
|
||||||
|
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:A modality:FINAL visibility:public superTypes:[<unbound IrClassPublicSymbolImpl>]'
|
||||||
|
FUN name:foo visibility:private modality:FINAL <> ($this:test.A) returnType:<unbound IrClassPublicSymbolImpl>
|
||||||
|
$this: VALUE_PARAMETER name:<this> type:test.A
|
||||||
|
BLOCK_BODY
|
||||||
|
RETURN type=<unbound IrClassPublicSymbolImpl> from='private final fun foo (): <unbound IrClassPublicSymbolImpl> declared in test.A'
|
||||||
|
CONST Int type=<unbound IrClassPublicSymbolImpl> value=42
|
||||||
|
FUN name:bar visibility:public modality:FINAL <> ($this:test.A, z:<unbound IrClassPublicSymbolImpl>) returnType:<unbound IrClassPublicSymbolImpl>
|
||||||
|
$this: VALUE_PARAMETER name:<this> type:test.A
|
||||||
|
VALUE_PARAMETER name:z index:0 type:<unbound IrClassPublicSymbolImpl>
|
||||||
|
BLOCK_BODY
|
||||||
|
RETURN type=<unbound IrClassPublicSymbolImpl> from='public final fun bar (z: <unbound IrClassPublicSymbolImpl>): <unbound IrClassPublicSymbolImpl> declared in test.A'
|
||||||
|
CALL 'UNBOUND IrSimpleFunctionPublicSymbolImpl' type=<unbound IrClassPublicSymbolImpl> origin=PLUS
|
||||||
|
$this: CALL 'private final fun foo (): <unbound IrClassPublicSymbolImpl> declared in test.A' type=<unbound IrClassPublicSymbolImpl> origin=null
|
||||||
|
$this: GET_VAR '<this>: test.A declared in test.A.bar' type=test.A origin=null
|
||||||
|
1: GET_VAR 'z: <unbound IrClassPublicSymbolImpl> declared in test.A.bar' type=<unbound IrClassPublicSymbolImpl> origin=null
|
||||||
+7
@@ -0,0 +1,7 @@
|
|||||||
|
// FIR_IDENTICAL
|
||||||
|
package test
|
||||||
|
|
||||||
|
class A {
|
||||||
|
private fun foo() = 42
|
||||||
|
public fun bar(z: Int) = foo() + z
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
MODULE_FRAGMENT name:<fun.kt>
|
||||||
|
FILE fqName:test fileName:fun.kt
|
||||||
|
CLASS CLASS name:A signature:test/A|null[0] modality:FINAL visibility:public superTypes:[<unbound IrClassPublicSymbolImpl>]
|
||||||
|
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:test.A
|
||||||
|
CONSTRUCTOR signature:test/A.<init>|<init>(){}[0] visibility:public <> () returnType:test.A [primary]
|
||||||
|
BLOCK_BODY
|
||||||
|
DELEGATING_CONSTRUCTOR_CALL 'UNBOUND IrConstructorPublicSymbolImpl'
|
||||||
|
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:A signature:test/A|null[0] modality:FINAL visibility:public superTypes:[<unbound IrClassPublicSymbolImpl>]'
|
||||||
|
FUN name:foo signature:test/A.foo|foo(){}[0] visibility:private modality:FINAL <> ($this:test.A) returnType:<unbound IrClassPublicSymbolImpl>
|
||||||
|
$this: VALUE_PARAMETER name:<this> type:test.A
|
||||||
|
BLOCK_BODY
|
||||||
|
RETURN type=<unbound IrClassPublicSymbolImpl> from='private final fun foo (): <unbound IrClassPublicSymbolImpl> declared in test.A'
|
||||||
|
CONST Int type=<unbound IrClassPublicSymbolImpl> value=42
|
||||||
|
FUN name:bar signature:test/A.bar|bar(kotlin.Int){}[0] visibility:public modality:FINAL <> ($this:test.A, z:<unbound IrClassPublicSymbolImpl>) returnType:<unbound IrClassPublicSymbolImpl>
|
||||||
|
$this: VALUE_PARAMETER name:<this> type:test.A
|
||||||
|
VALUE_PARAMETER name:z index:0 type:<unbound IrClassPublicSymbolImpl>
|
||||||
|
BLOCK_BODY
|
||||||
|
RETURN type=<unbound IrClassPublicSymbolImpl> from='public final fun bar (z: <unbound IrClassPublicSymbolImpl>): <unbound IrClassPublicSymbolImpl> declared in test.A'
|
||||||
|
CALL 'UNBOUND IrSimpleFunctionPublicSymbolImpl' type=<unbound IrClassPublicSymbolImpl> origin=PLUS
|
||||||
|
$this: CALL 'private final fun foo (): <unbound IrClassPublicSymbolImpl> declared in test.A' type=<unbound IrClassPublicSymbolImpl> origin=null
|
||||||
|
$this: GET_VAR '<this>: test.A declared in test.A.bar' type=test.A origin=null
|
||||||
|
1: GET_VAR 'z: <unbound IrClassPublicSymbolImpl> declared in test.A.bar' type=<unbound IrClassPublicSymbolImpl> origin=null
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
MODULE_FRAGMENT name:<typealias.kt>
|
||||||
|
FILE fqName:test fileName:typealias.kt
|
||||||
|
TYPEALIAS name:PublicTypeAlias visibility:public expandedType:test.ClassName
|
||||||
|
TYPEALIAS name:InternalTypeAlias visibility:internal expandedType:test.ClassName
|
||||||
|
TYPEALIAS name:PrivateTypeAlias visibility:private expandedType:test.ClassName
|
||||||
|
CLASS CLASS name:ClassName modality:FINAL visibility:public superTypes:[<unbound IrClassPublicSymbolImpl>]
|
||||||
|
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:test.ClassName
|
||||||
|
CONSTRUCTOR visibility:public <> () returnType:test.ClassName [primary]
|
||||||
|
BLOCK_BODY
|
||||||
|
DELEGATING_CONSTRUCTOR_CALL 'UNBOUND IrConstructorPublicSymbolImpl'
|
||||||
|
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:ClassName modality:FINAL visibility:public superTypes:[<unbound IrClassPublicSymbolImpl>]'
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
MODULE_FRAGMENT name:<typealias.kt>
|
||||||
|
FILE fqName:test fileName:typealias.kt
|
||||||
|
CLASS CLASS name:ClassName modality:FINAL visibility:public superTypes:[<unbound IrClassPublicSymbolImpl>]
|
||||||
|
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:test.ClassName
|
||||||
|
CONSTRUCTOR visibility:public <> () returnType:test.ClassName [primary]
|
||||||
|
BLOCK_BODY
|
||||||
|
DELEGATING_CONSTRUCTOR_CALL 'UNBOUND IrConstructorPublicSymbolImpl'
|
||||||
|
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:ClassName modality:FINAL visibility:public superTypes:[<unbound IrClassPublicSymbolImpl>]'
|
||||||
|
TYPEALIAS name:PublicTypeAlias visibility:public expandedType:test.ClassName
|
||||||
|
TYPEALIAS name:InternalTypeAlias visibility:internal expandedType:test.ClassName
|
||||||
|
TYPEALIAS name:PrivateTypeAlias visibility:private expandedType:test.ClassName
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package test
|
||||||
|
|
||||||
|
class ClassName
|
||||||
|
|
||||||
|
typealias PublicTypeAlias = ClassName
|
||||||
|
internal typealias InternalTypeAlias = ClassName
|
||||||
|
private typealias PrivateTypeAlias = ClassName
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
MODULE_FRAGMENT name:<typealias.kt>
|
||||||
|
FILE fqName:test fileName:typealias.kt
|
||||||
|
TYPEALIAS name:PublicTypeAlias signature:test/PublicTypeAlias|null[0] visibility:public expandedType:test.ClassName
|
||||||
|
TYPEALIAS name:InternalTypeAlias signature:test/InternalTypeAlias|null[0] visibility:internal expandedType:test.ClassName
|
||||||
|
TYPEALIAS name:PrivateTypeAlias signature:[ File 'typealias.kt' <- test/PrivateTypeAlias|null[0] ] visibility:private expandedType:test.ClassName
|
||||||
|
CLASS CLASS name:ClassName signature:test/ClassName|null[0] modality:FINAL visibility:public superTypes:[<unbound IrClassPublicSymbolImpl>]
|
||||||
|
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:test.ClassName
|
||||||
|
CONSTRUCTOR signature:test/ClassName.<init>|<init>(){}[0] visibility:public <> () returnType:test.ClassName [primary]
|
||||||
|
BLOCK_BODY
|
||||||
|
DELEGATING_CONSTRUCTOR_CALL 'UNBOUND IrConstructorPublicSymbolImpl'
|
||||||
|
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:ClassName signature:test/ClassName|null[0] modality:FINAL visibility:public superTypes:[<unbound IrClassPublicSymbolImpl>]'
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
MODULE_FRAGMENT name:<typealias.kt>
|
||||||
|
FILE fqName:test fileName:typealias.kt
|
||||||
|
CLASS CLASS name:ClassName signature:test/ClassName|null[0] modality:FINAL visibility:public superTypes:[<unbound IrClassPublicSymbolImpl>]
|
||||||
|
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:test.ClassName
|
||||||
|
CONSTRUCTOR signature:test/ClassName.<init>|<init>(){}[0] visibility:public <> () returnType:test.ClassName [primary]
|
||||||
|
BLOCK_BODY
|
||||||
|
DELEGATING_CONSTRUCTOR_CALL 'UNBOUND IrConstructorPublicSymbolImpl'
|
||||||
|
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:ClassName signature:test/ClassName|null[0] modality:FINAL visibility:public superTypes:[<unbound IrClassPublicSymbolImpl>]'
|
||||||
|
TYPEALIAS name:PublicTypeAlias signature:test/PublicTypeAlias|null[0] visibility:public expandedType:test.ClassName
|
||||||
|
TYPEALIAS name:InternalTypeAlias signature:test/InternalTypeAlias|null[0] visibility:internal expandedType:test.ClassName
|
||||||
|
TYPEALIAS name:PrivateTypeAlias signature:[ File 'typealias.kt' <- test/PrivateTypeAlias|null[0] ] visibility:private expandedType:test.ClassName
|
||||||
+1
-1
@@ -22,7 +22,7 @@ import java.util.regex.Pattern;
|
|||||||
@TestDataPath("$PROJECT_ROOT")
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
@Tag("frontend-fir")
|
@Tag("frontend-fir")
|
||||||
@FirPipeline()
|
@FirPipeline()
|
||||||
public class FirNativeKLibContentsTestGenerated extends AbstractNativeKlibContentsTest {
|
public class FirNativeKlibContentsTestGenerated extends AbstractNativeKlibContentsTest {
|
||||||
@Test
|
@Test
|
||||||
public void testAllFilesPresentInKlibContents() throws Exception {
|
public void testAllFilesPresentInKlibContents() throws Exception {
|
||||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("native/native.tests/testData/klibContents"), Pattern.compile("^([^_](.+)).kt$"), null, true);
|
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("native/native.tests/testData/klibContents"), Pattern.compile("^([^_](.+)).kt$"), null, true);
|
||||||
+66
@@ -0,0 +1,66 @@
|
|||||||
|
/*
|
||||||
|
* 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.konan.blackboxtest;
|
||||||
|
|
||||||
|
import com.intellij.testFramework.TestDataPath;
|
||||||
|
import org.jetbrains.kotlin.test.util.KtTestUtil;
|
||||||
|
import org.junit.jupiter.api.Tag;
|
||||||
|
import org.jetbrains.kotlin.konan.blackboxtest.support.group.FirPipeline;
|
||||||
|
import org.jetbrains.kotlin.test.TestMetadata;
|
||||||
|
import org.junit.jupiter.api.Nested;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
/** This class is generated by {@link org.jetbrains.kotlin.generators.tests.GenerateNativeTestsKt}. DO NOT MODIFY MANUALLY */
|
||||||
|
@SuppressWarnings("all")
|
||||||
|
@TestMetadata("native/native.tests/testData/klibIr")
|
||||||
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
|
@Tag("frontend-fir")
|
||||||
|
@FirPipeline()
|
||||||
|
public class FirNativeKlibIrTestGenerated extends AbstractNativeKlibIrTest {
|
||||||
|
@Test
|
||||||
|
public void testAllFilesPresentInKlibIr() throws Exception {
|
||||||
|
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("native/native.tests/testData/klibIr"), Pattern.compile("^([^_](.+)).kt$"), null, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("class.kt")
|
||||||
|
public void testClass() throws Exception {
|
||||||
|
runTest("native/native.tests/testData/klibIr/class.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("constructor.kt")
|
||||||
|
public void testConstructor() throws Exception {
|
||||||
|
runTest("native/native.tests/testData/klibIr/constructor.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("enum.kt")
|
||||||
|
public void testEnum() throws Exception {
|
||||||
|
runTest("native/native.tests/testData/klibIr/enum.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("field.kt")
|
||||||
|
public void testField() throws Exception {
|
||||||
|
runTest("native/native.tests/testData/klibIr/field.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("fun.kt")
|
||||||
|
public void testFun() throws Exception {
|
||||||
|
runTest("native/native.tests/testData/klibIr/fun.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("typealias.kt")
|
||||||
|
public void testTypealias() throws Exception {
|
||||||
|
runTest("native/native.tests/testData/klibIr/typealias.kt");
|
||||||
|
}
|
||||||
|
}
|
||||||
+1
-1
@@ -18,7 +18,7 @@ import java.util.regex.Pattern;
|
|||||||
@SuppressWarnings("all")
|
@SuppressWarnings("all")
|
||||||
@TestMetadata("native/native.tests/testData/klibContents")
|
@TestMetadata("native/native.tests/testData/klibContents")
|
||||||
@TestDataPath("$PROJECT_ROOT")
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
public class NativeKLibContentsTestGenerated extends AbstractNativeKlibContentsTest {
|
public class NativeKlibContentsTestGenerated extends AbstractNativeKlibContentsTest {
|
||||||
@Test
|
@Test
|
||||||
public void testAllFilesPresentInKlibContents() throws Exception {
|
public void testAllFilesPresentInKlibContents() throws Exception {
|
||||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("native/native.tests/testData/klibContents"), Pattern.compile("^([^_](.+)).kt$"), null, true);
|
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("native/native.tests/testData/klibContents"), Pattern.compile("^([^_](.+)).kt$"), null, true);
|
||||||
native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/NativeKlibIrTestGenerated.java
Generated
+62
@@ -0,0 +1,62 @@
|
|||||||
|
/*
|
||||||
|
* 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.konan.blackboxtest;
|
||||||
|
|
||||||
|
import com.intellij.testFramework.TestDataPath;
|
||||||
|
import org.jetbrains.kotlin.test.util.KtTestUtil;
|
||||||
|
import org.jetbrains.kotlin.test.TestMetadata;
|
||||||
|
import org.junit.jupiter.api.Nested;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
/** This class is generated by {@link org.jetbrains.kotlin.generators.tests.GenerateNativeTestsKt}. DO NOT MODIFY MANUALLY */
|
||||||
|
@SuppressWarnings("all")
|
||||||
|
@TestMetadata("native/native.tests/testData/klibIr")
|
||||||
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
|
public class NativeKlibIrTestGenerated extends AbstractNativeKlibIrTest {
|
||||||
|
@Test
|
||||||
|
public void testAllFilesPresentInKlibIr() throws Exception {
|
||||||
|
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("native/native.tests/testData/klibIr"), Pattern.compile("^([^_](.+)).kt$"), null, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("class.kt")
|
||||||
|
public void testClass() throws Exception {
|
||||||
|
runTest("native/native.tests/testData/klibIr/class.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("constructor.kt")
|
||||||
|
public void testConstructor() throws Exception {
|
||||||
|
runTest("native/native.tests/testData/klibIr/constructor.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("enum.kt")
|
||||||
|
public void testEnum() throws Exception {
|
||||||
|
runTest("native/native.tests/testData/klibIr/enum.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("field.kt")
|
||||||
|
public void testField() throws Exception {
|
||||||
|
runTest("native/native.tests/testData/klibIr/field.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("fun.kt")
|
||||||
|
public void testFun() throws Exception {
|
||||||
|
runTest("native/native.tests/testData/klibIr/fun.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("typealias.kt")
|
||||||
|
public void testTypealias() throws Exception {
|
||||||
|
runTest("native/native.tests/testData/klibIr/typealias.kt");
|
||||||
|
}
|
||||||
|
}
|
||||||
+21
-2
@@ -196,14 +196,14 @@ fun main() {
|
|||||||
// Klib contents tests
|
// Klib contents tests
|
||||||
testGroup("native/native.tests/tests-gen", "native/native.tests/testData") {
|
testGroup("native/native.tests/tests-gen", "native/native.tests/testData") {
|
||||||
testClass<AbstractNativeKlibContentsTest>(
|
testClass<AbstractNativeKlibContentsTest>(
|
||||||
suiteTestClassName = "NativeKLibContentsTestGenerated"
|
suiteTestClassName = "NativeKlibContentsTestGenerated"
|
||||||
) {
|
) {
|
||||||
model("klibContents", pattern = "^([^_](.+)).kt$", recursive = true)
|
model("klibContents", pattern = "^([^_](.+)).kt$", recursive = true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
testGroup("native/native.tests/tests-gen", "native/native.tests/testData") {
|
testGroup("native/native.tests/tests-gen", "native/native.tests/testData") {
|
||||||
testClass<AbstractNativeKlibContentsTest>(
|
testClass<AbstractNativeKlibContentsTest>(
|
||||||
suiteTestClassName = "FirNativeKLibContentsTestGenerated",
|
suiteTestClassName = "FirNativeKlibContentsTestGenerated",
|
||||||
annotations = listOf(
|
annotations = listOf(
|
||||||
*frontendFir()
|
*frontendFir()
|
||||||
)
|
)
|
||||||
@@ -212,6 +212,25 @@ fun main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Klib ir tests
|
||||||
|
testGroup("native/native.tests/tests-gen", "native/native.tests/testData") {
|
||||||
|
testClass<AbstractNativeKlibIrTest>(
|
||||||
|
suiteTestClassName = "NativeKlibIrTestGenerated",
|
||||||
|
) {
|
||||||
|
model("klibIr", pattern = "^([^_](.+)).kt$", recursive = true)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
testGroup("native/native.tests/tests-gen", "native/native.tests/testData") {
|
||||||
|
testClass<AbstractNativeKlibIrTest>(
|
||||||
|
suiteTestClassName = "FirNativeKlibIrTestGenerated",
|
||||||
|
annotations = listOf(
|
||||||
|
*frontendFir()
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
model("klibIr", pattern = "^([^_](.+)).kt$", recursive = true)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// LLDB integration tests.
|
// LLDB integration tests.
|
||||||
testGroup("native/native.tests/tests-gen", "native/native.tests/testData") {
|
testGroup("native/native.tests/tests-gen", "native/native.tests/testData") {
|
||||||
testClass<AbstractNativeBlackBoxTest>(
|
testClass<AbstractNativeBlackBoxTest>(
|
||||||
|
|||||||
+2
-1
@@ -20,6 +20,7 @@ import org.jetbrains.kotlin.konan.blackboxtest.support.runner.TestRunChecks
|
|||||||
import org.jetbrains.kotlin.konan.blackboxtest.support.settings.Binaries
|
import org.jetbrains.kotlin.konan.blackboxtest.support.settings.Binaries
|
||||||
import org.jetbrains.kotlin.konan.blackboxtest.support.settings.CacheMode
|
import org.jetbrains.kotlin.konan.blackboxtest.support.settings.CacheMode
|
||||||
import org.jetbrains.kotlin.konan.blackboxtest.support.settings.KotlinNativeTargets
|
import org.jetbrains.kotlin.konan.blackboxtest.support.settings.KotlinNativeTargets
|
||||||
|
import org.jetbrains.kotlin.konan.blackboxtest.support.settings.PipelineType
|
||||||
import org.jetbrains.kotlin.konan.blackboxtest.support.settings.Timeouts
|
import org.jetbrains.kotlin.konan.blackboxtest.support.settings.Timeouts
|
||||||
import org.jetbrains.kotlin.konan.blackboxtest.support.util.*
|
import org.jetbrains.kotlin.konan.blackboxtest.support.util.*
|
||||||
import org.jetbrains.kotlin.test.Directives
|
import org.jetbrains.kotlin.test.Directives
|
||||||
@@ -36,7 +37,7 @@ import org.jetbrains.kotlin.compatibility.binary.TestModule as TModule
|
|||||||
abstract class AbstractNativeKlibEvolutionTest : AbstractNativeSimpleTest() {
|
abstract class AbstractNativeKlibEvolutionTest : AbstractNativeSimpleTest() {
|
||||||
// Const evaluation tests muted for FIR because FIR does const propagation.
|
// Const evaluation tests muted for FIR because FIR does const propagation.
|
||||||
private fun isIgnoredTest(filePath: String): Boolean {
|
private fun isIgnoredTest(filePath: String): Boolean {
|
||||||
if (!this::class.java.simpleName.startsWith("Fir"))
|
if (testRunSettings.get<PipelineType>() != PipelineType.K2)
|
||||||
return false
|
return false
|
||||||
|
|
||||||
val fileName = filePath.substringAfterLast('/')
|
val fileName = filePath.substringAfterLast('/')
|
||||||
|
|||||||
+84
@@ -0,0 +1,84 @@
|
|||||||
|
/*
|
||||||
|
* 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.konan.blackboxtest
|
||||||
|
|
||||||
|
import com.intellij.testFramework.TestDataFile
|
||||||
|
import org.jetbrains.kotlin.konan.blackboxtest.support.PackageName
|
||||||
|
import org.jetbrains.kotlin.konan.blackboxtest.support.TestCase
|
||||||
|
import org.jetbrains.kotlin.konan.blackboxtest.support.TestCaseId
|
||||||
|
import org.jetbrains.kotlin.konan.blackboxtest.support.TestCompilerArgs
|
||||||
|
import org.jetbrains.kotlin.konan.blackboxtest.support.TestFile
|
||||||
|
import org.jetbrains.kotlin.konan.blackboxtest.support.TestKind
|
||||||
|
import org.jetbrains.kotlin.konan.blackboxtest.support.TestModule
|
||||||
|
import org.jetbrains.kotlin.konan.blackboxtest.support.TestRunnerType
|
||||||
|
import org.jetbrains.kotlin.konan.blackboxtest.support.compilation.TestCompilationArtifact
|
||||||
|
import org.jetbrains.kotlin.konan.blackboxtest.support.compilation.TestCompilationResult
|
||||||
|
import org.jetbrains.kotlin.konan.blackboxtest.support.compilation.TestCompilationResult.Companion.assertSuccess
|
||||||
|
import org.jetbrains.kotlin.konan.blackboxtest.support.runner.TestRunChecks
|
||||||
|
import org.jetbrains.kotlin.konan.blackboxtest.support.settings.KotlinNativeClassLoader
|
||||||
|
import org.jetbrains.kotlin.konan.blackboxtest.support.settings.PipelineType
|
||||||
|
import org.jetbrains.kotlin.konan.blackboxtest.support.settings.Timeouts
|
||||||
|
import org.jetbrains.kotlin.konan.blackboxtest.support.util.getAbsoluteFile
|
||||||
|
import org.jetbrains.kotlin.konan.blackboxtest.support.util.getIr
|
||||||
|
import org.jetbrains.kotlin.test.services.JUnit5Assertions.assertEqualsToFile
|
||||||
|
import org.junit.jupiter.api.Tag
|
||||||
|
import java.io.File
|
||||||
|
|
||||||
|
@Tag("klib")
|
||||||
|
abstract class AbstractNativeKlibIrTest : AbstractNativeSimpleTest() {
|
||||||
|
protected fun runTest(@TestDataFile testPath: String) {
|
||||||
|
val testPathFull = getAbsoluteFile(testPath)
|
||||||
|
muteTestIfNecessary(testPathFull)
|
||||||
|
|
||||||
|
val testCase: TestCase = generateTestCaseWithSingleSource(
|
||||||
|
testPathFull,
|
||||||
|
listOf("-Xklib-relative-path-base=${testPathFull.parent}")
|
||||||
|
)
|
||||||
|
val testCompilationResult: TestCompilationResult.Success<out TestCompilationArtifact.KLIB> = compileToLibrary(testCase)
|
||||||
|
|
||||||
|
val testPathNoExtension = testPathFull.canonicalPath.substringBeforeLast(".")
|
||||||
|
|
||||||
|
val firSpecificExt =
|
||||||
|
if (testRunSettings.get<PipelineType>() == PipelineType.K2 && !firIdentical(testPathFull))
|
||||||
|
".fir"
|
||||||
|
else ""
|
||||||
|
|
||||||
|
val expectedContentsNoSig = File("$testPathNoExtension.ir$firSpecificExt.txt")
|
||||||
|
assertIrMatchesExpected(testCompilationResult, expectedContentsNoSig, printSignatures = false)
|
||||||
|
|
||||||
|
val expectedContentsWithSig = File("$testPathNoExtension.sig.ir$firSpecificExt.txt")
|
||||||
|
assertIrMatchesExpected(testCompilationResult, expectedContentsWithSig, printSignatures = true)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun assertIrMatchesExpected(
|
||||||
|
compilationResult: TestCompilationResult<out TestCompilationArtifact.KLIB>,
|
||||||
|
expectedContents: File,
|
||||||
|
printSignatures: Boolean
|
||||||
|
) {
|
||||||
|
val artifact = compilationResult.assertSuccess().resultingArtifact
|
||||||
|
val kotlinNativeClassLoader = testRunSettings.get<KotlinNativeClassLoader>()
|
||||||
|
val klibIr = artifact.getIr(kotlinNativeClassLoader.classLoader, printSignatures)
|
||||||
|
assertEqualsToFile(expectedContents, klibIr)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun generateTestCaseWithSingleSource(source: File, extraArgs: List<String>): TestCase {
|
||||||
|
val moduleName: String = source.name
|
||||||
|
val module = TestModule.Exclusive(moduleName, emptySet(), emptySet(), emptySet())
|
||||||
|
module.files += TestFile.createCommitted(source, module)
|
||||||
|
|
||||||
|
return TestCase(
|
||||||
|
id = TestCaseId.Named(moduleName),
|
||||||
|
kind = TestKind.STANDALONE,
|
||||||
|
modules = setOf(module),
|
||||||
|
freeCompilerArgs = TestCompilerArgs(extraArgs),
|
||||||
|
nominalPackageName = PackageName.EMPTY,
|
||||||
|
checks = TestRunChecks.Default(testRunSettings.get<Timeouts>().executionTimeout),
|
||||||
|
extras = TestCase.WithTestRunnerExtras(TestRunnerType.DEFAULT)
|
||||||
|
).apply {
|
||||||
|
initialize(null, null)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+3
@@ -309,6 +309,9 @@ internal fun AbstractNativeSimpleTest.muteTestIfNecessary(testDataFileContents:
|
|||||||
Assumptions.assumeFalse(mutedWhenValues.any { it == pipelineType.mutedOption.name })
|
Assumptions.assumeFalse(mutedWhenValues.any { it == pipelineType.mutedOption.name })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal fun AbstractNativeSimpleTest.firIdentical(testDataFile: File) =
|
||||||
|
InTextDirectivesUtils.isDirectiveDefined(FileUtil.loadFile(testDataFile), TestDirectives.FIR_IDENTICAL.name)
|
||||||
|
|
||||||
internal fun AbstractNativeSimpleTest.freeCompilerArgs(testDataFile: File) = freeCompilerArgs(FileUtil.loadFile(testDataFile))
|
internal fun AbstractNativeSimpleTest.freeCompilerArgs(testDataFile: File) = freeCompilerArgs(FileUtil.loadFile(testDataFile))
|
||||||
internal fun AbstractNativeSimpleTest.freeCompilerArgs(testDataFileContents: String) =
|
internal fun AbstractNativeSimpleTest.freeCompilerArgs(testDataFileContents: String) =
|
||||||
directiveValues(testDataFileContents, TestDirectives.FREE_COMPILER_ARGS.name)
|
directiveValues(testDataFileContents, TestDirectives.FREE_COMPILER_ARGS.name)
|
||||||
|
|||||||
+4
@@ -140,6 +140,10 @@ internal object TestDirectives : SimpleDirectivesContainer() {
|
|||||||
Usage: // MUTED_WHEN: [K1, K2]
|
Usage: // MUTED_WHEN: [K1, K2]
|
||||||
In native simple tests, specify the pipeline types to mute the test""".trimIndent(),
|
In native simple tests, specify the pipeline types to mute the test""".trimIndent(),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
val FIR_IDENTICAL by directive(
|
||||||
|
description = "Test behavior should be identical for FIR testing"
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
internal enum class TestKind {
|
internal enum class TestKind {
|
||||||
|
|||||||
+16
-3
@@ -6,14 +6,27 @@
|
|||||||
package org.jetbrains.kotlin.konan.blackboxtest.support.util
|
package org.jetbrains.kotlin.konan.blackboxtest.support.util
|
||||||
|
|
||||||
import org.jetbrains.kotlin.konan.blackboxtest.support.compilation.TestCompilationArtifact
|
import org.jetbrains.kotlin.konan.blackboxtest.support.compilation.TestCompilationArtifact
|
||||||
|
import java.io.File
|
||||||
|
|
||||||
internal fun TestCompilationArtifact.KLIB.getContents(kotlinNativeClassLoader: ClassLoader): String {
|
private fun invokeKlibTool(kotlinNativeClassLoader: ClassLoader, klibFile: File, functionName: String, vararg args: Any): String {
|
||||||
val libraryClass = Class.forName("org.jetbrains.kotlin.cli.klib.Library", true, kotlinNativeClassLoader)
|
val libraryClass = Class.forName("org.jetbrains.kotlin.cli.klib.Library", true, kotlinNativeClassLoader)
|
||||||
val entryPoint = libraryClass.declaredMethods.single { it.name == "contents" }
|
val entryPoint = libraryClass.declaredMethods.single { it.name == functionName }
|
||||||
val lib = libraryClass.getDeclaredConstructor(String::class.java, String::class.java, String::class.java)
|
val lib = libraryClass.getDeclaredConstructor(String::class.java, String::class.java, String::class.java)
|
||||||
.newInstance(klibFile.canonicalPath, null, "host")
|
.newInstance(klibFile.canonicalPath, null, "host")
|
||||||
|
|
||||||
val output = StringBuilder()
|
val output = StringBuilder()
|
||||||
entryPoint.invoke(lib, output, false)
|
entryPoint.invoke(lib, output, *args)
|
||||||
return output.toString()
|
return output.toString()
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
internal fun TestCompilationArtifact.KLIB.getContents(kotlinNativeClassLoader: ClassLoader): String {
|
||||||
|
return invokeKlibTool(kotlinNativeClassLoader, klibFile, "contents", false)
|
||||||
|
}
|
||||||
|
|
||||||
|
internal fun TestCompilationArtifact.KLIB.getIr(
|
||||||
|
kotlinNativeClassLoader: ClassLoader,
|
||||||
|
printSignatures: Boolean = false,
|
||||||
|
): String {
|
||||||
|
return invokeKlibTool(kotlinNativeClassLoader, klibFile, "ir", printSignatures)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user