From f04827cd573792a70a0bea0f4d839ac4c50e42e5 Mon Sep 17 00:00:00 2001 From: Alexander Gorshenev Date: Tue, 13 Jun 2017 12:52:30 +0300 Subject: [PATCH] Deserialization of IrSetField/IrGetField was missing. --- .../backend/konan/serialization/KonanIr.proto | 2 +- .../konan/serialization/SerializeIr.kt | 39 +++++++++++++++++-- 2 files changed, 36 insertions(+), 5 deletions(-) diff --git a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/serialization/KonanIr.proto b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/serialization/KonanIr.proto index 86bbc11433a..9a021a910ea 100644 --- a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/serialization/KonanIr.proto +++ b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/serialization/KonanIr.proto @@ -154,7 +154,7 @@ message IrGetEnumValue { message FieldAccessCommon { required KotlinDescriptor descriptor = 1; optional KotlinDescriptor super = 2; - required IrExpression reciever = 3; + required IrExpression receiver = 3; } message IrGetField { diff --git a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/serialization/SerializeIr.kt b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/serialization/SerializeIr.kt index b968904ae47..35c686f03f6 100644 --- a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/serialization/SerializeIr.kt +++ b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/serialization/SerializeIr.kt @@ -271,7 +271,7 @@ internal class IrSerializer(val context: Context, proto.setSuper(serializeDescriptor(superQualifier)) val receiver = expression.receiver if (receiver != null) - proto.setReciever(serializeExpression(receiver)) + proto.setReceiver(serializeExpression(receiver)) return proto.build() } @@ -820,6 +820,19 @@ internal class IrDeserializer(val context: Context, return call } + fun deserializeGetField(proto: KonanIr.IrGetField, start: Int, end: Int, type: KotlinType): IrGetField { + val access = proto.fieldAccess + val descriptor = deserializeDescriptor(access.getDescriptor()) as PropertyDescriptor + val superQualifier = if (access.hasSuper()) { + deserializeDescriptor(access.getDescriptor()) as ClassDescriptor + } else null + val receiver = if (access.hasReceiver()) { + deserializeExpression(access.receiver) + } else null + + return IrGetFieldImpl(start, end, descriptor, receiver, null, superQualifier) + } + fun deserializeGetValue(proto: KonanIr.IrGetValue, start: Int, end: Int, type: KotlinType): IrGetValue { val descriptor = deserializeDescriptor(proto.descriptor) as ValueDescriptor @@ -852,6 +865,20 @@ internal class IrDeserializer(val context: Context, return IrReturnImpl(start, end, type, descriptor, value) } + fun deserializeSetField(proto: KonanIr.IrSetField, start: Int, end: Int, type: KotlinType): IrSetField { + val access = proto.fieldAccess + val descriptor = deserializeDescriptor(access.getDescriptor()) as PropertyDescriptor + val superQualifier = if (access.hasSuper()) { + deserializeDescriptor(access.getDescriptor()) as ClassDescriptor + } else null + val receiver = if (access.hasReceiver()) { + deserializeExpression(access.receiver) + } else null + val value = deserializeExpression(proto.value) + + return IrSetFieldImpl(start, end, descriptor, receiver, value, null, superQualifier) + } + fun deserializeSetVariable(proto: KonanIr.IrSetVariable, start: Int, end: Int, type: KotlinType): IrSetVariable { val descriptor = deserializeDescriptor(proto.getDescriptor()) as VariableDescriptor val value = deserializeExpression(proto.getValue()) @@ -1006,16 +1033,20 @@ internal class IrDeserializer(val context: Context, -> deserializeContinue(proto.getContinue(), start, end, type) DELEGATING_CONSTRUCTOR_CALL -> deserializeDelegatingConstructorCall(proto.delegatingConstructorCall, start, end, type) - GET_VALUE - -> deserializeGetValue(proto.getValue, start, end, type) GET_ENUM_VALUE -> deserializeGetEnumValue(proto.getEnumValue, start, end, type) + GET_FIELD + -> deserializeGetField(proto.getField, start, end, type) GET_OBJECT -> deserializeGetObject(proto.getObject, start, end, type) + GET_VALUE + -> deserializeGetValue(proto.getValue, start, end, type) INSTANCE_INITIALIZER_CALL -> deserializeInstanceInitializerCall(proto.instanceInitializerCall, start, end, type) RETURN -> deserializeReturn(proto.getReturn(), start, end, type) + SET_FIELD + -> deserializeSetField(proto.setField, start, end, type) SET_VARIABLE -> deserializeSetVariable(proto.setVariable, start, end, type) STRING_CONCAT @@ -1033,7 +1064,7 @@ internal class IrDeserializer(val context: Context, WHILE -> deserializeWhile(proto.getWhile(), start, end, type) else -> { - TODO("Expression deserialization not implemented}") + TODO("Expression deserialization not implemented: ${proto.operationCase}") } }