Added BitSetUtils and method converting BitSet to int.
This commit is contained in:
@@ -37,6 +37,7 @@ import org.jetbrains.jet.lang.resolve.java.JvmStdlibNames;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.DescriptorPredicate;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.lexer.JetTokens;
|
||||
import org.jetbrains.jet.utils.BitSetUtils;
|
||||
import org.objectweb.asm.AnnotationVisitor;
|
||||
import org.objectweb.asm.MethodVisitor;
|
||||
import org.objectweb.asm.Type;
|
||||
@@ -168,11 +169,16 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
if (signature.getKotlinGenericSignature() != null || descriptor.getVisibility() != Visibilities.PUBLIC) {
|
||||
AnnotationVisitor annotationVisitor = v.newAnnotation(myClass, JvmStdlibNames.JET_CLASS.getDescriptor(), true);
|
||||
annotationVisitor.visit(JvmStdlibNames.JET_CLASS_SIGNATURE, signature.getKotlinGenericSignature());
|
||||
BitSet flags = new BitSet();
|
||||
if (descriptor.getVisibility() == Visibilities.INTERNAL) {
|
||||
annotationVisitor.visit(JvmStdlibNames.JET_CLASS_FLAGS_FIELD, 1 << JvmStdlibNames.FLAG_INTERNAL_BIT);
|
||||
flags.set(JvmStdlibNames.FLAG_INTERNAL_BIT);
|
||||
}
|
||||
else if (descriptor.getVisibility() == Visibilities.PRIVATE) {
|
||||
annotationVisitor.visit(JvmStdlibNames.JET_CLASS_FLAGS_FIELD, 1 << JvmStdlibNames.FLAG_PRIVATE_BIT);
|
||||
flags.set(JvmStdlibNames.FLAG_PRIVATE_BIT);
|
||||
}
|
||||
int flagsValue = BitSetUtils.toInt(flags);
|
||||
if (JvmStdlibNames.FLAGS_DEFAULT_VALUE != flagsValue) {
|
||||
annotationVisitor.visit(JvmStdlibNames.JET_CLASS_FLAGS_FIELD, flagsValue);
|
||||
}
|
||||
annotationVisitor.visitEnd();
|
||||
}
|
||||
|
||||
+2
-7
@@ -18,6 +18,7 @@ package org.jetbrains.jet.codegen.signature.kotlin;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.resolve.java.JvmStdlibNames;
|
||||
import org.jetbrains.jet.utils.BitSetUtils;
|
||||
import org.objectweb.asm.AnnotationVisitor;
|
||||
import org.objectweb.asm.MethodVisitor;
|
||||
|
||||
@@ -34,13 +35,7 @@ public class JetMethodAnnotationWriter {
|
||||
}
|
||||
|
||||
public void writeFlags(BitSet flags) {
|
||||
int flagsValue = 0;
|
||||
for (int bit = 0; bit < flags.length(); bit++) {
|
||||
if (flags.get(bit)) {
|
||||
flagsValue |= (1 << bit);
|
||||
}
|
||||
}
|
||||
|
||||
int flagsValue = BitSetUtils.toInt(flags);
|
||||
if (flagsValue != JvmStdlibNames.FLAGS_DEFAULT_VALUE) {
|
||||
av.visit(JvmStdlibNames.JET_METHOD_FLAGS_FIELD, flagsValue);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright 2010-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jet.utils;
|
||||
|
||||
import java.util.BitSet;
|
||||
|
||||
/**
|
||||
* @author Evgeny Gerashchenko
|
||||
* @since 6/14/12
|
||||
*/
|
||||
public class BitSetUtils {
|
||||
private BitSetUtils() {
|
||||
}
|
||||
|
||||
public static int toInt(BitSet bitSet) {
|
||||
int intValue = 0;
|
||||
for (int bit = 0; bit < bitSet.length(); bit++) {
|
||||
if (bitSet.get(bit)) {
|
||||
intValue |= (1 << bit);
|
||||
}
|
||||
}
|
||||
return intValue;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user