Add JVM prefix to CodegenUtil name to give way for backend-independent CodegenUtil
This commit is contained in:
committed by
Zalim Bashorov
parent
981b6fdaff
commit
00e65c8771
@@ -133,7 +133,7 @@ public abstract class AnnotationCodegen {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean isNullableType = CodegenUtil.isNullableType(type);
|
boolean isNullableType = JvmCodegenUtil.isNullableType(type);
|
||||||
if (!isNullableType && KotlinBuiltIns.getInstance().isPrimitiveType(type)) return;
|
if (!isNullableType && KotlinBuiltIns.getInstance().isPrimitiveType(type)) return;
|
||||||
|
|
||||||
Class<?> annotationClass = isNullableType ? Nullable.class : NotNull.class;
|
Class<?> annotationClass = isNullableType ? Nullable.class : NotNull.class;
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ import java.util.Map;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import static org.jetbrains.org.objectweb.asm.Opcodes.*;
|
import static org.jetbrains.org.objectweb.asm.Opcodes.*;
|
||||||
import static org.jetbrains.jet.codegen.CodegenUtil.*;
|
import static org.jetbrains.jet.codegen.JvmCodegenUtil.*;
|
||||||
import static org.jetbrains.jet.lang.resolve.DescriptorUtils.*;
|
import static org.jetbrains.jet.lang.resolve.DescriptorUtils.*;
|
||||||
import static org.jetbrains.jet.lang.resolve.java.AsmTypeConstants.JAVA_STRING_TYPE;
|
import static org.jetbrains.jet.lang.resolve.java.AsmTypeConstants.JAVA_STRING_TYPE;
|
||||||
import static org.jetbrains.jet.lang.resolve.java.JvmAnnotationNames.ABI_VERSION_FIELD_NAME;
|
import static org.jetbrains.jet.lang.resolve.java.JvmAnnotationNames.ABI_VERSION_FIELD_NAME;
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ import java.util.Collection;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static org.jetbrains.jet.codegen.AsmUtil.*;
|
import static org.jetbrains.jet.codegen.AsmUtil.*;
|
||||||
import static org.jetbrains.jet.codegen.CodegenUtil.isConst;
|
import static org.jetbrains.jet.codegen.JvmCodegenUtil.isConst;
|
||||||
import static org.jetbrains.jet.codegen.binding.CodegenBinding.*;
|
import static org.jetbrains.jet.codegen.binding.CodegenBinding.*;
|
||||||
import static org.jetbrains.jet.lang.resolve.java.JvmAnnotationNames.KotlinSyntheticClass;
|
import static org.jetbrains.jet.lang.resolve.java.JvmAnnotationNames.KotlinSyntheticClass;
|
||||||
import static org.jetbrains.org.objectweb.asm.Opcodes.*;
|
import static org.jetbrains.org.objectweb.asm.Opcodes.*;
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ import org.jetbrains.org.objectweb.asm.commons.Method;
|
|||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
import static org.jetbrains.jet.codegen.AsmUtil.*;
|
import static org.jetbrains.jet.codegen.AsmUtil.*;
|
||||||
import static org.jetbrains.jet.codegen.CodegenUtil.*;
|
import static org.jetbrains.jet.codegen.JvmCodegenUtil.*;
|
||||||
import static org.jetbrains.jet.codegen.FunctionTypesUtil.functionTypeToImpl;
|
import static org.jetbrains.jet.codegen.FunctionTypesUtil.functionTypeToImpl;
|
||||||
import static org.jetbrains.jet.codegen.FunctionTypesUtil.getFunctionImplType;
|
import static org.jetbrains.jet.codegen.FunctionTypesUtil.getFunctionImplType;
|
||||||
import static org.jetbrains.jet.codegen.binding.CodegenBinding.*;
|
import static org.jetbrains.jet.codegen.binding.CodegenBinding.*;
|
||||||
@@ -3511,7 +3511,7 @@ The "returned" value of try expression with no finally is either the last expres
|
|||||||
value.put(boxType(value.type), v);
|
value.put(boxType(value.type), v);
|
||||||
|
|
||||||
if (opToken != JetTokens.AS_SAFE) {
|
if (opToken != JetTokens.AS_SAFE) {
|
||||||
if (!CodegenUtil.isNullableType(rightType)) {
|
if (!JvmCodegenUtil.isNullableType(rightType)) {
|
||||||
v.dup();
|
v.dup();
|
||||||
Label nonnull = new Label();
|
Label nonnull = new Label();
|
||||||
v.ifnonnull(nonnull);
|
v.ifnonnull(nonnull);
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ import org.jetbrains.org.objectweb.asm.commons.Method;
|
|||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
import static org.jetbrains.jet.codegen.AsmUtil.*;
|
import static org.jetbrains.jet.codegen.AsmUtil.*;
|
||||||
import static org.jetbrains.jet.codegen.CodegenUtil.*;
|
import static org.jetbrains.jet.codegen.JvmCodegenUtil.*;
|
||||||
import static org.jetbrains.jet.codegen.binding.CodegenBinding.*;
|
import static org.jetbrains.jet.codegen.binding.CodegenBinding.*;
|
||||||
import static org.jetbrains.jet.descriptors.serialization.NameSerializationUtil.createNameResolver;
|
import static org.jetbrains.jet.descriptors.serialization.NameSerializationUtil.createNameResolver;
|
||||||
import static org.jetbrains.jet.lang.resolve.BindingContextUtils.descriptorToDeclaration;
|
import static org.jetbrains.jet.lang.resolve.BindingContextUtils.descriptorToDeclaration;
|
||||||
@@ -512,7 +512,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
|||||||
int access = descriptor.getKind() == ClassKind.TRAIT ?
|
int access = descriptor.getKind() == ClassKind.TRAIT ?
|
||||||
ACC_PUBLIC | ACC_ABSTRACT :
|
ACC_PUBLIC | ACC_ABSTRACT :
|
||||||
ACC_PUBLIC;
|
ACC_PUBLIC;
|
||||||
if (CodegenUtil.getDeclaredFunctionByRawSignature(descriptor, Name.identifier("toArray"), builtIns.getArray()) == null) {
|
if (JvmCodegenUtil.getDeclaredFunctionByRawSignature(descriptor, Name.identifier("toArray"), builtIns.getArray()) == null) {
|
||||||
MethodVisitor mv = v.getVisitor().visitMethod(access, "toArray", "()[Ljava/lang/Object;", null, null);
|
MethodVisitor mv = v.getVisitor().visitMethod(access, "toArray", "()[Ljava/lang/Object;", null, null);
|
||||||
|
|
||||||
if (descriptor.getKind() != ClassKind.TRAIT) {
|
if (descriptor.getKind() != ClassKind.TRAIT) {
|
||||||
@@ -551,7 +551,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
|||||||
@NotNull ClassifierDescriptor returnedClassifier,
|
@NotNull ClassifierDescriptor returnedClassifier,
|
||||||
@NotNull ClassifierDescriptor... valueParameterClassifiers
|
@NotNull ClassifierDescriptor... valueParameterClassifiers
|
||||||
) {
|
) {
|
||||||
if (CodegenUtil.getDeclaredFunctionByRawSignature(
|
if (JvmCodegenUtil.getDeclaredFunctionByRawSignature(
|
||||||
descriptor, Name.identifier(name), returnedClassifier, valueParameterClassifiers) == null) {
|
descriptor, Name.identifier(name), returnedClassifier, valueParameterClassifiers) == null) {
|
||||||
int access = descriptor.getKind() == ClassKind.TRAIT ?
|
int access = descriptor.getKind() == ClassKind.TRAIT ?
|
||||||
ACC_PUBLIC | ACC_ABSTRACT :
|
ACC_PUBLIC | ACC_ABSTRACT :
|
||||||
|
|||||||
+2
-2
@@ -47,9 +47,9 @@ import java.util.List;
|
|||||||
|
|
||||||
import static org.jetbrains.jet.lang.descriptors.Modality.ABSTRACT;
|
import static org.jetbrains.jet.lang.descriptors.Modality.ABSTRACT;
|
||||||
|
|
||||||
public class CodegenUtil {
|
public class JvmCodegenUtil {
|
||||||
|
|
||||||
private CodegenUtil() {
|
private JvmCodegenUtil() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isInterface(DeclarationDescriptor descriptor) {
|
public static boolean isInterface(DeclarationDescriptor descriptor) {
|
||||||
@@ -387,7 +387,7 @@ public class PackageCodegen extends GenerationStateAware {
|
|||||||
|
|
||||||
// path hashCode to prevent same name / different path collision
|
// path hashCode to prevent same name / different path collision
|
||||||
String srcName = facadeFqName.shortName().asString() + "-" + replaceSpecialSymbols(fileName) + "-" + Integer.toHexString(
|
String srcName = facadeFqName.shortName().asString() + "-" + replaceSpecialSymbols(fileName) + "-" + Integer.toHexString(
|
||||||
CodegenUtil.getPathHashCode(file));
|
JvmCodegenUtil.getPathHashCode(file));
|
||||||
|
|
||||||
return asmTypeByFqNameWithoutInnerClasses(facadeFqName.parent().child(Name.identifier(srcName)));
|
return asmTypeByFqNameWithoutInnerClasses(facadeFqName.parent().child(Name.identifier(srcName)));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,8 +44,8 @@ import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter;
|
|||||||
import org.jetbrains.org.objectweb.asm.commons.Method;
|
import org.jetbrains.org.objectweb.asm.commons.Method;
|
||||||
|
|
||||||
import static org.jetbrains.jet.codegen.AsmUtil.*;
|
import static org.jetbrains.jet.codegen.AsmUtil.*;
|
||||||
import static org.jetbrains.jet.codegen.CodegenUtil.getParentBodyCodegen;
|
import static org.jetbrains.jet.codegen.JvmCodegenUtil.getParentBodyCodegen;
|
||||||
import static org.jetbrains.jet.codegen.CodegenUtil.isInterface;
|
import static org.jetbrains.jet.codegen.JvmCodegenUtil.isInterface;
|
||||||
import static org.jetbrains.jet.codegen.JvmSerializationBindings.*;
|
import static org.jetbrains.jet.codegen.JvmSerializationBindings.*;
|
||||||
import static org.jetbrains.jet.lang.resolve.DescriptorUtils.isTrait;
|
import static org.jetbrains.jet.lang.resolve.DescriptorUtils.isTrait;
|
||||||
import static org.jetbrains.jet.lang.resolve.java.AsmTypeConstants.OBJECT_TYPE;
|
import static org.jetbrains.jet.lang.resolve.java.AsmTypeConstants.OBJECT_TYPE;
|
||||||
|
|||||||
@@ -138,7 +138,7 @@ public class SamWrapperCodegen extends ParentCodegenAwareImpl {
|
|||||||
FqName packageClassFqName = PackageClassUtils.getPackageClassFqName(containingFile.getPackageFqName());
|
FqName packageClassFqName = PackageClassUtils.getPackageClassFqName(containingFile.getPackageFqName());
|
||||||
String packageInternalName = JvmClassName.byFqNameWithoutInnerClasses(packageClassFqName).getInternalName();
|
String packageInternalName = JvmClassName.byFqNameWithoutInnerClasses(packageClassFqName).getInternalName();
|
||||||
return packageInternalName + "$sam$" + samInterface.getName().asString() + "$" +
|
return packageInternalName + "$sam$" + samInterface.getName().asString() + "$" +
|
||||||
Integer.toHexString(CodegenUtil.getPathHashCode(containingFile.getVirtualFile()) * 31 + DescriptorUtils.getFqNameSafe(
|
Integer.toHexString(JvmCodegenUtil.getPathHashCode(containingFile.getVirtualFile()) * 31 + DescriptorUtils.getFqNameSafe(
|
||||||
samInterface).hashCode());
|
samInterface).hashCode());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -46,7 +46,7 @@ import org.jetbrains.org.objectweb.asm.Type;
|
|||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
import static org.jetbrains.jet.codegen.CodegenUtil.peekFromStack;
|
import static org.jetbrains.jet.codegen.JvmCodegenUtil.peekFromStack;
|
||||||
import static org.jetbrains.jet.codegen.FunctionTypesUtil.getSuperTypeForClosure;
|
import static org.jetbrains.jet.codegen.FunctionTypesUtil.getSuperTypeForClosure;
|
||||||
import static org.jetbrains.jet.codegen.binding.CodegenBinding.*;
|
import static org.jetbrains.jet.codegen.binding.CodegenBinding.*;
|
||||||
import static org.jetbrains.jet.lang.resolve.BindingContext.*;
|
import static org.jetbrains.jet.lang.resolve.BindingContext.*;
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ import org.jetbrains.jet.util.slicedmap.WritableSlice;
|
|||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
import static org.jetbrains.jet.codegen.CodegenUtil.isInterface;
|
import static org.jetbrains.jet.codegen.JvmCodegenUtil.isInterface;
|
||||||
import static org.jetbrains.jet.lang.resolve.BindingContext.*;
|
import static org.jetbrains.jet.lang.resolve.BindingContext.*;
|
||||||
import static org.jetbrains.jet.lang.resolve.DescriptorUtils.isEnumClass;
|
import static org.jetbrains.jet.lang.resolve.DescriptorUtils.isEnumClass;
|
||||||
|
|
||||||
|
|||||||
@@ -16,8 +16,8 @@
|
|||||||
|
|
||||||
package org.jetbrains.jet.codegen.context;
|
package org.jetbrains.jet.codegen.context;
|
||||||
|
|
||||||
|
import org.jetbrains.jet.codegen.JvmCodegenUtil;
|
||||||
import org.jetbrains.org.objectweb.asm.Type;
|
import org.jetbrains.org.objectweb.asm.Type;
|
||||||
import org.jetbrains.jet.codegen.CodegenUtil;
|
|
||||||
import org.jetbrains.jet.codegen.ExpressionCodegen;
|
import org.jetbrains.jet.codegen.ExpressionCodegen;
|
||||||
import org.jetbrains.jet.codegen.StackValue;
|
import org.jetbrains.jet.codegen.StackValue;
|
||||||
import org.jetbrains.jet.codegen.binding.MutableClosure;
|
import org.jetbrains.jet.codegen.binding.MutableClosure;
|
||||||
@@ -92,7 +92,7 @@ public interface LocalLookup {
|
|||||||
Type localType = asmTypeForAnonymousClass(bindingContext, vd);
|
Type localType = asmTypeForAnonymousClass(bindingContext, vd);
|
||||||
|
|
||||||
MutableClosure localFunClosure = bindingContext.get(CLOSURE, bindingContext.get(CLASS_FOR_FUNCTION, vd));
|
MutableClosure localFunClosure = bindingContext.get(CLOSURE, bindingContext.get(CLASS_FOR_FUNCTION, vd));
|
||||||
if (localFunClosure != null && CodegenUtil.isConst(localFunClosure)) {
|
if (localFunClosure != null && JvmCodegenUtil.isConst(localFunClosure)) {
|
||||||
// This is an optimization: we can obtain an instance of a const closure simply by GETSTATIC ...$instance
|
// This is an optimization: we can obtain an instance of a const closure simply by GETSTATIC ...$instance
|
||||||
// (instead of passing this instance to the constructor and storing as a field)
|
// (instead of passing this instance to the constructor and storing as a field)
|
||||||
return StackValue.field(localType, localType, JvmAbi.INSTANCE_FIELD, true);
|
return StackValue.field(localType, localType, JvmAbi.INSTANCE_FIELD, true);
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ public class InlineCodegen implements ParentCodegenAware, CallGenerator {
|
|||||||
this.asFunctionInline = false;
|
this.asFunctionInline = false;
|
||||||
|
|
||||||
isSameModule = !(functionDescriptor instanceof DeserializedSimpleFunctionDescriptor) /*not compiled library*/ &&
|
isSameModule = !(functionDescriptor instanceof DeserializedSimpleFunctionDescriptor) /*not compiled library*/ &&
|
||||||
CodegenUtil.isCallInsideSameModuleAsDeclared(functionDescriptor, codegen.getContext());
|
JvmCodegenUtil.isCallInsideSameModuleAsDeclared(functionDescriptor, codegen.getContext());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ import java.util.List;
|
|||||||
|
|
||||||
import static org.jetbrains.jet.codegen.AsmUtil.boxType;
|
import static org.jetbrains.jet.codegen.AsmUtil.boxType;
|
||||||
import static org.jetbrains.jet.codegen.AsmUtil.getTraitImplThisParameterType;
|
import static org.jetbrains.jet.codegen.AsmUtil.getTraitImplThisParameterType;
|
||||||
import static org.jetbrains.jet.codegen.CodegenUtil.*;
|
import static org.jetbrains.jet.codegen.JvmCodegenUtil.*;
|
||||||
import static org.jetbrains.jet.codegen.binding.CodegenBinding.*;
|
import static org.jetbrains.jet.codegen.binding.CodegenBinding.*;
|
||||||
import static org.jetbrains.jet.lang.resolve.BindingContextUtils.isVarCapturedInClosure;
|
import static org.jetbrains.jet.lang.resolve.BindingContextUtils.isVarCapturedInClosure;
|
||||||
import static org.jetbrains.jet.lang.resolve.DescriptorUtils.*;
|
import static org.jetbrains.jet.lang.resolve.DescriptorUtils.*;
|
||||||
|
|||||||
Reference in New Issue
Block a user