IR serialization: isExpect in proto and ser/deser

This commit is contained in:
Dmitry Petrov
2019-10-17 14:14:29 +03:00
parent 922b1e576d
commit 69a9559eac
9 changed files with 273 additions and 9 deletions
@@ -517,6 +517,7 @@ message IrFunctionBase {
repeated IrValueParameter value_parameter = 9;
optional int32 body = 10;
required int32 return_type = 11;
required bool is_expect = 12;
}
message IrFunction {
@@ -531,7 +532,6 @@ message IrFunction {
message IrConstructor {
required IrFunctionBase base = 1;
required bool is_primary = 2;
}
message IrField {
@@ -568,6 +568,7 @@ message IrProperty {
optional IrField backing_field = 10;
optional IrFunction getter = 11;
optional IrFunction setter = 12;
required bool is_expect = 13;
}
message IrVariable {
@@ -636,6 +637,7 @@ message IrClass {
required IrTypeParameterContainer type_parameters = 12;
required IrDeclarationContainer declaration_container = 13;
repeated int32 super_type = 14;
required bool is_expect = 15;
}
message IrTypeAlias {
@@ -985,7 +985,7 @@ abstract class IrFileDeserializer(
isData = proto.isData,
isExternal = proto.isExternal,
isInline = proto.isInline,
isExpect = false // TODO isExpect
isExpect = proto.isExpect
)
}.usingParent {
proto.declarationContainer.declarationList.mapTo(declarations) { deserializeDeclaration(it) }
@@ -1057,7 +1057,7 @@ abstract class IrFileDeserializer(
isExternal = proto.base.isExternal,
isTailrec = proto.isTailrec,
isSuspend = proto.isSuspend,
isExpect = false // TODO isExpect
isExpect = proto.base.isExpect
)
}.apply {
proto.overriddenList.mapTo(overriddenSymbols) { deserializeIrSymbol(it) as IrSimpleFunctionSymbol }
@@ -1141,7 +1141,7 @@ abstract class IrFileDeserializer(
isInline = proto.base.isInline,
isExternal = proto.base.isExternal,
isPrimary = proto.isPrimary,
isExpect = false // TODO isExpect
isExpect = proto.base.isExpect
)
}.apply {
(descriptor as? WrappedClassConstructorDescriptor)?.bind(this)
@@ -1212,11 +1212,12 @@ abstract class IrFileDeserializer(
deserializeName(proto.name),
deserializeVisibility(proto.visibility),
deserializeModality(proto.modality),
proto.isVar,
proto.isConst,
proto.isLateinit,
proto.isDelegated,
proto.isExternal
isVar = proto.isVar,
isConst = proto.isConst,
isLateinit = proto.isLateinit,
isDelegated = proto.isDelegated,
isExpect = proto.isExpect,
isExternal = proto.isExternal
)
}.apply {
if (proto.hasGetter()) {
@@ -1033,6 +1033,7 @@ open class IrFileSerializer(
.setVisibility(serializeVisibility(function.visibility))
.setIsInline(function.isInline)
.setIsExternal(function.isExternal)
.setIsExpect(function.isExpect)
.setReturnType(serializeIrType(function.returnType))
.setTypeParameters(serializeIrTypeParameterContainer(function.typeParameters))
@@ -1108,6 +1109,7 @@ open class IrFileSerializer(
.setIsLateinit(property.isLateinit)
.setIsDelegated(property.isDelegated)
.setIsExternal(property.isExternal)
.setIsExpect(property.isExpect)
val backingField = property.backingField
val getter = property.getter
@@ -1180,6 +1182,7 @@ open class IrFileSerializer(
.setIsData(clazz.isData)
.setIsExternal(clazz.isExternal)
.setIsInline(clazz.isInline)
.setIsExpect(clazz.isExpect)
.setTypeParameters(serializeIrTypeParameterContainer(clazz.typeParameters))
.setDeclarationContainer(serializeIrDeclarationContainer(clazz.declarations))
clazz.superTypes.forEach {
@@ -193,6 +193,11 @@ public final class IrClass extends
input.popLimit(limit);
break;
}
case 120: {
bitField0_ |= 0x00002000;
isExpect_ = input.readBool();
break;
}
}
}
} catch (org.jetbrains.kotlin.protobuf.InvalidProtocolBufferException e) {
@@ -455,6 +460,21 @@ public final class IrClass extends
return superType_.get(index);
}
public static final int IS_EXPECT_FIELD_NUMBER = 15;
private boolean isExpect_;
/**
* <code>required bool is_expect = 15;</code>
*/
public boolean hasIsExpect() {
return ((bitField0_ & 0x00002000) == 0x00002000);
}
/**
* <code>required bool is_expect = 15;</code>
*/
public boolean getIsExpect() {
return isExpect_;
}
private void initFields() {
base_ = org.jetbrains.kotlin.backend.common.serialization.proto.IrDeclarationBase.getDefaultInstance();
name_ = 0;
@@ -470,6 +490,7 @@ public final class IrClass extends
typeParameters_ = org.jetbrains.kotlin.backend.common.serialization.proto.IrTypeParameterContainer.getDefaultInstance();
declarationContainer_ = org.jetbrains.kotlin.backend.common.serialization.proto.IrDeclarationContainer.getDefaultInstance();
superType_ = java.util.Collections.emptyList();
isExpect_ = false;
}
private byte memoizedIsInitialized = -1;
public final boolean isInitialized() {
@@ -525,6 +546,10 @@ public final class IrClass extends
memoizedIsInitialized = 0;
return false;
}
if (!hasIsExpect()) {
memoizedIsInitialized = 0;
return false;
}
if (!getBase().isInitialized()) {
memoizedIsInitialized = 0;
return false;
@@ -596,6 +621,9 @@ public final class IrClass extends
for (int i = 0; i < superType_.size(); i++) {
output.writeInt32(14, superType_.get(i));
}
if (((bitField0_ & 0x00002000) == 0x00002000)) {
output.writeBool(15, isExpect_);
}
output.writeRawBytes(unknownFields);
}
@@ -666,6 +694,10 @@ public final class IrClass extends
size += dataSize;
size += 1 * getSuperTypeList().size();
}
if (((bitField0_ & 0x00002000) == 0x00002000)) {
size += org.jetbrains.kotlin.protobuf.CodedOutputStream
.computeBoolSize(15, isExpect_);
}
size += unknownFields.size();
memoizedSerializedSize = size;
return size;
@@ -788,6 +820,8 @@ public final class IrClass extends
bitField0_ = (bitField0_ & ~0x00001000);
superType_ = java.util.Collections.emptyList();
bitField0_ = (bitField0_ & ~0x00002000);
isExpect_ = false;
bitField0_ = (bitField0_ & ~0x00004000);
return this;
}
@@ -868,6 +902,10 @@ public final class IrClass extends
bitField0_ = (bitField0_ & ~0x00002000);
}
result.superType_ = superType_;
if (((from_bitField0_ & 0x00004000) == 0x00004000)) {
to_bitField0_ |= 0x00002000;
}
result.isExpect_ = isExpect_;
result.bitField0_ = to_bitField0_;
return result;
}
@@ -923,6 +961,9 @@ public final class IrClass extends
}
}
if (other.hasIsExpect()) {
setIsExpect(other.getIsExpect());
}
setUnknownFields(
getUnknownFields().concat(other.unknownFields));
return this;
@@ -977,6 +1018,10 @@ public final class IrClass extends
return false;
}
if (!hasIsExpect()) {
return false;
}
if (!getBase().isInitialized()) {
return false;
@@ -1665,6 +1710,38 @@ public final class IrClass extends
return this;
}
private boolean isExpect_ ;
/**
* <code>required bool is_expect = 15;</code>
*/
public boolean hasIsExpect() {
return ((bitField0_ & 0x00004000) == 0x00004000);
}
/**
* <code>required bool is_expect = 15;</code>
*/
public boolean getIsExpect() {
return isExpect_;
}
/**
* <code>required bool is_expect = 15;</code>
*/
public Builder setIsExpect(boolean value) {
bitField0_ |= 0x00004000;
isExpect_ = value;
return this;
}
/**
* <code>required bool is_expect = 15;</code>
*/
public Builder clearIsExpect() {
bitField0_ = (bitField0_ & ~0x00004000);
isExpect_ = false;
return this;
}
// @@protoc_insertion_point(builder_scope:org.jetbrains.kotlin.backend.common.serialization.proto.IrClass)
}
@@ -144,4 +144,13 @@ public interface IrClassOrBuilder extends
* <code>repeated int32 super_type = 14;</code>
*/
int getSuperType(int index);
/**
* <code>required bool is_expect = 15;</code>
*/
boolean hasIsExpect();
/**
* <code>required bool is_expect = 15;</code>
*/
boolean getIsExpect();
}
@@ -151,6 +151,11 @@ public final class IrFunctionBase extends
returnType_ = input.readInt32();
break;
}
case 96: {
bitField0_ |= 0x00000400;
isExpect_ = input.readBool();
break;
}
}
}
} catch (org.jetbrains.kotlin.protobuf.InvalidProtocolBufferException e) {
@@ -373,6 +378,21 @@ public final class IrFunctionBase extends
return returnType_;
}
public static final int IS_EXPECT_FIELD_NUMBER = 12;
private boolean isExpect_;
/**
* <code>required bool is_expect = 12;</code>
*/
public boolean hasIsExpect() {
return ((bitField0_ & 0x00000400) == 0x00000400);
}
/**
* <code>required bool is_expect = 12;</code>
*/
public boolean getIsExpect() {
return isExpect_;
}
private void initFields() {
base_ = org.jetbrains.kotlin.backend.common.serialization.proto.IrDeclarationBase.getDefaultInstance();
name_ = 0;
@@ -385,6 +405,7 @@ public final class IrFunctionBase extends
valueParameter_ = java.util.Collections.emptyList();
body_ = 0;
returnType_ = 0;
isExpect_ = false;
}
private byte memoizedIsInitialized = -1;
public final boolean isInitialized() {
@@ -420,6 +441,10 @@ public final class IrFunctionBase extends
memoizedIsInitialized = 0;
return false;
}
if (!hasIsExpect()) {
memoizedIsInitialized = 0;
return false;
}
if (!getBase().isInitialized()) {
memoizedIsInitialized = 0;
return false;
@@ -490,6 +515,9 @@ public final class IrFunctionBase extends
if (((bitField0_ & 0x00000200) == 0x00000200)) {
output.writeInt32(11, returnType_);
}
if (((bitField0_ & 0x00000400) == 0x00000400)) {
output.writeBool(12, isExpect_);
}
output.writeRawBytes(unknownFields);
}
@@ -543,6 +571,10 @@ public final class IrFunctionBase extends
size += org.jetbrains.kotlin.protobuf.CodedOutputStream
.computeInt32Size(11, returnType_);
}
if (((bitField0_ & 0x00000400) == 0x00000400)) {
size += org.jetbrains.kotlin.protobuf.CodedOutputStream
.computeBoolSize(12, isExpect_);
}
size += unknownFields.size();
memoizedSerializedSize = size;
return size;
@@ -659,6 +691,8 @@ public final class IrFunctionBase extends
bitField0_ = (bitField0_ & ~0x00000200);
returnType_ = 0;
bitField0_ = (bitField0_ & ~0x00000400);
isExpect_ = false;
bitField0_ = (bitField0_ & ~0x00000800);
return this;
}
@@ -727,6 +761,10 @@ public final class IrFunctionBase extends
to_bitField0_ |= 0x00000200;
}
result.returnType_ = returnType_;
if (((from_bitField0_ & 0x00000800) == 0x00000800)) {
to_bitField0_ |= 0x00000400;
}
result.isExpect_ = isExpect_;
result.bitField0_ = to_bitField0_;
return result;
}
@@ -773,6 +811,9 @@ public final class IrFunctionBase extends
if (other.hasReturnType()) {
setReturnType(other.getReturnType());
}
if (other.hasIsExpect()) {
setIsExpect(other.getIsExpect());
}
setUnknownFields(
getUnknownFields().concat(other.unknownFields));
return this;
@@ -807,6 +848,10 @@ public final class IrFunctionBase extends
return false;
}
if (!hasIsExpect()) {
return false;
}
if (!getBase().isInitialized()) {
return false;
@@ -1444,6 +1489,38 @@ public final class IrFunctionBase extends
return this;
}
private boolean isExpect_ ;
/**
* <code>required bool is_expect = 12;</code>
*/
public boolean hasIsExpect() {
return ((bitField0_ & 0x00000800) == 0x00000800);
}
/**
* <code>required bool is_expect = 12;</code>
*/
public boolean getIsExpect() {
return isExpect_;
}
/**
* <code>required bool is_expect = 12;</code>
*/
public Builder setIsExpect(boolean value) {
bitField0_ |= 0x00000800;
isExpect_ = value;
return this;
}
/**
* <code>required bool is_expect = 12;</code>
*/
public Builder clearIsExpect() {
bitField0_ = (bitField0_ & ~0x00000800);
isExpect_ = false;
return this;
}
// @@protoc_insertion_point(builder_scope:org.jetbrains.kotlin.backend.common.serialization.proto.IrFunctionBase)
}
@@ -110,4 +110,13 @@ public interface IrFunctionBaseOrBuilder extends
* <code>required int32 return_type = 11;</code>
*/
int getReturnType();
/**
* <code>required bool is_expect = 12;</code>
*/
boolean hasIsExpect();
/**
* <code>required bool is_expect = 12;</code>
*/
boolean getIsExpect();
}
@@ -160,6 +160,11 @@ public final class IrProperty extends
bitField0_ |= 0x00000800;
break;
}
case 104: {
bitField0_ |= 0x00001000;
isExpect_ = input.readBool();
break;
}
}
}
} catch (org.jetbrains.kotlin.protobuf.InvalidProtocolBufferException e) {
@@ -374,6 +379,21 @@ public final class IrProperty extends
return setter_;
}
public static final int IS_EXPECT_FIELD_NUMBER = 13;
private boolean isExpect_;
/**
* <code>required bool is_expect = 13;</code>
*/
public boolean hasIsExpect() {
return ((bitField0_ & 0x00001000) == 0x00001000);
}
/**
* <code>required bool is_expect = 13;</code>
*/
public boolean getIsExpect() {
return isExpect_;
}
private void initFields() {
base_ = org.jetbrains.kotlin.backend.common.serialization.proto.IrDeclarationBase.getDefaultInstance();
name_ = 0;
@@ -387,6 +407,7 @@ public final class IrProperty extends
backingField_ = org.jetbrains.kotlin.backend.common.serialization.proto.IrField.getDefaultInstance();
getter_ = org.jetbrains.kotlin.backend.common.serialization.proto.IrFunction.getDefaultInstance();
setter_ = org.jetbrains.kotlin.backend.common.serialization.proto.IrFunction.getDefaultInstance();
isExpect_ = false;
}
private byte memoizedIsInitialized = -1;
public final boolean isInitialized() {
@@ -430,6 +451,10 @@ public final class IrProperty extends
memoizedIsInitialized = 0;
return false;
}
if (!hasIsExpect()) {
memoizedIsInitialized = 0;
return false;
}
if (!getBase().isInitialized()) {
memoizedIsInitialized = 0;
return false;
@@ -499,6 +524,9 @@ public final class IrProperty extends
if (((bitField0_ & 0x00000800) == 0x00000800)) {
output.writeMessage(12, setter_);
}
if (((bitField0_ & 0x00001000) == 0x00001000)) {
output.writeBool(13, isExpect_);
}
output.writeRawBytes(unknownFields);
}
@@ -556,6 +584,10 @@ public final class IrProperty extends
size += org.jetbrains.kotlin.protobuf.CodedOutputStream
.computeMessageSize(12, setter_);
}
if (((bitField0_ & 0x00001000) == 0x00001000)) {
size += org.jetbrains.kotlin.protobuf.CodedOutputStream
.computeBoolSize(13, isExpect_);
}
size += unknownFields.size();
memoizedSerializedSize = size;
return size;
@@ -674,6 +706,8 @@ public final class IrProperty extends
bitField0_ = (bitField0_ & ~0x00000400);
setter_ = org.jetbrains.kotlin.backend.common.serialization.proto.IrFunction.getDefaultInstance();
bitField0_ = (bitField0_ & ~0x00000800);
isExpect_ = false;
bitField0_ = (bitField0_ & ~0x00001000);
return this;
}
@@ -745,6 +779,10 @@ public final class IrProperty extends
to_bitField0_ |= 0x00000800;
}
result.setter_ = setter_;
if (((from_bitField0_ & 0x00001000) == 0x00001000)) {
to_bitField0_ |= 0x00001000;
}
result.isExpect_ = isExpect_;
result.bitField0_ = to_bitField0_;
return result;
}
@@ -787,6 +825,9 @@ public final class IrProperty extends
if (other.hasSetter()) {
mergeSetter(other.getSetter());
}
if (other.hasIsExpect()) {
setIsExpect(other.getIsExpect());
}
setUnknownFields(
getUnknownFields().concat(other.unknownFields));
return this;
@@ -829,6 +870,10 @@ public final class IrProperty extends
return false;
}
if (!hasIsExpect()) {
return false;
}
if (!getBase().isInitialized()) {
return false;
@@ -1404,6 +1449,38 @@ public final class IrProperty extends
return this;
}
private boolean isExpect_ ;
/**
* <code>required bool is_expect = 13;</code>
*/
public boolean hasIsExpect() {
return ((bitField0_ & 0x00001000) == 0x00001000);
}
/**
* <code>required bool is_expect = 13;</code>
*/
public boolean getIsExpect() {
return isExpect_;
}
/**
* <code>required bool is_expect = 13;</code>
*/
public Builder setIsExpect(boolean value) {
bitField0_ |= 0x00001000;
isExpect_ = value;
return this;
}
/**
* <code>required bool is_expect = 13;</code>
*/
public Builder clearIsExpect() {
bitField0_ = (bitField0_ & ~0x00001000);
isExpect_ = false;
return this;
}
// @@protoc_insertion_point(builder_scope:org.jetbrains.kotlin.backend.common.serialization.proto.IrProperty)
}
@@ -114,4 +114,13 @@ public interface IrPropertyOrBuilder extends
* <code>optional .org.jetbrains.kotlin.backend.common.serialization.proto.IrFunction setter = 12;</code>
*/
org.jetbrains.kotlin.backend.common.serialization.proto.IrFunction getSetter();
/**
* <code>required bool is_expect = 13;</code>
*/
boolean hasIsExpect();
/**
* <code>required bool is_expect = 13;</code>
*/
boolean getIsExpect();
}