JVM_IR: Supply fake file name to signatures of file local declarations
This commit is contained in:
committed by
TeamCityServer
parent
225705a237
commit
08b950fc2a
+2
-2
@@ -7,7 +7,7 @@ package org.jetbrains.kotlin.backend.jvm
|
||||
|
||||
import org.jetbrains.kotlin.backend.common.ir.createImplicitParameterDeclarationWithWrappedDescriptor
|
||||
import org.jetbrains.kotlin.backend.common.ir.createParameterDeclarations
|
||||
import org.jetbrains.kotlin.backend.common.serialization.signature.IdSignatureSerializer
|
||||
import org.jetbrains.kotlin.backend.common.serialization.signature.PublicIdSignatureComputer
|
||||
import org.jetbrains.kotlin.backend.jvm.lower.SingletonObjectJvmStaticTransformer
|
||||
import org.jetbrains.kotlin.backend.jvm.serialization.deserializeClassFromByteArray
|
||||
import org.jetbrains.kotlin.backend.jvm.serialization.deserializeIrFileFromByteArray
|
||||
@@ -211,7 +211,7 @@ open class JvmGeneratorExtensionsImpl(
|
||||
}
|
||||
|
||||
override fun registerDeclarations(symbolTable: SymbolTable) {
|
||||
val signatureComputer = IdSignatureSerializer(JvmIrMangler)
|
||||
val signatureComputer = PublicIdSignatureComputer(JvmIrMangler)
|
||||
specialAnnotationConstructors.forEach { constructor ->
|
||||
symbolTable.declareConstructorWithSignature(signatureComputer.composePublicIdSignature(constructor), constructor.symbol)
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ message XStatementOrExpression {
|
||||
}
|
||||
|
||||
message AuxTables {
|
||||
// TODO: optimize the representation.
|
||||
repeated bytes type = 1;
|
||||
repeated bytes signature = 2;
|
||||
repeated bytes string = 3;
|
||||
|
||||
+1
-2
@@ -6,7 +6,6 @@
|
||||
package org.jetbrains.kotlin.backend.jvm.serialization
|
||||
|
||||
import org.jetbrains.kotlin.backend.common.serialization.GlobalDeclarationTable
|
||||
import org.jetbrains.kotlin.backend.common.serialization.signature.IdSignatureSerializer
|
||||
import org.jetbrains.kotlin.ir.backend.jvm.serialization.JvmIrMangler
|
||||
|
||||
class JvmGlobalDeclarationTable : GlobalDeclarationTable(IdSignatureSerializer(JvmIrMangler), JvmIrMangler)
|
||||
class JvmGlobalDeclarationTable : GlobalDeclarationTable(JvmIrMangler)
|
||||
-1
@@ -13,7 +13,6 @@ import org.jetbrains.kotlin.ir.declarations.IrClass
|
||||
import org.jetbrains.kotlin.ir.declarations.IrFile
|
||||
import org.jetbrains.kotlin.ir.symbols.IrSymbol
|
||||
import org.jetbrains.kotlin.ir.util.IrMessageLogger
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.protobuf.ByteString
|
||||
|
||||
class JvmIrSerializerSession(
|
||||
|
||||
+18
-15
@@ -9,25 +9,20 @@ import org.jetbrains.kotlin.backend.common.overrides.DefaultFakeOverrideClassFil
|
||||
import org.jetbrains.kotlin.backend.common.overrides.FakeOverrideBuilder
|
||||
import org.jetbrains.kotlin.backend.common.overrides.FakeOverrideDeclarationTable
|
||||
import org.jetbrains.kotlin.backend.common.overrides.FileLocalAwareLinker
|
||||
import org.jetbrains.kotlin.backend.common.serialization.DescriptorByIdSignatureFinder
|
||||
import org.jetbrains.kotlin.backend.common.serialization.IrDeclarationDeserializer
|
||||
import org.jetbrains.kotlin.backend.common.serialization.IrLibraryFile
|
||||
import org.jetbrains.kotlin.backend.common.serialization.IrSymbolDeserializer
|
||||
import org.jetbrains.kotlin.backend.common.serialization.*
|
||||
import org.jetbrains.kotlin.backend.common.serialization.encodings.BinarySymbolData
|
||||
import org.jetbrains.kotlin.backend.common.serialization.signature.IdSignatureSerializer
|
||||
import org.jetbrains.kotlin.backend.jvm.serialization.proto.JvmIr
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.ir.IrElement
|
||||
import org.jetbrains.kotlin.ir.backend.jvm.serialization.JvmDescriptorMangler
|
||||
import org.jetbrains.kotlin.ir.backend.jvm.serialization.JvmIrMangler
|
||||
import org.jetbrains.kotlin.ir.declarations.*
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrFileImpl
|
||||
import org.jetbrains.kotlin.ir.declarations.lazy.LazyIrFactory
|
||||
import org.jetbrains.kotlin.ir.descriptors.IrBuiltIns
|
||||
import org.jetbrains.kotlin.ir.symbols.*
|
||||
import org.jetbrains.kotlin.ir.util.DeclarationStubGenerator
|
||||
import org.jetbrains.kotlin.ir.util.ExternalDependenciesGenerator
|
||||
import org.jetbrains.kotlin.ir.util.IdSignature
|
||||
import org.jetbrains.kotlin.ir.util.SymbolTable
|
||||
import org.jetbrains.kotlin.ir.symbols.impl.IrFileSymbolImpl
|
||||
import org.jetbrains.kotlin.ir.util.*
|
||||
import org.jetbrains.kotlin.ir.visitors.IrElementVisitorVoid
|
||||
import org.jetbrains.kotlin.ir.visitors.acceptChildrenVoid
|
||||
import org.jetbrains.kotlin.protobuf.ByteString
|
||||
@@ -53,9 +48,14 @@ fun deserializeClassFromByteArray(
|
||||
JvmDescriptorMangler(null),
|
||||
DescriptorByIdSignatureFinder.LookupMode.MODULE_WITH_DEPENDENCIES
|
||||
)
|
||||
|
||||
// Only needed for local signature computation.
|
||||
val dummyIrFile = IrFileImpl(NaiveSourceBasedFileEntryImpl("<unknown>"), IrFileSymbolImpl(), irClass.packageFqName!!)
|
||||
|
||||
val symbolDeserializer = IrSymbolDeserializer(
|
||||
symbolTable,
|
||||
irLibraryFile,
|
||||
fileSymbol = dummyIrFile.symbol,
|
||||
/* TODO */ actuals = emptyList(),
|
||||
enqueueLocalTopLevelDeclaration = {}, // just link to it in symbolTable
|
||||
handleExpectActualMapping = { _, _ -> TODO() },
|
||||
@@ -103,9 +103,14 @@ fun deserializeIrFileFromByteArray(
|
||||
JvmDescriptorMangler(null),
|
||||
DescriptorByIdSignatureFinder.LookupMode.MODULE_WITH_DEPENDENCIES
|
||||
)
|
||||
|
||||
// Only needed for local signature computation.
|
||||
val dummyIrFile = IrFileImpl(NaiveSourceBasedFileEntryImpl("<unknown>"), IrFileSymbolImpl(), facadeClass.packageFqName!!)
|
||||
|
||||
val symbolDeserializer = IrSymbolDeserializer(
|
||||
symbolTable,
|
||||
irLibraryFile,
|
||||
fileSymbol = dummyIrFile.symbol,
|
||||
/* TODO */ actuals = emptyList(),
|
||||
enqueueLocalTopLevelDeclaration = {}, // just link to it in symbolTable
|
||||
handleExpectActualMapping = { _, _ -> TODO() },
|
||||
@@ -193,7 +198,6 @@ fun makeSimpleFakeOverrideBuilder(
|
||||
irBuiltIns: IrBuiltIns,
|
||||
symbolDeserializer: IrSymbolDeserializer
|
||||
): FakeOverrideBuilder {
|
||||
val signatureSerializer = IdSignatureSerializer(JvmIrMangler)
|
||||
return FakeOverrideBuilder(
|
||||
object : FileLocalAwareLinker {
|
||||
override fun tryReferencingPropertyByLocalSignature(parent: IrDeclaration, idSignature: IdSignature): IrPropertySymbol =
|
||||
@@ -205,9 +209,9 @@ fun makeSimpleFakeOverrideBuilder(
|
||||
symbolDeserializer.referenceSimpleFunctionByLocalSignature(idSignature)
|
||||
},
|
||||
symbolTable,
|
||||
signatureSerializer,
|
||||
JvmIrMangler,
|
||||
irBuiltIns,
|
||||
fakeOverrideDeclarationTable = PrePopulatedDeclarationTable(symbolDeserializer.deserializedSymbols, signatureSerializer)
|
||||
fakeOverrideDeclarationTable = PrePopulatedDeclarationTable(symbolDeserializer.deserializedSymbols)
|
||||
)
|
||||
}
|
||||
|
||||
@@ -233,9 +237,8 @@ private fun buildFakeOverridesForLocalClasses(
|
||||
}
|
||||
|
||||
class PrePopulatedDeclarationTable(
|
||||
sig2symbol: Map<IdSignature, IrSymbol>,
|
||||
signatureSerializer: IdSignatureSerializer
|
||||
) : FakeOverrideDeclarationTable(signatureSerializer) {
|
||||
sig2symbol: Map<IdSignature, IrSymbol>
|
||||
) : FakeOverrideDeclarationTable(JvmIrMangler) {
|
||||
private val symbol2Sig = sig2symbol.entries.associate { (x, y) -> y to x }
|
||||
|
||||
override fun tryComputeBackendSpecificSignature(declaration: IrDeclaration): IdSignature? {
|
||||
|
||||
+52
@@ -599,14 +599,26 @@ public final class JvmIr {
|
||||
|
||||
/**
|
||||
* <code>repeated bytes type = 1;</code>
|
||||
*
|
||||
* <pre>
|
||||
* TODO: optimize the representation.
|
||||
* </pre>
|
||||
*/
|
||||
java.util.List<org.jetbrains.kotlin.protobuf.ByteString> getTypeList();
|
||||
/**
|
||||
* <code>repeated bytes type = 1;</code>
|
||||
*
|
||||
* <pre>
|
||||
* TODO: optimize the representation.
|
||||
* </pre>
|
||||
*/
|
||||
int getTypeCount();
|
||||
/**
|
||||
* <code>repeated bytes type = 1;</code>
|
||||
*
|
||||
* <pre>
|
||||
* TODO: optimize the representation.
|
||||
* </pre>
|
||||
*/
|
||||
org.jetbrains.kotlin.protobuf.ByteString getType(int index);
|
||||
|
||||
@@ -780,6 +792,10 @@ public final class JvmIr {
|
||||
private java.util.List<org.jetbrains.kotlin.protobuf.ByteString> type_;
|
||||
/**
|
||||
* <code>repeated bytes type = 1;</code>
|
||||
*
|
||||
* <pre>
|
||||
* TODO: optimize the representation.
|
||||
* </pre>
|
||||
*/
|
||||
public java.util.List<org.jetbrains.kotlin.protobuf.ByteString>
|
||||
getTypeList() {
|
||||
@@ -787,12 +803,20 @@ public final class JvmIr {
|
||||
}
|
||||
/**
|
||||
* <code>repeated bytes type = 1;</code>
|
||||
*
|
||||
* <pre>
|
||||
* TODO: optimize the representation.
|
||||
* </pre>
|
||||
*/
|
||||
public int getTypeCount() {
|
||||
return type_.size();
|
||||
}
|
||||
/**
|
||||
* <code>repeated bytes type = 1;</code>
|
||||
*
|
||||
* <pre>
|
||||
* TODO: optimize the representation.
|
||||
* </pre>
|
||||
*/
|
||||
public org.jetbrains.kotlin.protobuf.ByteString getType(int index) {
|
||||
return type_.get(index);
|
||||
@@ -1166,6 +1190,10 @@ public final class JvmIr {
|
||||
}
|
||||
/**
|
||||
* <code>repeated bytes type = 1;</code>
|
||||
*
|
||||
* <pre>
|
||||
* TODO: optimize the representation.
|
||||
* </pre>
|
||||
*/
|
||||
public java.util.List<org.jetbrains.kotlin.protobuf.ByteString>
|
||||
getTypeList() {
|
||||
@@ -1173,18 +1201,30 @@ public final class JvmIr {
|
||||
}
|
||||
/**
|
||||
* <code>repeated bytes type = 1;</code>
|
||||
*
|
||||
* <pre>
|
||||
* TODO: optimize the representation.
|
||||
* </pre>
|
||||
*/
|
||||
public int getTypeCount() {
|
||||
return type_.size();
|
||||
}
|
||||
/**
|
||||
* <code>repeated bytes type = 1;</code>
|
||||
*
|
||||
* <pre>
|
||||
* TODO: optimize the representation.
|
||||
* </pre>
|
||||
*/
|
||||
public org.jetbrains.kotlin.protobuf.ByteString getType(int index) {
|
||||
return type_.get(index);
|
||||
}
|
||||
/**
|
||||
* <code>repeated bytes type = 1;</code>
|
||||
*
|
||||
* <pre>
|
||||
* TODO: optimize the representation.
|
||||
* </pre>
|
||||
*/
|
||||
public Builder setType(
|
||||
int index, org.jetbrains.kotlin.protobuf.ByteString value) {
|
||||
@@ -1198,6 +1238,10 @@ public final class JvmIr {
|
||||
}
|
||||
/**
|
||||
* <code>repeated bytes type = 1;</code>
|
||||
*
|
||||
* <pre>
|
||||
* TODO: optimize the representation.
|
||||
* </pre>
|
||||
*/
|
||||
public Builder addType(org.jetbrains.kotlin.protobuf.ByteString value) {
|
||||
if (value == null) {
|
||||
@@ -1210,6 +1254,10 @@ public final class JvmIr {
|
||||
}
|
||||
/**
|
||||
* <code>repeated bytes type = 1;</code>
|
||||
*
|
||||
* <pre>
|
||||
* TODO: optimize the representation.
|
||||
* </pre>
|
||||
*/
|
||||
public Builder addAllType(
|
||||
java.lang.Iterable<? extends org.jetbrains.kotlin.protobuf.ByteString> values) {
|
||||
@@ -1221,6 +1269,10 @@ public final class JvmIr {
|
||||
}
|
||||
/**
|
||||
* <code>repeated bytes type = 1;</code>
|
||||
*
|
||||
* <pre>
|
||||
* TODO: optimize the representation.
|
||||
* </pre>
|
||||
*/
|
||||
public Builder clearType() {
|
||||
type_ = java.util.Collections.emptyList();
|
||||
|
||||
Reference in New Issue
Block a user