Drop Callable and primary/secondary constructor proto messages

This commit is contained in:
Alexander Udalov
2015-10-05 11:18:06 +03:00
parent e02854db6d
commit e4efa27b76
30 changed files with 261 additions and 8881 deletions
-5
View File
@@ -30,11 +30,6 @@ extend Class {
repeated Annotation class_annotation = 150;
}
extend Callable {
repeated Annotation old_callable_annotation = 150;
optional Annotation.Argument.Value old_compile_time_value = 151;
}
extend Constructor {
repeated Annotation constructor_annotation = 150;
}
@@ -177,28 +177,12 @@ message Class {
repeated Function function = 9;
repeated Property property = 10;
repeated Callable member = 11;
repeated int32 enum_entry = 12 [packed = true, (name_id_in_table) = true];
message PrimaryConstructor {
// If this field is present, it contains serialized data for the primary constructor.
// Otherwise it's default and can be created manually upon deserialization
// Note: currently only objects have default primary constructor
optional Callable data = 1;
}
// This field is present if and only if the class has a primary constructor
optional PrimaryConstructor primary_constructor = 13;
repeated Callable secondary_constructor = 14;
extensions 100 to 199;
}
message Package {
repeated Callable member = 1;
repeated Constructor constructor = 2;
repeated Function function = 3;
repeated Property property = 4;
@@ -279,46 +263,6 @@ message Property {
extensions 100 to 199;
}
message Callable {
/*
Visibility
Modality
hasAnnotations
CallableKind
MemberKind
hasGetter
hasSetter
hasConstant
isConst
lateinit
isOperator
isInfix
*/
optional int32 flags = 1;
/*
isNotDefault
Visibility
Modality
hasAnnotations
*/
optional int32 getter_flags = 9 /* absent => same as property */;
optional int32 setter_flags = 10 /* absent => same as property */;
repeated TypeParameter type_parameter = 4;
optional Type receiver_type = 5;
required int32 name = 6 [(name_id_in_table) = true];
// Value parameters for functions and constructors, or setter value parameter for properties
repeated ValueParameter value_parameter = 7;
required Type return_type = 8;
extensions 100 to 199;
}
message ValueParameter {
/*
declaresDefault
@@ -353,14 +297,6 @@ enum Visibility {
LOCAL = 0x05;
}
enum CallableKind {
// 2 bits
FUN = 0;
VAL = 1;
VAR = 2;
CONSTRUCTOR = 3;
}
enum MemberKind {
// 2 bits
DECLARATION = 0;
@@ -36,8 +36,11 @@ public class Flags {
// Callables
public static final FlagField<ProtoBuf.CallableKind> CALLABLE_KIND = FlagField.after(MODALITY, ProtoBuf.CallableKind.values());
public static final FlagField<ProtoBuf.MemberKind> MEMBER_KIND = FlagField.after(CALLABLE_KIND, ProtoBuf.MemberKind.values());
// TODO: use these flags
public static final FlagField<Boolean> RESERVED_1 = FlagField.booleanAfter(MODALITY);
public static final FlagField<Boolean> RESERVED_2 = FlagField.booleanAfter(RESERVED_1);
public static final FlagField<ProtoBuf.MemberKind> MEMBER_KIND = FlagField.after(RESERVED_2, ProtoBuf.MemberKind.values());
// Constructors
@@ -57,16 +60,6 @@ public class Flags {
public static final FlagField<Boolean> LATE_INIT = FlagField.booleanAfter(IS_CONST);
public static final FlagField<Boolean> HAS_CONSTANT = FlagField.booleanAfter(LATE_INIT);
// Old callables. TODO: delete
public static final FlagField<Boolean> OLD_HAS_GETTER = FlagField.booleanAfter(MEMBER_KIND);
public static final FlagField<Boolean> OLD_HAS_SETTER = FlagField.booleanAfter(OLD_HAS_GETTER);
public static final FlagField<Boolean> OLD_HAS_CONSTANT = FlagField.booleanAfter(OLD_HAS_SETTER);
public static final FlagField<Boolean> OLD_IS_CONST = FlagField.booleanAfter(OLD_HAS_CONSTANT);
public static final FlagField<Boolean> OLD_LATE_INIT = FlagField.booleanAfter(OLD_IS_CONST);
public static final FlagField<Boolean> OLD_IS_OPERATOR = FlagField.booleanAfter(OLD_LATE_INIT);
public static final FlagField<Boolean> OLD_IS_INFIX = FlagField.booleanAfter(OLD_IS_OPERATOR);
// Parameters
public static final FlagField<Boolean> DECLARES_DEFAULT_VALUE = FlagField.booleanAfter(HAS_ANNOTATIONS);
@@ -123,35 +116,6 @@ public class Flags {
throw new IllegalArgumentException("Unknown class kind: " + kind);
}
public static int getCallableFlags(
boolean hasAnnotations,
@NotNull Visibility visibility,
@NotNull Modality modality,
@NotNull CallableMemberDescriptor.Kind memberKind,
@NotNull ProtoBuf.CallableKind callableKind,
boolean hasGetter,
boolean hasSetter,
boolean hasConstant,
boolean lateInit,
boolean isConst,
boolean isOperator,
boolean isInfix
) {
return HAS_ANNOTATIONS.toFlags(hasAnnotations)
| MODALITY.toFlags(modality(modality))
| VISIBILITY.toFlags(visibility(visibility))
| MEMBER_KIND.toFlags(memberKind(memberKind))
| CALLABLE_KIND.toFlags(callableKind)
| OLD_HAS_GETTER.toFlags(hasGetter)
| OLD_HAS_SETTER.toFlags(hasSetter)
| OLD_HAS_CONSTANT.toFlags(hasConstant)
| OLD_LATE_INIT.toFlags(lateInit)
| OLD_IS_CONST.toFlags(isConst)
| OLD_IS_OPERATOR.toFlags(isOperator)
| OLD_IS_INFIX.toFlags(isInfix)
;
}
public static int getConstructorFlags(
boolean hasAnnotations,
@NotNull Visibility visibility,
File diff suppressed because it is too large Load Diff
@@ -9,8 +9,6 @@ public final class BuiltInsProtoBuf {
com.google.protobuf.ExtensionRegistryLite registry) {
registry.add(org.jetbrains.kotlin.serialization.builtins.BuiltInsProtoBuf.className);
registry.add(org.jetbrains.kotlin.serialization.builtins.BuiltInsProtoBuf.classAnnotation);
registry.add(org.jetbrains.kotlin.serialization.builtins.BuiltInsProtoBuf.oldCallableAnnotation);
registry.add(org.jetbrains.kotlin.serialization.builtins.BuiltInsProtoBuf.oldCompileTimeValue);
registry.add(org.jetbrains.kotlin.serialization.builtins.BuiltInsProtoBuf.constructorAnnotation);
registry.add(org.jetbrains.kotlin.serialization.builtins.BuiltInsProtoBuf.functionAnnotation);
registry.add(org.jetbrains.kotlin.serialization.builtins.BuiltInsProtoBuf.propertyAnnotation);
@@ -48,36 +46,6 @@ public final class BuiltInsProtoBuf {
150,
com.google.protobuf.WireFormat.FieldType.MESSAGE,
false);
public static final int OLD_CALLABLE_ANNOTATION_FIELD_NUMBER = 150;
/**
* <code>extend .org.jetbrains.kotlin.serialization.Callable { ... }</code>
*/
public static final
com.google.protobuf.GeneratedMessageLite.GeneratedExtension<
org.jetbrains.kotlin.serialization.ProtoBuf.Callable,
java.util.List<org.jetbrains.kotlin.serialization.ProtoBuf.Annotation>> oldCallableAnnotation = com.google.protobuf.GeneratedMessageLite
.newRepeatedGeneratedExtension(
org.jetbrains.kotlin.serialization.ProtoBuf.Callable.getDefaultInstance(),
org.jetbrains.kotlin.serialization.ProtoBuf.Annotation.getDefaultInstance(),
null,
150,
com.google.protobuf.WireFormat.FieldType.MESSAGE,
false);
public static final int OLD_COMPILE_TIME_VALUE_FIELD_NUMBER = 151;
/**
* <code>extend .org.jetbrains.kotlin.serialization.Callable { ... }</code>
*/
public static final
com.google.protobuf.GeneratedMessageLite.GeneratedExtension<
org.jetbrains.kotlin.serialization.ProtoBuf.Callable,
org.jetbrains.kotlin.serialization.ProtoBuf.Annotation.Argument.Value> oldCompileTimeValue = com.google.protobuf.GeneratedMessageLite
.newSingularGeneratedExtension(
org.jetbrains.kotlin.serialization.ProtoBuf.Callable.getDefaultInstance(),
org.jetbrains.kotlin.serialization.ProtoBuf.Annotation.Argument.Value.getDefaultInstance(),
org.jetbrains.kotlin.serialization.ProtoBuf.Annotation.Argument.Value.getDefaultInstance(),
null,
151,
com.google.protobuf.WireFormat.FieldType.MESSAGE);
public static final int CONSTRUCTOR_ANNOTATION_FIELD_NUMBER = 150;
/**
* <code>extend .org.jetbrains.kotlin.serialization.Constructor { ... }</code>
@@ -39,18 +39,18 @@ public class MemberDeserializer(private val c: DeserializationContext) {
getAnnotations(proto, flags, AnnotatedCallableKind.PROPERTY),
Deserialization.modality(Flags.MODALITY.get(flags)),
Deserialization.visibility(Flags.VISIBILITY.get(flags)),
Flags.CALLABLE_KIND.get(flags) == ProtoBuf.CallableKind.VAR,
Flags.IS_VAR.get(flags),
c.nameResolver.getName(proto.getName()),
Deserialization.memberKind(Flags.MEMBER_KIND.get(flags)),
proto,
c.nameResolver,
Flags.OLD_LATE_INIT.get(flags),
Flags.OLD_IS_CONST.get(flags)
Flags.LATE_INIT.get(flags),
Flags.IS_CONST.get(flags)
)
val local = c.childContext(property, proto.getTypeParameterList())
val hasGetter = Flags.OLD_HAS_GETTER.get(flags)
val hasGetter = Flags.HAS_GETTER.get(flags)
val receiverAnnotations = if (hasGetter && proto.hasReceiverType())
getReceiverParameterAnnotations(proto, AnnotatedCallableKind.PROPERTY_GETTER)
else
@@ -87,7 +87,7 @@ public class MemberDeserializer(private val c: DeserializationContext) {
null
}
val setter = if (Flags.OLD_HAS_SETTER.get(flags)) {
val setter = if (Flags.HAS_SETTER.get(flags)) {
val setterFlags = proto.getSetterFlags()
val isNotDefault = proto.hasSetterFlags() && Flags.IS_NOT_DEFAULT.get(setterFlags)
if (isNotDefault) {
@@ -115,7 +115,7 @@ public class MemberDeserializer(private val c: DeserializationContext) {
null
}
if (Flags.OLD_HAS_CONSTANT.get(flags)) {
if (Flags.HAS_CONSTANT.get(flags)) {
property.setCompileTimeInitializer(
c.storageManager.createNullableLazyValue {
val container = c.containingDeclaration.asProtoContainer()!!
@@ -145,8 +145,8 @@ public class MemberDeserializer(private val c: DeserializationContext) {
Deserialization.modality(Flags.MODALITY.get(proto.flags)),
Deserialization.visibility(Flags.VISIBILITY.get(proto.flags))
)
function.isOperator = Flags.OLD_IS_OPERATOR.get(proto.flags)
function.isInfix = Flags.OLD_IS_INFIX.get(proto.flags)
function.isOperator = Flags.IS_OPERATOR.get(proto.flags)
function.isInfix = Flags.IS_INFIX.get(proto.flags)
return function
}
@@ -322,7 +322,8 @@ public class DeserializedClassDescriptor(
}
val nameResolver = c.nameResolver
return classProto.getMemberList().mapTo(result) { nameResolver.getName(it.getName()) }
return classProto.functionList.mapTo(result) { nameResolver.getName(it.name) } +
classProto.propertyList.mapTo(result) { nameResolver.getName(it.name) }
}
fun all(): Collection<ClassDescriptor> {