Minor. Small clean-up in KLIB decompiler
This commit is contained in:
@@ -80,9 +80,7 @@ abstract class KlibMetadataDecompiler<out V : BinaryVersion>(
|
|||||||
private fun buildDecompiledText(virtualFile: VirtualFile): DecompiledText {
|
private fun buildDecompiledText(virtualFile: VirtualFile): DecompiledText {
|
||||||
assert(virtualFile.fileType == fileType) { "Unexpected file type ${virtualFile.fileType}" }
|
assert(virtualFile.fileType == fileType) { "Unexpected file type ${virtualFile.fileType}" }
|
||||||
|
|
||||||
val file = readFileSafely(virtualFile)
|
return when (val file = readFileSafely(virtualFile)) {
|
||||||
|
|
||||||
return when (file) {
|
|
||||||
is FileWithMetadata.Incompatible -> createIncompatibleAbiVersionDecompiledText(expectedBinaryVersion(), file.version)
|
is FileWithMetadata.Incompatible -> createIncompatibleAbiVersionDecompiledText(expectedBinaryVersion(), file.version)
|
||||||
is FileWithMetadata.Compatible -> decompiledText(
|
is FileWithMetadata.Compatible -> decompiledText(
|
||||||
file,
|
file,
|
||||||
@@ -98,10 +96,7 @@ abstract class KlibMetadataDecompiler<out V : BinaryVersion>(
|
|||||||
sealed class FileWithMetadata {
|
sealed class FileWithMetadata {
|
||||||
class Incompatible(val version: BinaryVersion) : FileWithMetadata()
|
class Incompatible(val version: BinaryVersion) : FileWithMetadata()
|
||||||
|
|
||||||
open class Compatible(
|
open class Compatible(val proto: ProtoBuf.PackageFragment) : FileWithMetadata() {
|
||||||
val proto: ProtoBuf.PackageFragment,
|
|
||||||
serializerProtocol: SerializerExtensionProtocol // TODO: Is it required?
|
|
||||||
) : FileWithMetadata() {
|
|
||||||
val nameResolver = NameResolverImpl(proto.strings, proto.qualifiedNames)
|
val nameResolver = NameResolverImpl(proto.strings, proto.qualifiedNames)
|
||||||
val packageFqName = FqName(proto.getExtension(KlibMetadataProtoBuf.fqName))
|
val packageFqName = FqName(proto.getExtension(KlibMetadataProtoBuf.fqName))
|
||||||
|
|
||||||
|
|||||||
+1
-5
@@ -42,9 +42,7 @@ class KlibMetadataDeserializerForDecompiler(
|
|||||||
storageManager, moduleDescriptor, DeserializationConfiguration.Default,
|
storageManager, moduleDescriptor, DeserializationConfiguration.Default,
|
||||||
KlibMetadataClassDataFinder(proto, nameResolver),
|
KlibMetadataClassDataFinder(proto, nameResolver),
|
||||||
AnnotationAndConstantLoaderImpl(moduleDescriptor, notFoundClasses, serializerProtocol), packageFragmentProvider,
|
AnnotationAndConstantLoaderImpl(moduleDescriptor, notFoundClasses, serializerProtocol), packageFragmentProvider,
|
||||||
ResolveEverythingToKotlinAnyLocalClassifierResolver(builtIns), createLoggingErrorReporter(
|
ResolveEverythingToKotlinAnyLocalClassifierResolver(builtIns), LoggingErrorReporter(LOG),
|
||||||
LOG
|
|
||||||
),
|
|
||||||
LookupTracker.DO_NOTHING, flexibleTypeDeserializer, emptyList(), notFoundClasses, ContractDeserializer.DEFAULT,
|
LookupTracker.DO_NOTHING, flexibleTypeDeserializer, emptyList(), notFoundClasses, ContractDeserializer.DEFAULT,
|
||||||
extensionRegistryLite = serializerProtocol.extensionRegistry,
|
extensionRegistryLite = serializerProtocol.extensionRegistry,
|
||||||
samConversionResolver = SamConversionResolverImpl(storageManager, samWithReceiverResolvers = emptyList())
|
samConversionResolver = SamConversionResolverImpl(storageManager, samWithReceiverResolvers = emptyList())
|
||||||
@@ -72,5 +70,3 @@ class KlibMetadataDeserializerForDecompiler(
|
|||||||
private val LOG = Logger.getInstance(KlibMetadataDeserializerForDecompiler::class.java)
|
private val LOG = Logger.getInstance(KlibMetadataDeserializerForDecompiler::class.java)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun createLoggingErrorReporter(log: Logger) = LoggingErrorReporter(log)
|
|
||||||
+2
-3
@@ -23,8 +23,7 @@ class KotlinNativeMetadataDecompiler : KlibMetadataDecompiler<KlibMetadataVersio
|
|||||||
KlibMetaFileType.STUB_VERSION
|
KlibMetaFileType.STUB_VERSION
|
||||||
) {
|
) {
|
||||||
override fun doReadFile(file: VirtualFile): FileWithMetadata? {
|
override fun doReadFile(file: VirtualFile): FileWithMetadata? {
|
||||||
val fragment = KlibLoadingMetadataCache
|
val fragment = KlibLoadingMetadataCache.getInstance().getCachedPackageFragment(file) ?: return null
|
||||||
.getInstance().getCachedPackageFragment(file) ?: return null
|
return FileWithMetadata.Compatible(fragment) //todo: check version compatibility
|
||||||
return FileWithMetadata.Compatible(fragment, KlibMetadataSerializerProtocol) //todo: check version compatibility
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user