Value parameters flags supported

This commit is contained in:
Andrey Breslav
2013-05-16 20:42:30 +04:00
committed by Alexander Udalov
parent 2e978950ab
commit 655db3ca44
3 changed files with 17 additions and 8 deletions
@@ -299,8 +299,7 @@ public class DescriptorDeserializer {
Collections.<AnnotationDescriptor>emptyList(),
nameResolver.getName(proto.getName()),
typeDeserializer.type(proto.getType()),
// TODO: declaresDefaultValue
false,
Flags.declaresDefaultValue(proto.getFlags()),
typeDeserializer.typeOrNull(proto.hasVarargElementType() ? proto.getVarargElementType() : null));
}
}
@@ -147,7 +147,7 @@ public class DescriptorSerializer {
private ProtoBuf.Callable.ValueParameter.Builder valueParameter(ValueParameterDescriptor descriptor) {
ProtoBuf.Callable.ValueParameter.Builder builder = ProtoBuf.Callable.ValueParameter.newBuilder();
builder.setFlags(flags(descriptor));
builder.setFlags(Flags.getValueParameterFlags(descriptor.declaresDefaultValue()));
builder.setName(nameTable.getSimpleNameIndex(descriptor.getName()));
@@ -161,11 +161,6 @@ public class DescriptorSerializer {
return builder;
}
private int flags(ValueParameterDescriptor descriptor) {
// TODO
return 0;
}
private ProtoBuf.TypeParameter.Builder typeParameter(TypeParameterDescriptor typeParameter) {
ProtoBuf.TypeParameter.Builder builder = ProtoBuf.TypeParameter.newBuilder();
@@ -33,6 +33,11 @@ public class Flags {
public static final int INLINE_BIT_COUNT = 1;
public static final int INLINE_OFFSET = MEMBER_KIND_OFFSET + MEMBER_KIND_BIT_COUNT;
// Parameters
public static final int DECLARES_DEFAULT_VALUE_BIT_COUNT = 1;
public static final int DECLARES_DEFAULT_VALUE_OFFSET = 0;
// ---
private static final Boolean[] BOOLEANS = { false, true };
@@ -87,6 +92,10 @@ public class Flags {
return getValue(flags, BOOLEANS, INLINE_BIT_COUNT, INLINE_OFFSET);
}
public static boolean declaresDefaultValue(int flags) {
return getValue(flags, BOOLEANS, DECLARES_DEFAULT_VALUE_BIT_COUNT, DECLARES_DEFAULT_VALUE_OFFSET);
}
public static int getClassFlags(Visibility visibility, Modality modality, ClassKind kind, boolean inner) {
int visibilityInt = visibility(visibility).getNumber();
int modalityInt = modality(modality).getNumber();
@@ -183,4 +192,10 @@ public class Flags {
}
throw new IllegalArgumentException("Unknown member kind: " + kind);
}
public static int getValueParameterFlags(boolean declaresDefaultValue) {
int declaresDefaultValueInt = declaresDefaultValue ? 1 : 0;
return declaresDefaultValueInt << DECLARES_DEFAULT_VALUE_OFFSET
;
}
}