Serializer warning cleanup.
This commit is contained in:
committed by
alexander-gorshenev
parent
f63862e98d
commit
8c30ae38b6
+7
-7
@@ -81,7 +81,7 @@ internal class IrDescriptorDeserializer(val context: Context,
|
|||||||
|
|
||||||
val index = proto.getIndex()
|
val index = proto.getIndex()
|
||||||
val text = proto.getDebugText()
|
val text = proto.getDebugText()
|
||||||
val typeProto = localDeserializer.typeTable!![index]
|
val typeProto = localDeserializer.typeTable[index]
|
||||||
val type = localDeserializer.deserializeInlineType(typeProto)
|
val type = localDeserializer.deserializeInlineType(typeProto)
|
||||||
context.log("### deserialized Kotlin Type index=$index, text=$text:\t$type")
|
context.log("### deserialized Kotlin Type index=$index, text=$text:\t$type")
|
||||||
|
|
||||||
@@ -313,7 +313,7 @@ internal class IrDescriptorDeserializer(val context: Context,
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun parentByFqNameIndex(index: Int): DeclarationDescriptor {
|
fun parentByFqNameIndex(index: Int): DeclarationDescriptor {
|
||||||
val module = context.moduleDescriptor!!
|
val module = context.moduleDescriptor
|
||||||
val parent = nameResolver.getDescriptorByFqNameIndex(module, nameTable, index)
|
val parent = nameResolver.getDescriptorByFqNameIndex(module, nameTable, index)
|
||||||
return parent
|
return parent
|
||||||
|
|
||||||
@@ -327,7 +327,7 @@ internal class IrDescriptorDeserializer(val context: Context,
|
|||||||
KotlinDescriptor.Kind.CLASS -> {
|
KotlinDescriptor.Kind.CLASS -> {
|
||||||
val parentScope =
|
val parentScope =
|
||||||
parentMemberScopeByFqNameIndex(classOrPackage)
|
parentMemberScopeByFqNameIndex(classOrPackage)
|
||||||
val clazz = parentScope.getContributedClassifier(
|
val clazz = parentScope.getContributedClassifier(
|
||||||
Name.identifier(name), NoLookupLocation.FROM_BACKEND)
|
Name.identifier(name), NoLookupLocation.FROM_BACKEND)
|
||||||
return listOf(clazz!!)
|
return listOf(clazz!!)
|
||||||
|
|
||||||
@@ -351,10 +351,10 @@ internal class IrDescriptorDeserializer(val context: Context,
|
|||||||
|
|
||||||
fun selectFunction(
|
fun selectFunction(
|
||||||
functions: Collection<DeclarationDescriptor>,
|
functions: Collection<DeclarationDescriptor>,
|
||||||
proto: KonanIr.KotlinDescriptor ):
|
descriptorProto: KonanIr.KotlinDescriptor):
|
||||||
DeserializedSimpleFunctionDescriptor {
|
DeserializedSimpleFunctionDescriptor {
|
||||||
|
|
||||||
val originalIndex = proto.originalIndex
|
val originalIndex = descriptorProto.originalIndex
|
||||||
return functions.single() {
|
return functions.single() {
|
||||||
val proto = (it as DeserializedSimpleFunctionDescriptor).proto
|
val proto = (it as DeserializedSimpleFunctionDescriptor).proto
|
||||||
proto.getExtension(KonanLinkData.functionIndex) == originalIndex
|
proto.getExtension(KonanLinkData.functionIndex) == originalIndex
|
||||||
@@ -363,10 +363,10 @@ internal class IrDescriptorDeserializer(val context: Context,
|
|||||||
|
|
||||||
fun selectConstructor(
|
fun selectConstructor(
|
||||||
constructors: Collection<DeclarationDescriptor>,
|
constructors: Collection<DeclarationDescriptor>,
|
||||||
proto: KonanIr.KotlinDescriptor):
|
descriptorProto: KonanIr.KotlinDescriptor):
|
||||||
DeserializedClassConstructorDescriptor {
|
DeserializedClassConstructorDescriptor {
|
||||||
|
|
||||||
val originalIndex = proto.originalIndex
|
val originalIndex = descriptorProto.originalIndex
|
||||||
return constructors.single {
|
return constructors.single {
|
||||||
val proto = (it as DeserializedClassConstructorDescriptor).proto
|
val proto = (it as DeserializedClassConstructorDescriptor).proto
|
||||||
proto.getExtension(KonanLinkData.constructorIndex) == originalIndex
|
proto.getExtension(KonanLinkData.constructorIndex) == originalIndex
|
||||||
|
|||||||
+2
-2
@@ -40,7 +40,7 @@ internal class IrDescriptorSerializer(
|
|||||||
var rootFunction: FunctionDescriptor) {
|
var rootFunction: FunctionDescriptor) {
|
||||||
|
|
||||||
fun serializeKotlinType(type: KotlinType): KonanIr.KotlinType {
|
fun serializeKotlinType(type: KotlinType): KonanIr.KotlinType {
|
||||||
val index = this.typeSerializer!!(type)
|
val index = this.typeSerializer(type)
|
||||||
val proto = KonanIr.KotlinType.newBuilder()
|
val proto = KonanIr.KotlinType.newBuilder()
|
||||||
.setIndex(index)
|
.setIndex(index)
|
||||||
.setDebugText(type.toString())
|
.setDebugText(type.toString())
|
||||||
@@ -94,7 +94,7 @@ internal class IrDescriptorSerializer(
|
|||||||
proto.setExtensionReceiverIndex(
|
proto.setExtensionReceiverIndex(
|
||||||
descriptorTable.indexByValue(extensionReceiver))
|
descriptorTable.indexByValue(extensionReceiver))
|
||||||
proto.setExtensionReceiverType(
|
proto.setExtensionReceiverType(
|
||||||
serializeKotlinType(extensionReceiver.type!!))
|
serializeKotlinType(extensionReceiver.type))
|
||||||
}
|
}
|
||||||
|
|
||||||
proto.setType(serializeKotlinType(
|
proto.setType(serializeKotlinType(
|
||||||
|
|||||||
-1
@@ -36,7 +36,6 @@ class KonanClassDataFinder(
|
|||||||
) : ClassDataFinder {
|
) : ClassDataFinder {
|
||||||
override fun findClassData(classId: ClassId): ClassDataWithSource? {
|
override fun findClassData(classId: ClassId): ClassDataWithSource? {
|
||||||
val proto = fragment.classes
|
val proto = fragment.classes
|
||||||
val classList = proto.getClassesList()
|
|
||||||
val nameList = proto.getClassNameList()
|
val nameList = proto.getClassNameList()
|
||||||
|
|
||||||
val index = nameList.indexOfFirst({
|
val index = nameList.indexOfFirst({
|
||||||
|
|||||||
+1
-1
@@ -252,7 +252,7 @@ message IrClass {
|
|||||||
}
|
}
|
||||||
|
|
||||||
message IrEnumEntry {
|
message IrEnumEntry {
|
||||||
optional IrExpression initializer = 1;
|
required IrExpression initializer = 1;
|
||||||
optional IrDeclaration corresponding_class = 2;
|
optional IrDeclaration corresponding_class = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -53,7 +53,7 @@ class KonanPackageFragment( val proto: KonanLinkData.PackageFragment,
|
|||||||
if (!classId.isNestedClass) shortName else null
|
if (!classId.isNestedClass) shortName else null
|
||||||
}
|
}
|
||||||
|
|
||||||
return names ?: listOf()
|
return names
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+11
-11
@@ -49,15 +49,15 @@ internal class KonanSerializerExtension(val context: Context, val util: KonanSer
|
|||||||
override val stringTable = KonanStringTable()
|
override val stringTable = KonanStringTable()
|
||||||
override fun shouldUseTypeTable(): Boolean = true
|
override fun shouldUseTypeTable(): Boolean = true
|
||||||
|
|
||||||
override fun serializeType(descriptor: KotlinType, proto: ProtoBuf.Type.Builder) {
|
override fun serializeType(type: KotlinType, proto: ProtoBuf.Type.Builder) {
|
||||||
|
|
||||||
proto.setExtension(KonanLinkData.typeText, descriptor.toString())
|
proto.setExtension(KonanLinkData.typeText, type.toString())
|
||||||
|
|
||||||
super.serializeType(descriptor, proto)
|
super.serializeType(type, proto)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun serializeTypeParameter(descriptor: TypeParameterDescriptor, proto: ProtoBuf.TypeParameter.Builder) {
|
override fun serializeTypeParameter(typeParameter: TypeParameterDescriptor, proto: ProtoBuf.TypeParameter.Builder) {
|
||||||
super.serializeTypeParameter(descriptor, proto)
|
super.serializeTypeParameter(typeParameter, proto)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun serializeValueParameter(descriptor: ValueParameterDescriptor, proto: ProtoBuf.ValueParameter.Builder) {
|
override fun serializeValueParameter(descriptor: ValueParameterDescriptor, proto: ProtoBuf.ValueParameter.Builder) {
|
||||||
@@ -131,21 +131,21 @@ internal class KonanSerializerExtension(val context: Context, val util: KonanSer
|
|||||||
backingFieldClass, emptyMap(), SourceElement.NO_SOURCE)
|
backingFieldClass, emptyMap(), SourceElement.NO_SOURCE)
|
||||||
|
|
||||||
|
|
||||||
override fun serializeProperty(property: PropertyDescriptor, proto: ProtoBuf.Property.Builder) {
|
override fun serializeProperty(descriptor: PropertyDescriptor, proto: ProtoBuf.Property.Builder) {
|
||||||
val parentIndex = property.parentFqNameIndex()
|
val parentIndex = descriptor.parentFqNameIndex()
|
||||||
proto.setExtension(KonanLinkData.propertyParent, parentIndex)
|
proto.setExtension(KonanLinkData.propertyParent, parentIndex)
|
||||||
val variable = originalVariables[property]
|
val variable = originalVariables[descriptor]
|
||||||
if (variable != null) {
|
if (variable != null) {
|
||||||
proto.setExtension(KonanLinkData.usedAsVariable, true)
|
proto.setExtension(KonanLinkData.usedAsVariable, true)
|
||||||
proto.setExtension(KonanLinkData.propertyIndex, inlineDescriptorTable.indexByValue(variable))
|
proto.setExtension(KonanLinkData.propertyIndex, inlineDescriptorTable.indexByValue(variable))
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
proto.setExtension(KonanLinkData.propertyIndex, inlineDescriptorTable.indexByValue(property))
|
proto.setExtension(KonanLinkData.propertyIndex, inlineDescriptorTable.indexByValue(descriptor))
|
||||||
}
|
}
|
||||||
|
|
||||||
super.serializeProperty(property, proto)
|
super.serializeProperty(descriptor, proto)
|
||||||
|
|
||||||
if (context.ir.propertiesWithBackingFields.contains(property)) {
|
if (context.ir.propertiesWithBackingFields.contains(descriptor)) {
|
||||||
proto.addExtension(KonanLinkData.propertyAnnotation,
|
proto.addExtension(KonanLinkData.propertyAnnotation,
|
||||||
annotationSerializer.serializeAnnotation(backingFieldAnnotation))
|
annotationSerializer.serializeAnnotation(backingFieldAnnotation))
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -64,7 +64,6 @@ class LocalDeclarationDeserializer(val rootFunction: FunctionDescriptor, val mod
|
|||||||
fun getDescriptorByFqNameIndex(module: ModuleDescriptor, fqNameIndex: Int): DeclarationDescriptor {
|
fun getDescriptorByFqNameIndex(module: ModuleDescriptor, fqNameIndex: Int): DeclarationDescriptor {
|
||||||
|
|
||||||
val packageName = nameResolver.getPackageFqName(fqNameIndex)
|
val packageName = nameResolver.getPackageFqName(fqNameIndex)
|
||||||
val shortName = nameResolver.getString(fqNameIndex)
|
|
||||||
// Here we using internals of NameresolverImpl.
|
// Here we using internals of NameresolverImpl.
|
||||||
val proto = nameTable.getQualifiedName(fqNameIndex)
|
val proto = nameTable.getQualifiedName(fqNameIndex)
|
||||||
when (proto.kind) {
|
when (proto.kind) {
|
||||||
@@ -73,6 +72,7 @@ class LocalDeclarationDeserializer(val rootFunction: FunctionDescriptor, val mod
|
|||||||
return module.findClassAcrossModuleDependencies(nameResolver.getClassId(fqNameIndex))!!
|
return module.findClassAcrossModuleDependencies(nameResolver.getClassId(fqNameIndex))!!
|
||||||
QualifiedName.Kind.PACKAGE ->
|
QualifiedName.Kind.PACKAGE ->
|
||||||
return module.getPackage(packageName)
|
return module.getPackage(packageName)
|
||||||
|
else -> error("Unexpected descriptor kind.")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+12
-15
@@ -50,7 +50,7 @@ internal class IrSerializer(val context: Context,
|
|||||||
fun serializeInlineBody(): String {
|
fun serializeInlineBody(): String {
|
||||||
val declaration = context.ir.originalModuleIndex.functions[rootFunction]!!
|
val declaration = context.ir.originalModuleIndex.functions[rootFunction]!!
|
||||||
context.log("INLINE: ${ir2stringWhole(declaration)}")
|
context.log("INLINE: ${ir2stringWhole(declaration)}")
|
||||||
return encodeDeclaration(declaration as IrFunction)
|
return encodeDeclaration(declaration)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun serializeKotlinType(type: KotlinType): KonanIr.KotlinType {
|
fun serializeKotlinType(type: KotlinType): KonanIr.KotlinType {
|
||||||
@@ -174,7 +174,7 @@ internal class IrSerializer(val context: Context,
|
|||||||
assert(it.varargElementType != null ||
|
assert(it.varargElementType != null ||
|
||||||
it.declaresDefaultValue())
|
it.declaresDefaultValue())
|
||||||
} else {
|
} else {
|
||||||
val arg = actual!!
|
val arg = actual
|
||||||
val argProto = serializeExpression(arg)
|
val argProto = serializeExpression(arg)
|
||||||
proto.addValueArgument(argProto)
|
proto.addValueArgument(argProto)
|
||||||
}
|
}
|
||||||
@@ -366,7 +366,7 @@ internal class IrSerializer(val context: Context,
|
|||||||
if (label != null) {
|
if (label != null) {
|
||||||
proto.setLabel(label)
|
proto.setLabel(label)
|
||||||
}
|
}
|
||||||
val loopId = loopIndex[expression.loop!!]!!
|
val loopId = loopIndex[expression.loop]!!
|
||||||
proto.setLoopId(loopId)
|
proto.setLoopId(loopId)
|
||||||
|
|
||||||
return proto.build()
|
return proto.build()
|
||||||
@@ -378,7 +378,7 @@ internal class IrSerializer(val context: Context,
|
|||||||
if (label != null) {
|
if (label != null) {
|
||||||
proto.setLabel(label)
|
proto.setLabel(label)
|
||||||
}
|
}
|
||||||
val loopId = loopIndex[expression.loop!!]!!
|
val loopId = loopIndex[expression.loop]!!
|
||||||
proto.setLoopId(loopId)
|
proto.setLoopId(loopId)
|
||||||
|
|
||||||
return proto.build()
|
return proto.build()
|
||||||
@@ -490,9 +490,7 @@ internal class IrSerializer(val context: Context,
|
|||||||
fun serializeIrEnumEntry(enumEntry: IrEnumEntry): KonanIr.IrEnumEntry {
|
fun serializeIrEnumEntry(enumEntry: IrEnumEntry): KonanIr.IrEnumEntry {
|
||||||
val proto = KonanIr.IrEnumEntry.newBuilder()
|
val proto = KonanIr.IrEnumEntry.newBuilder()
|
||||||
val initializer = enumEntry.initializerExpression
|
val initializer = enumEntry.initializerExpression
|
||||||
if (initializer != null) {
|
proto.setInitializer(serializeExpression(initializer))
|
||||||
proto.setInitializer(serializeExpression(initializer))
|
|
||||||
}
|
|
||||||
val correspondingClass = enumEntry.correspondingClass
|
val correspondingClass = enumEntry.correspondingClass
|
||||||
if (correspondingClass != null) {
|
if (correspondingClass != null) {
|
||||||
proto.setCorrespondingClass(serializeDeclaration(correspondingClass))
|
proto.setCorrespondingClass(serializeDeclaration(correspondingClass))
|
||||||
@@ -566,7 +564,7 @@ internal class IrDeserializer(val context: Context,
|
|||||||
|
|
||||||
val loopIndex = mutableMapOf<Int, IrLoop>()
|
val loopIndex = mutableMapOf<Int, IrLoop>()
|
||||||
|
|
||||||
val localDeserializer = LocalDeclarationDeserializer(rootFunction, context.moduleDescriptor!!)
|
val localDeserializer = LocalDeclarationDeserializer(rootFunction, context.moduleDescriptor)
|
||||||
|
|
||||||
val descriptorDeserializer = IrDescriptorDeserializer(
|
val descriptorDeserializer = IrDescriptorDeserializer(
|
||||||
context, descriptorIndex, rootFunction, localDeserializer)
|
context, descriptorIndex, rootFunction, localDeserializer)
|
||||||
@@ -657,7 +655,7 @@ internal class IrDeserializer(val context: Context,
|
|||||||
return block
|
return block
|
||||||
}
|
}
|
||||||
|
|
||||||
fun deserializeMemberAccessCommon(access: IrMemberAccessExpression, descriptor: CallableDescriptor, proto: KonanIr.MemberAccessCommon) {
|
fun deserializeMemberAccessCommon(access: IrMemberAccessExpression, proto: KonanIr.MemberAccessCommon) {
|
||||||
|
|
||||||
proto.valueArgumentList.mapIndexed { i, expr ->
|
proto.valueArgumentList.mapIndexed { i, expr ->
|
||||||
access.putValueArgument(i, deserializeExpression(expr))
|
access.putValueArgument(i, deserializeExpression(expr))
|
||||||
@@ -689,8 +687,9 @@ internal class IrDeserializer(val context: Context,
|
|||||||
IrUnaryPrimitiveImpl(start, end, null, descriptor)
|
IrUnaryPrimitiveImpl(start, end, null, descriptor)
|
||||||
KonanIr.IrCall.Primitive.BINARY ->
|
KonanIr.IrCall.Primitive.BINARY ->
|
||||||
IrBinaryPrimitiveImpl(start, end, null, descriptor)
|
IrBinaryPrimitiveImpl(start, end, null, descriptor)
|
||||||
|
else -> error("Unexpected primitive IrCall.")
|
||||||
}
|
}
|
||||||
deserializeMemberAccessCommon(call, descriptor, proto.memberAccess)
|
deserializeMemberAccessCommon(call, proto.memberAccess)
|
||||||
return call
|
return call
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -709,14 +708,14 @@ internal class IrDeserializer(val context: Context,
|
|||||||
|
|
||||||
val call = IrDelegatingConstructorCallImpl(start, end, descriptor, typeArgs)
|
val call = IrDelegatingConstructorCallImpl(start, end, descriptor, typeArgs)
|
||||||
|
|
||||||
deserializeMemberAccessCommon(call, descriptor, proto.memberAccess)
|
deserializeMemberAccessCommon(call, proto.memberAccess)
|
||||||
return call
|
return call
|
||||||
}
|
}
|
||||||
|
|
||||||
fun deserializeEnumConstructorCall(proto: KonanIr.IrEnumConstructorCall, start: Int, end: Int, type: KotlinType): IrEnumConstructorCall {
|
fun deserializeEnumConstructorCall(proto: KonanIr.IrEnumConstructorCall, start: Int, end: Int, type: KotlinType): IrEnumConstructorCall {
|
||||||
val descriptor = deserializeDescriptor(proto.getDescriptor()) as ClassConstructorDescriptor
|
val descriptor = deserializeDescriptor(proto.getDescriptor()) as ClassConstructorDescriptor
|
||||||
val call = IrEnumConstructorCallImpl(start, end, descriptor)
|
val call = IrEnumConstructorCallImpl(start, end, descriptor)
|
||||||
deserializeMemberAccessCommon(call, descriptor, proto.memberAccess)
|
deserializeMemberAccessCommon(call, proto.memberAccess)
|
||||||
return call
|
return call
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -991,9 +990,7 @@ internal class IrDeserializer(val context: Context,
|
|||||||
if (proto.hasCorrespondingClass()) {
|
if (proto.hasCorrespondingClass()) {
|
||||||
enumEntry.correspondingClass = deserializeDeclaration(proto.correspondingClass) as IrClass
|
enumEntry.correspondingClass = deserializeDeclaration(proto.correspondingClass) as IrClass
|
||||||
}
|
}
|
||||||
if (proto.hasInitializer()) {
|
enumEntry.initializerExpression = deserializeExpression(proto.initializer)
|
||||||
enumEntry.initializerExpression = deserializeExpression(proto.initializer)
|
|
||||||
}
|
|
||||||
|
|
||||||
return enumEntry
|
return enumEntry
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user