Serialize value parameter indices on JVM

This will help to load annotations on value parameters
This commit is contained in:
Alexander Udalov
2013-10-21 19:43:30 +04:00
parent 011e2675ab
commit 4105455179
9 changed files with 87 additions and 10 deletions
@@ -189,6 +189,7 @@ message Callable {
required Type type = 3;
optional Type vararg_element_type = 4;
extensions 100 to 199;
}
repeated ValueParameter value_parameter = 7;
@@ -272,7 +272,8 @@ public class DescriptorSerializer {
return ProtoBuf.Callable.CallableKind.FUN;
}
private ProtoBuf.Callable.ValueParameter.Builder valueParameter(ValueParameterDescriptor descriptor) {
@NotNull
private ProtoBuf.Callable.ValueParameter.Builder valueParameter(@NotNull ValueParameterDescriptor descriptor) {
ProtoBuf.Callable.ValueParameter.Builder builder = ProtoBuf.Callable.ValueParameter.newBuilder();
builder.setFlags(Flags.getValueParameterFlags(hasAnnotations(descriptor), descriptor.declaresDefaultValue()));
@@ -286,6 +287,8 @@ public class DescriptorSerializer {
builder.setVarargElementType(type(varargElementType));
}
extension.serializeValueParameter(descriptor, builder, nameTable);
return builder;
}
@@ -7515,8 +7515,9 @@ public final class ProtoBuf {
// @@protoc_insertion_point(enum_scope:org.jetbrains.jet.descriptors.serialization.Callable.CallableKind)
}
public interface ValueParameterOrBuilder
extends com.google.protobuf.MessageLiteOrBuilder {
public interface ValueParameterOrBuilder extends
com.google.protobuf.GeneratedMessageLite.
ExtendableMessageOrBuilder<ValueParameter> {
// optional int32 flags = 1;
/**
@@ -7574,10 +7575,10 @@ public final class ProtoBuf {
* Protobuf type {@code org.jetbrains.jet.descriptors.serialization.Callable.ValueParameter}
*/
public static final class ValueParameter extends
com.google.protobuf.GeneratedMessageLite
implements ValueParameterOrBuilder {
com.google.protobuf.GeneratedMessageLite.ExtendableMessage<
ValueParameter> implements ValueParameterOrBuilder {
// Use ValueParameter.newBuilder() to construct.
private ValueParameter(com.google.protobuf.GeneratedMessageLite.Builder builder) {
private ValueParameter(com.google.protobuf.GeneratedMessageLite.ExtendableBuilder<org.jetbrains.jet.descriptors.serialization.ProtoBuf.Callable.ValueParameter, ?> builder) {
super(builder);
}
@@ -7781,6 +7782,10 @@ public final class ProtoBuf {
return false;
}
}
if (!extensionsAreInitialized()) {
memoizedIsInitialized = 0;
return false;
}
memoizedIsInitialized = 1;
return true;
}
@@ -7788,6 +7793,9 @@ public final class ProtoBuf {
public void writeTo(com.google.protobuf.CodedOutputStream output)
throws java.io.IOException {
getSerializedSize();
com.google.protobuf.GeneratedMessageLite
.ExtendableMessage<org.jetbrains.jet.descriptors.serialization.ProtoBuf.Callable.ValueParameter>.ExtensionWriter extensionWriter =
newExtensionWriter();
if (((bitField0_ & 0x00000001) == 0x00000001)) {
output.writeInt32(1, flags_);
}
@@ -7800,6 +7808,7 @@ public final class ProtoBuf {
if (((bitField0_ & 0x00000008) == 0x00000008)) {
output.writeMessage(4, varargElementType_);
}
extensionWriter.writeUntil(200, output);
}
private int memoizedSerializedSize = -1;
@@ -7824,6 +7833,7 @@ public final class ProtoBuf {
size += com.google.protobuf.CodedOutputStream
.computeMessageSize(4, varargElementType_);
}
size += extensionsSerializedSize();
memoizedSerializedSize = size;
return size;
}
@@ -7899,9 +7909,8 @@ public final class ProtoBuf {
* Protobuf type {@code org.jetbrains.jet.descriptors.serialization.Callable.ValueParameter}
*/
public static final class Builder extends
com.google.protobuf.GeneratedMessageLite.Builder<
org.jetbrains.jet.descriptors.serialization.ProtoBuf.Callable.ValueParameter, Builder>
implements org.jetbrains.jet.descriptors.serialization.ProtoBuf.Callable.ValueParameterOrBuilder {
com.google.protobuf.GeneratedMessageLite.ExtendableBuilder<
org.jetbrains.jet.descriptors.serialization.ProtoBuf.Callable.ValueParameter, Builder> implements org.jetbrains.jet.descriptors.serialization.ProtoBuf.Callable.ValueParameterOrBuilder {
// Construct using org.jetbrains.jet.descriptors.serialization.ProtoBuf.Callable.ValueParameter.newBuilder()
private Builder() {
maybeForceBuilderInitialization();
@@ -7980,6 +7989,7 @@ public final class ProtoBuf {
if (other.hasVarargElementType()) {
mergeVarargElementType(other.getVarargElementType());
}
this.mergeExtensionFields(other);
return this;
}
@@ -8002,6 +8012,10 @@ public final class ProtoBuf {
return false;
}
}
if (!extensionsAreInitialized()) {
return false;
}
return true;
}
@@ -19,6 +19,7 @@ package org.jetbrains.jet.descriptors.serialization;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.lang.descriptors.CallableMemberDescriptor;
import org.jetbrains.jet.lang.descriptors.ClassDescriptor;
import org.jetbrains.jet.lang.descriptors.ValueParameterDescriptor;
public abstract class SerializerExtension {
public static final SerializerExtension DEFAULT = new SerializerExtension() {};
@@ -33,4 +34,11 @@ public abstract class SerializerExtension {
@NotNull NameTable nameTable
) {
}
public void serializeValueParameter(
@NotNull ValueParameterDescriptor descriptor,
@NotNull ProtoBuf.Callable.ValueParameter.Builder proto,
@NotNull NameTable nameTable
) {
}
}