IrDelegatedProperty and IrDelegatedPropertyReference were missing from the serialization
This commit is contained in:
committed by
alexander-gorshenev
parent
e07821ca75
commit
ce6cda631d
@@ -246,6 +246,12 @@ message IrFunctionReference {
|
||||
required MemberAccessCommon member_access = 3;
|
||||
}
|
||||
|
||||
message IrLocalDelegatedPropertyReference {
|
||||
required IrSymbol delegate = 1;
|
||||
optional IrSymbol getter = 2;
|
||||
optional IrSymbol setter = 3;
|
||||
required IrSymbol symbol = 4;
|
||||
}
|
||||
|
||||
message IrPropertyReference {
|
||||
optional IrSymbol field = 1;
|
||||
@@ -478,6 +484,7 @@ message IrOperation {
|
||||
IrWhile while = 28;
|
||||
IrDynamicMemberExpression dynamic_member = 29;
|
||||
IrDynamicOperatorExpression dynamic_operator = 30;
|
||||
IrLocalDelegatedPropertyReference local_delegated_property_reference = 31;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -551,6 +558,16 @@ message IrField {
|
||||
required IrTypeIndex type = 8;
|
||||
}
|
||||
|
||||
message IrLocalDelegatedProperty {
|
||||
required String name = 1;
|
||||
required IrTypeIndex type = 2;
|
||||
required bool is_var = 3;
|
||||
required IrVariable delegate = 4;
|
||||
optional IrFunction getter = 5;
|
||||
optional IrFunction setter = 6;
|
||||
required IrSymbol symbol = 7;
|
||||
}
|
||||
|
||||
message IrProperty {
|
||||
optional DescriptorReference descriptor_reference = 1; // IrProperty doesn't have a symbol at all. Preserve this rudiment for now.
|
||||
required String name = 2;
|
||||
@@ -661,6 +678,7 @@ message IrDeclarator {
|
||||
IrTypeParameter ir_type_parameter = 9;
|
||||
IrVariable ir_variable = 10;
|
||||
IrValueParameter ir_value_parameter = 11;
|
||||
IrLocalDelegatedProperty ir_local_delegated_property = 12;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+62
-7
@@ -9,6 +9,14 @@ import org.jetbrains.kotlin.backend.common.LoggingContext
|
||||
import org.jetbrains.kotlin.backend.common.descriptors.*
|
||||
import org.jetbrains.kotlin.backend.common.ir.DeclarationFactory
|
||||
import org.jetbrains.kotlin.backend.common.ir.ir2string
|
||||
import org.jetbrains.kotlin.backend.common.serialization.KotlinIr.IrConst.ValueCase.*
|
||||
import org.jetbrains.kotlin.backend.common.serialization.KotlinIr.IrDeclarator.DeclaratorCase.*
|
||||
import org.jetbrains.kotlin.backend.common.serialization.KotlinIr.IrOperation.OperationCase.*
|
||||
import org.jetbrains.kotlin.backend.common.serialization.KotlinIr.IrStatement.StatementCase
|
||||
import org.jetbrains.kotlin.backend.common.serialization.KotlinIr.IrType.KindCase.*
|
||||
import org.jetbrains.kotlin.backend.common.serialization.KotlinIr.IrTypeArgument.KindCase.STAR
|
||||
import org.jetbrains.kotlin.backend.common.serialization.KotlinIr.IrTypeArgument.KindCase.TYPE
|
||||
import org.jetbrains.kotlin.backend.common.serialization.KotlinIr.IrVarargElement.VarargElementCase
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.ir.IrElement
|
||||
import org.jetbrains.kotlin.ir.IrStatement
|
||||
@@ -23,13 +31,6 @@ import org.jetbrains.kotlin.ir.types.*
|
||||
import org.jetbrains.kotlin.ir.types.impl.*
|
||||
import org.jetbrains.kotlin.ir.util.SymbolTable
|
||||
import org.jetbrains.kotlin.ir.util.render
|
||||
import org.jetbrains.kotlin.backend.common.serialization.KotlinIr.IrStatement.*
|
||||
import org.jetbrains.kotlin.backend.common.serialization.KotlinIr.IrOperation.OperationCase.*
|
||||
import org.jetbrains.kotlin.backend.common.serialization.KotlinIr.IrConst.ValueCase.*
|
||||
import org.jetbrains.kotlin.backend.common.serialization.KotlinIr.IrDeclarator.DeclaratorCase.*
|
||||
import org.jetbrains.kotlin.backend.common.serialization.KotlinIr.IrType.KindCase.*
|
||||
import org.jetbrains.kotlin.backend.common.serialization.KotlinIr.IrVarargElement.VarargElementCase
|
||||
import org.jetbrains.kotlin.backend.common.serialization.KotlinIr.IrTypeArgument.KindCase.*
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.types.Variance
|
||||
|
||||
@@ -383,6 +384,26 @@ abstract class IrModuleDeserializer(
|
||||
return IrInstanceInitializerCallImpl(start, end, symbol, builtIns.unitType)
|
||||
}
|
||||
|
||||
private fun deserializeIrLocalDelegatedPropertyReference(
|
||||
proto: KotlinIr.IrLocalDelegatedPropertyReference,
|
||||
start: Int,
|
||||
end: Int,
|
||||
type: IrType
|
||||
): IrLocalDelegatedPropertyReference {
|
||||
|
||||
val delegate = deserializeIrSymbol(proto.delegate) as IrVariableSymbol
|
||||
val getter = deserializeIrSymbol(proto.getter) as IrSimpleFunctionSymbol
|
||||
val setter = if (proto.hasSetter()) deserializeIrSymbol(proto.setter) as IrSimpleFunctionSymbol else null
|
||||
val symbol = deserializeIrSymbol(proto.symbol) as IrLocalDelegatedPropertySymbol
|
||||
return IrLocalDelegatedPropertyReferenceImpl(
|
||||
start, end, type,
|
||||
symbol,
|
||||
delegate,
|
||||
getter,
|
||||
setter
|
||||
)
|
||||
}
|
||||
|
||||
private val getterToPropertyDescriptorMap = mutableMapOf<IrSimpleFunctionSymbol, WrappedPropertyDescriptor>()
|
||||
|
||||
private fun deserializePropertyReference(
|
||||
@@ -690,6 +711,8 @@ abstract class IrModuleDeserializer(
|
||||
-> deserializeGetObject(proto.getObject, start, end, type)
|
||||
GET_VALUE
|
||||
-> deserializeGetValue(proto.getValue, start, end, type)
|
||||
LOCAL_DELEGATED_PROPERTY_REFERENCE
|
||||
-> deserializeIrLocalDelegatedPropertyReference(proto.localDelegatedPropertyReference, start, end, type)
|
||||
INSTANCE_INITIALIZER_CALL
|
||||
-> deserializeInstanceInitializerCall(proto.instanceInitializerCall, start, end)
|
||||
PROPERTY_REFERENCE
|
||||
@@ -1039,6 +1062,36 @@ abstract class IrModuleDeserializer(
|
||||
KotlinIr.ModalityKind.ABSTRACT_MODALITY -> Modality.ABSTRACT
|
||||
}
|
||||
|
||||
private fun deserializeIrLocalDelegatedProperty(
|
||||
proto: KotlinIr.IrLocalDelegatedProperty,
|
||||
start: Int,
|
||||
end: Int,
|
||||
origin: IrDeclarationOrigin
|
||||
): IrLocalDelegatedProperty {
|
||||
|
||||
val delegate = deserializeIrVariable(proto.delegate, start, end, origin)
|
||||
val getter = deserializeIrFunction(proto.getter, start, end, origin)
|
||||
val setter = if (proto.hasSetter()) deserializeIrFunction(proto.setter, start, end, origin) else null
|
||||
|
||||
delegate.let { (it.descriptor as? WrappedVariableDescriptor)?.bind(it) }
|
||||
getter.let { (it.descriptor as? WrappedSimpleFunctionDescriptor)?.bind(it) }
|
||||
setter?.let { (it.descriptor as? WrappedSimpleFunctionDescriptor)?.bind(it) }
|
||||
|
||||
val symbol = deserializeIrSymbol(proto.symbol) as IrLocalDelegatedPropertySymbol
|
||||
|
||||
return IrLocalDelegatedPropertyImpl(
|
||||
start, end, origin,
|
||||
symbol,
|
||||
deserializeName(proto.name),
|
||||
deserializeIrType(proto.type),
|
||||
proto.isVar
|
||||
).also {
|
||||
it.delegate = delegate
|
||||
it.getter = getter
|
||||
it.setter = setter
|
||||
}
|
||||
}
|
||||
|
||||
private fun deserializeIrProperty(
|
||||
proto: KotlinIr.IrProperty,
|
||||
start: Int,
|
||||
@@ -1132,6 +1185,8 @@ abstract class IrModuleDeserializer(
|
||||
-> deserializeIrValueParameter(declarator.irValueParameter, start, end, origin)
|
||||
IR_ENUM_ENTRY
|
||||
-> deserializeIrEnumEntry(declarator.irEnumEntry, start, end, origin)
|
||||
IR_LOCAL_DELEGATED_PROPERTY
|
||||
-> deserializeIrLocalDelegatedProperty(declarator.irLocalDelegatedProperty, start, end, origin)
|
||||
DECLARATOR_NOT_SET
|
||||
-> error("Declaration deserialization not implemented: ${declarator.declaratorCase}")
|
||||
}
|
||||
|
||||
+31
@@ -407,6 +407,18 @@ open class IrModuleSerializer(
|
||||
return proto.build()
|
||||
}
|
||||
|
||||
private fun serializeIrLocalDelegatedPropertyReference(
|
||||
callable: IrLocalDelegatedPropertyReference
|
||||
): KotlinIr.IrLocalDelegatedPropertyReference {
|
||||
val proto = KotlinIr.IrLocalDelegatedPropertyReference.newBuilder()
|
||||
.setDelegate(serializeIrSymbol(callable.delegate))
|
||||
.setGetter(serializeIrSymbol(callable.getter))
|
||||
.setSymbol(serializeIrSymbol(callable.symbol))
|
||||
|
||||
callable.setter?.let { proto.setSetter(serializeIrSymbol(it)) }
|
||||
|
||||
return proto.build()
|
||||
}
|
||||
|
||||
private fun serializePropertyReference(callable: IrPropertyReference): KotlinIr.IrPropertyReference {
|
||||
val proto = KotlinIr.IrPropertyReference.newBuilder()
|
||||
@@ -780,6 +792,8 @@ open class IrModuleSerializer(
|
||||
-> operationProto.getObject = serializeGetObject(expression)
|
||||
is IrInstanceInitializerCall
|
||||
-> operationProto.instanceInitializerCall = serializeInstanceInitializerCall(expression)
|
||||
is IrLocalDelegatedPropertyReference
|
||||
-> operationProto.localDelegatedPropertyReference = serializeIrLocalDelegatedPropertyReference(expression)
|
||||
is IrPropertyReference
|
||||
-> operationProto.propertyReference = serializePropertyReference(expression)
|
||||
is IrReturn -> operationProto.`return` = serializeReturn(expression)
|
||||
@@ -937,6 +951,21 @@ open class IrModuleSerializer(
|
||||
.setBody(serializeStatement(declaration.body))
|
||||
.build()
|
||||
|
||||
private fun serializeIrLocalDelegatedProperty(variable: IrLocalDelegatedProperty): KotlinIr.IrLocalDelegatedProperty {
|
||||
|
||||
val proto = KotlinIr.IrLocalDelegatedProperty.newBuilder()
|
||||
.setName(serializeString(variable.name.toString()))
|
||||
.setIsVar(variable.isVar)
|
||||
.setType(serializeIrType(variable.type))
|
||||
.setDelegate(serializeIrVariable(variable.delegate))
|
||||
.setGetter(serializeIrFunction(variable.getter as IrSimpleFunction)) // TODO: can it be non simple?
|
||||
.setSymbol(serializeIrSymbol(variable.symbol))
|
||||
|
||||
variable.setter?.let { proto.setSetter(serializeIrFunction(it as IrSimpleFunction)) } // TODO: ditto.
|
||||
|
||||
return proto.build()
|
||||
}
|
||||
|
||||
private fun serializeIrProperty(property: IrProperty): KotlinIr.IrProperty {
|
||||
val index = declarationTable.uniqIdByDeclaration(property)
|
||||
|
||||
@@ -1074,6 +1103,8 @@ open class IrModuleSerializer(
|
||||
declarator.irEnumEntry = serializeIrEnumEntry(declaration)
|
||||
is IrProperty ->
|
||||
declarator.irProperty = serializeIrProperty(declaration)
|
||||
is IrLocalDelegatedProperty ->
|
||||
declarator.irLocalDelegatedProperty = serializeIrLocalDelegatedProperty(declaration)
|
||||
else
|
||||
-> TODO("Declaration serialization not supported yet: $declaration")
|
||||
}
|
||||
|
||||
+2265
-85
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user