Replaced int flags with BitSet in internal API.
This commit is contained in:
@@ -29,7 +29,6 @@ import org.jetbrains.jet.lang.resolve.BindingContextUtils;
|
|||||||
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
|
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
|
||||||
import org.jetbrains.jet.lang.resolve.java.JvmAbi;
|
import org.jetbrains.jet.lang.resolve.java.JvmAbi;
|
||||||
import org.jetbrains.jet.lang.resolve.java.JvmClassName;
|
import org.jetbrains.jet.lang.resolve.java.JvmClassName;
|
||||||
import org.jetbrains.jet.lang.resolve.java.JvmStdlibNames;
|
|
||||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor;
|
import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor;
|
||||||
import org.objectweb.asm.Label;
|
import org.objectweb.asm.Label;
|
||||||
@@ -136,7 +135,7 @@ public class FunctionCodegen {
|
|||||||
throw new IllegalStateException();
|
throw new IllegalStateException();
|
||||||
}
|
}
|
||||||
JetMethodAnnotationWriter aw = JetMethodAnnotationWriter.visitAnnotation(mv);
|
JetMethodAnnotationWriter aw = JetMethodAnnotationWriter.visitAnnotation(mv);
|
||||||
aw.writeFlags(JvmStdlibNames.JET_METHOD_FLAGS_DEFAULT);
|
aw.writeFlags(new BitSet());
|
||||||
aw.writeNullableReturnType(functionDescriptor.getReturnType().isNullable());
|
aw.writeNullableReturnType(functionDescriptor.getReturnType().isNullable());
|
||||||
aw.writeTypeParameters(jvmSignature.getKotlinTypeParameter());
|
aw.writeTypeParameters(jvmSignature.getKotlinTypeParameter());
|
||||||
aw.writeReturnType(jvmSignature.getKotlinReturnType());
|
aw.writeReturnType(jvmSignature.getKotlinReturnType());
|
||||||
|
|||||||
@@ -36,6 +36,8 @@ import org.objectweb.asm.Opcodes;
|
|||||||
import org.objectweb.asm.Type;
|
import org.objectweb.asm.Type;
|
||||||
import org.objectweb.asm.commons.InstructionAdapter;
|
import org.objectweb.asm.commons.InstructionAdapter;
|
||||||
|
|
||||||
|
import java.util.BitSet;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author max
|
* @author max
|
||||||
*/
|
*/
|
||||||
@@ -221,7 +223,9 @@ public class PropertyCodegen {
|
|||||||
|
|
||||||
public static void generateJetPropertyAnnotation(MethodVisitor mv, @NotNull String kotlinType, @NotNull String typeParameters) {
|
public static void generateJetPropertyAnnotation(MethodVisitor mv, @NotNull String kotlinType, @NotNull String typeParameters) {
|
||||||
JetMethodAnnotationWriter aw = JetMethodAnnotationWriter.visitAnnotation(mv);
|
JetMethodAnnotationWriter aw = JetMethodAnnotationWriter.visitAnnotation(mv);
|
||||||
aw.writeFlags(JvmStdlibNames.JET_METHOD_FLAG_PROPERTY);
|
BitSet flags = new BitSet();
|
||||||
|
flags.set(JvmStdlibNames.JET_METHOD_FLAG_PROPERTY_BIT);
|
||||||
|
aw.writeFlags(flags);
|
||||||
aw.writeTypeParameters(typeParameters);
|
aw.writeTypeParameters(typeParameters);
|
||||||
aw.writePropertyType(kotlinType);
|
aw.writePropertyType(kotlinType);
|
||||||
aw.visitEnd();
|
aw.visitEnd();
|
||||||
|
|||||||
+14
-5
@@ -21,6 +21,8 @@ import org.jetbrains.jet.lang.resolve.java.JvmStdlibNames;
|
|||||||
import org.objectweb.asm.AnnotationVisitor;
|
import org.objectweb.asm.AnnotationVisitor;
|
||||||
import org.objectweb.asm.MethodVisitor;
|
import org.objectweb.asm.MethodVisitor;
|
||||||
|
|
||||||
|
import java.util.BitSet;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Stepan Koltsov
|
* @author Stepan Koltsov
|
||||||
*/
|
*/
|
||||||
@@ -30,13 +32,20 @@ public class JetMethodAnnotationWriter {
|
|||||||
private JetMethodAnnotationWriter(AnnotationVisitor av) {
|
private JetMethodAnnotationWriter(AnnotationVisitor av) {
|
||||||
this.av = av;
|
this.av = av;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void writeFlags(int flags) {
|
public void writeFlags(BitSet flags) {
|
||||||
if (flags != JvmStdlibNames.JET_METHOD_FLAGS_DEFAULT) {
|
int flagsValue = 0;
|
||||||
av.visit(JvmStdlibNames.JET_METHOD_FLAGS_FIELD, flags);
|
for (int bit = 0; bit < flags.length(); bit++) {
|
||||||
|
if (flags.get(bit)) {
|
||||||
|
flagsValue |= (1 << bit);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (flagsValue != JvmStdlibNames.JET_METHOD_FLAGS_DEFAULT_VALUE) {
|
||||||
|
av.visit(JvmStdlibNames.JET_METHOD_FLAGS_FIELD, flagsValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void writeTypeParameters(@NotNull String typeParameters) {
|
public void writeTypeParameters(@NotNull String typeParameters) {
|
||||||
if (typeParameters.length() > 0) {
|
if (typeParameters.length() > 0) {
|
||||||
av.visit(JvmStdlibNames.JET_METHOD_TYPE_PARAMETERS_FIELD, typeParameters);
|
av.visit(JvmStdlibNames.JET_METHOD_TYPE_PARAMETERS_FIELD, typeParameters);
|
||||||
|
|||||||
+1
-1
@@ -1597,7 +1597,7 @@ public class JavaDescriptorResolver implements DependencyClassByQualifiedNameRes
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO: ugly
|
// TODO: ugly
|
||||||
if ((method.getJetMethod().flags() & JvmStdlibNames.JET_METHOD_FLAG_PROPERTY) != 0) {
|
if (method.getJetMethod().flags().get(JvmStdlibNames.JET_METHOD_FLAG_PROPERTY_BIT)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+3
-3
@@ -125,7 +125,7 @@ class JavaDescriptorResolverHelper {
|
|||||||
NamedMembers members = getNamedMembers(Name.identifier(propertyName));
|
NamedMembers members = getNamedMembers(Name.identifier(propertyName));
|
||||||
|
|
||||||
// TODO: some java properties too
|
// TODO: some java properties too
|
||||||
if ((method.getJetMethod().flags() & JvmStdlibNames.JET_METHOD_FLAG_PROPERTY) != 0) {
|
if (method.getJetMethod().flags().get(JvmStdlibNames.JET_METHOD_FLAG_PROPERTY_BIT)) {
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
@@ -167,7 +167,7 @@ class JavaDescriptorResolverHelper {
|
|||||||
String propertyName = propertyParseResult.getPropertyName();
|
String propertyName = propertyParseResult.getPropertyName();
|
||||||
NamedMembers members = getNamedMembers(Name.identifier(propertyName));
|
NamedMembers members = getNamedMembers(Name.identifier(propertyName));
|
||||||
|
|
||||||
if ((method.getJetMethod().flags() & JvmStdlibNames.JET_METHOD_FLAG_PROPERTY) != 0) {
|
if (method.getJetMethod().flags().get(JvmStdlibNames.JET_METHOD_FLAG_PROPERTY_BIT)) {
|
||||||
if (method.getParameters().size() == 0) {
|
if (method.getParameters().size() == 0) {
|
||||||
// TODO: report error properly
|
// TODO: report error properly
|
||||||
throw new IllegalStateException();
|
throw new IllegalStateException();
|
||||||
@@ -204,7 +204,7 @@ class JavaDescriptorResolverHelper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((method.getJetMethod().flags() & JvmStdlibNames.JET_METHOD_FLAG_PROPERTY) == 0) {
|
if (!method.getJetMethod().flags().get(JvmStdlibNames.JET_METHOD_FLAG_PROPERTY_BIT)) {
|
||||||
NamedMembers namedMembers = getNamedMembers(Name.identifier(method.getName()));
|
NamedMembers namedMembers = getNamedMembers(Name.identifier(method.getName()));
|
||||||
namedMembers.addMethod(method);
|
namedMembers.addMethod(method);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,8 +48,9 @@ public class JvmStdlibNames {
|
|||||||
public static final String JET_METHOD_TYPE_PARAMETERS_FIELD = "typeParameters";
|
public static final String JET_METHOD_TYPE_PARAMETERS_FIELD = "typeParameters";
|
||||||
public static final String JET_METHOD_PROPERTY_TYPE_FIELD = "propertyType";
|
public static final String JET_METHOD_PROPERTY_TYPE_FIELD = "propertyType";
|
||||||
|
|
||||||
public static final int JET_METHOD_FLAGS_DEFAULT = 0;
|
public static final int JET_METHOD_FLAGS_DEFAULT_VALUE = 0;
|
||||||
public static final int JET_METHOD_FLAG_PROPERTY = 1;
|
public static final int JET_METHOD_FLAGS_BITS = 1;
|
||||||
|
public static final int JET_METHOD_FLAG_PROPERTY_BIT = 0;
|
||||||
|
|
||||||
public static final JvmClassName JET_CONSTRUCTOR = JvmClassName.byFqNameWithoutInnerClasses("jet.runtime.typeinfo.JetConstructor");
|
public static final JvmClassName JET_CONSTRUCTOR = JvmClassName.byFqNameWithoutInnerClasses("jet.runtime.typeinfo.JetConstructor");
|
||||||
|
|
||||||
|
|||||||
+13
-8
@@ -22,6 +22,8 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.jetbrains.jet.lang.resolve.java.JvmStdlibNames;
|
import org.jetbrains.jet.lang.resolve.java.JvmStdlibNames;
|
||||||
|
|
||||||
|
import java.util.BitSet;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Stepan Koltsov
|
* @author Stepan Koltsov
|
||||||
*/
|
*/
|
||||||
@@ -31,16 +33,19 @@ public class JetMethodAnnotation extends PsiAnnotationWrapper {
|
|||||||
super(psiAnnotation);
|
super(psiAnnotation);
|
||||||
}
|
}
|
||||||
|
|
||||||
private int flags;
|
private BitSet flags = null;
|
||||||
private boolean flagsInitialized;
|
public BitSet flags() {
|
||||||
public int flags() {
|
if (flags == null) {
|
||||||
if (!flagsInitialized) {
|
int flagsValue = getIntAttribute(JvmStdlibNames.JET_METHOD_FLAGS_FIELD, JvmStdlibNames.JET_METHOD_FLAGS_DEFAULT_VALUE);
|
||||||
flags = getIntAttribute(JvmStdlibNames.JET_METHOD_FLAGS_FIELD, -1);
|
if (flagsValue == JvmStdlibNames.JET_METHOD_FLAGS_DEFAULT_VALUE) {
|
||||||
if (flags == -1) {
|
|
||||||
// for compatibility
|
// for compatibility
|
||||||
flags = getIntAttribute(JvmStdlibNames.JET_METHOD_KIND_FIELD, JvmStdlibNames.JET_METHOD_FLAGS_DEFAULT);
|
flagsValue = getIntAttribute(JvmStdlibNames.JET_METHOD_KIND_FIELD, JvmStdlibNames.JET_METHOD_FLAGS_DEFAULT_VALUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
flags = new BitSet(JvmStdlibNames.JET_METHOD_FLAGS_BITS);
|
||||||
|
for (int bit = 0; bit < JvmStdlibNames.JET_METHOD_FLAGS_BITS; bit++) {
|
||||||
|
flags.set(bit, (flagsValue & (1 << bit)) != 0);
|
||||||
}
|
}
|
||||||
flagsInitialized = true;
|
|
||||||
}
|
}
|
||||||
return flags;
|
return flags;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user