JS: serialize .kjsm package-wise, adapt decompiler & stub builder
Instead of multiple .kjsm files for different classes and .kotlin_string_table, .kotlin_file_table, .kotlin_classes files for each package, serialize the contents of each package to a single foo/bar/baz/baz.kjsm file. The short name of the file is the last segment in the FQ name of the package, or "root-package" if the package is root. There are two main reasons for this change: 1) Such structure takes less space, is more IO-friendly and will not cause multiple exceptions as the old one, where we sometimes tried to read non-existing files 2) This is exactly the same format that is used to serialize built-in declarations (.kotlin_builtins) at the moment, which will allow us to reuse some code Also write a separate Header protobuf message to the beginning of the .kjsm file. This will be used as arguments of the kotlin.Metadata annotation are used in the JVM-specific parts of the compiler: to be able to provide some general information about the binary file without parsing the whole protobuf data. This commit breaks decompiled text & stub builder consistency tests. This is OK because they're removed in a future commit. Fixes EA-79605, EA-81947, EA-84277 and maybe EA-86787 #KT-10894 Fixed #KT-14124 Fixed #KT-15755 Fixed
This commit is contained in:
+1
-10
@@ -21,7 +21,6 @@ import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.serialization.ProtoBuf
|
||||
import org.jetbrains.kotlin.serialization.ProtoBuf.QualifiedNameTable.QualifiedName
|
||||
import java.io.InputStream
|
||||
import java.util.*
|
||||
|
||||
class NameResolverImpl(
|
||||
@@ -29,7 +28,7 @@ class NameResolverImpl(
|
||||
private val qualifiedNames: ProtoBuf.QualifiedNameTable
|
||||
) : NameResolver {
|
||||
|
||||
override fun getString(index: Int) = strings.getString(index)
|
||||
override fun getString(index: Int): String = strings.getString(index)
|
||||
|
||||
override fun getName(index: Int) = Name.guessByFirstCharacter(strings.getString(index))
|
||||
|
||||
@@ -65,12 +64,4 @@ class NameResolverImpl(
|
||||
}
|
||||
return Triple(packageNameSegments, relativeClassNameSegments, local)
|
||||
}
|
||||
|
||||
companion object {
|
||||
fun read(stream: InputStream): NameResolverImpl {
|
||||
val simpleNames = ProtoBuf.StringTable.parseDelimitedFrom(stream)
|
||||
val qualifiedNames = ProtoBuf.QualifiedNameTable.parseDelimitedFrom(stream)
|
||||
return NameResolverImpl(simpleNames, qualifiedNames)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user