Write is_unsigned flag into metadata for an annotation arguments

Instead of adding new kind of types, we'll use flag to disambiguate
 usual types from unsigned ones, this approach has two advantages:
 - less changes in the metadata format
 - it allows naturally extend format for unsigned arrays,
  which will be supported later

 #KT-25310 Fixed
 #KT-25273 Fixed
This commit is contained in:
Mikhail Zarechenskiy
2018-07-06 01:41:13 +03:00
parent 8c075bc622
commit 0c6757a8b0
13 changed files with 487 additions and 169 deletions
+5
View File
@@ -83,6 +83,11 @@ message Annotation {
optional Annotation annotation = 8;
repeated Value array_element = 9;
/*
isUnsigned
*/
optional int32 flags = 10 [default = 0];
}
required int32 name_id = 1 [(name_id_in_table) = true];
@@ -2200,6 +2200,23 @@ public final class ProtoBuf {
* <code>repeated .org.jetbrains.kotlin.metadata.Annotation.Argument.Value array_element = 9;</code>
*/
int getArrayElementCount();
/**
* <code>optional int32 flags = 10 [default = 0];</code>
*
* <pre>
*isUnsigned
* </pre>
*/
boolean hasFlags();
/**
* <code>optional int32 flags = 10 [default = 0];</code>
*
* <pre>
*isUnsigned
* </pre>
*/
int getFlags();
}
/**
* Protobuf type {@code org.jetbrains.kotlin.metadata.Annotation.Argument.Value}
@@ -2314,6 +2331,11 @@ public final class ProtoBuf {
arrayElement_.add(input.readMessage(org.jetbrains.kotlin.metadata.ProtoBuf.Annotation.Argument.Value.PARSER, extensionRegistry));
break;
}
case 80: {
bitField0_ |= 0x00000100;
flags_ = input.readInt32();
break;
}
}
}
} catch (org.jetbrains.kotlin.protobuf.InvalidProtocolBufferException e) {
@@ -2681,6 +2703,29 @@ public final class ProtoBuf {
return arrayElement_.get(index);
}
public static final int FLAGS_FIELD_NUMBER = 10;
private int flags_;
/**
* <code>optional int32 flags = 10 [default = 0];</code>
*
* <pre>
*isUnsigned
* </pre>
*/
public boolean hasFlags() {
return ((bitField0_ & 0x00000100) == 0x00000100);
}
/**
* <code>optional int32 flags = 10 [default = 0];</code>
*
* <pre>
*isUnsigned
* </pre>
*/
public int getFlags() {
return flags_;
}
private void initFields() {
type_ = org.jetbrains.kotlin.metadata.ProtoBuf.Annotation.Argument.Value.Type.BYTE;
intValue_ = 0L;
@@ -2691,6 +2736,7 @@ public final class ProtoBuf {
enumValueId_ = 0;
annotation_ = org.jetbrains.kotlin.metadata.ProtoBuf.Annotation.getDefaultInstance();
arrayElement_ = java.util.Collections.emptyList();
flags_ = 0;
}
private byte memoizedIsInitialized = -1;
public final boolean isInitialized() {
@@ -2744,6 +2790,9 @@ public final class ProtoBuf {
for (int i = 0; i < arrayElement_.size(); i++) {
output.writeMessage(9, arrayElement_.get(i));
}
if (((bitField0_ & 0x00000100) == 0x00000100)) {
output.writeInt32(10, flags_);
}
output.writeRawBytes(unknownFields);
}
@@ -2789,6 +2838,10 @@ public final class ProtoBuf {
size += org.jetbrains.kotlin.protobuf.CodedOutputStream
.computeMessageSize(9, arrayElement_.get(i));
}
if (((bitField0_ & 0x00000100) == 0x00000100)) {
size += org.jetbrains.kotlin.protobuf.CodedOutputStream
.computeInt32Size(10, flags_);
}
size += unknownFields.size();
memoizedSerializedSize = size;
return size;
@@ -2901,6 +2954,8 @@ public final class ProtoBuf {
bitField0_ = (bitField0_ & ~0x00000080);
arrayElement_ = java.util.Collections.emptyList();
bitField0_ = (bitField0_ & ~0x00000100);
flags_ = 0;
bitField0_ = (bitField0_ & ~0x00000200);
return this;
}
@@ -2961,6 +3016,10 @@ public final class ProtoBuf {
bitField0_ = (bitField0_ & ~0x00000100);
}
result.arrayElement_ = arrayElement_;
if (((from_bitField0_ & 0x00000200) == 0x00000200)) {
to_bitField0_ |= 0x00000100;
}
result.flags_ = flags_;
result.bitField0_ = to_bitField0_;
return result;
}
@@ -3001,6 +3060,9 @@ public final class ProtoBuf {
}
}
if (other.hasFlags()) {
setFlags(other.getFlags());
}
setUnknownFields(
getUnknownFields().concat(other.unknownFields));
return this;
@@ -3493,6 +3555,54 @@ public final class ProtoBuf {
return this;
}
private int flags_ ;
/**
* <code>optional int32 flags = 10 [default = 0];</code>
*
* <pre>
*isUnsigned
* </pre>
*/
public boolean hasFlags() {
return ((bitField0_ & 0x00000200) == 0x00000200);
}
/**
* <code>optional int32 flags = 10 [default = 0];</code>
*
* <pre>
*isUnsigned
* </pre>
*/
public int getFlags() {
return flags_;
}
/**
* <code>optional int32 flags = 10 [default = 0];</code>
*
* <pre>
*isUnsigned
* </pre>
*/
public Builder setFlags(int value) {
bitField0_ |= 0x00000200;
flags_ = value;
return this;
}
/**
* <code>optional int32 flags = 10 [default = 0];</code>
*
* <pre>
*isUnsigned
* </pre>
*/
public Builder clearFlags() {
bitField0_ = (bitField0_ & ~0x00000200);
flags_ = 0;
return this;
}
// @@protoc_insertion_point(builder_scope:org.jetbrains.kotlin.metadata.Annotation.Argument.Value)
}
@@ -77,6 +77,8 @@ public class Flags {
public static final BooleanFlagField IS_NEGATED = FlagField.booleanFirst();
public static final BooleanFlagField IS_NULL_CHECK_PREDICATE = FlagField.booleanAfter(IS_NEGATED);
// Annotations
public static final BooleanFlagField IS_UNSIGNED = FlagField.booleanFirst();
// ---