From 8840a9bdd8862f33b52a8d999f942e7a2e71f401 Mon Sep 17 00:00:00 2001 From: Alex Tkachman Date: Wed, 29 Aug 2012 14:30:44 +0300 Subject: [PATCH] some static methods moved from JetTypeMapper to CodegenUtil & CodegenBinding --- .../jetbrains/jet/codegen/CodegenUtil.java | 48 +++++++++++++++ .../jet/codegen/ExpressionCodegen.java | 17 +++--- .../jet/codegen/FunctionCodegen.java | 2 +- .../codegen/ImplementationBodyCodegen.java | 16 +++-- .../jetbrains/jet/codegen/JetTypeMapper.java | 61 +------------------ .../org/jetbrains/jet/codegen/StackValue.java | 8 ++- .../jet/codegen/context/CodegenBinding.java | 6 ++ .../jet/codegen/context/CodegenContext.java | 12 +++- .../jet/codegen/intrinsics/ArrayGet.java | 2 +- .../jet/codegen/intrinsics/ArraySet.java | 2 +- .../jet/codegen/intrinsics/BinaryOp.java | 9 +-- .../jet/codegen/intrinsics/Increment.java | 9 +-- .../jetbrains/jet/codegen/intrinsics/Inv.java | 7 +-- .../jet/codegen/intrinsics/UnaryMinus.java | 7 +-- .../jet/codegen/intrinsics/UnaryPlus.java | 7 +-- .../jet/asJava/JavaElementFinder.java | 4 +- 16 files changed, 108 insertions(+), 109 deletions(-) diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/CodegenUtil.java b/compiler/backend/src/org/jetbrains/jet/codegen/CodegenUtil.java index 0f2e0d0f5b0..1252f83d061 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/CodegenUtil.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/CodegenUtil.java @@ -17,8 +17,10 @@ package org.jetbrains.jet.codegen; import com.intellij.openapi.util.Pair; +import com.intellij.psi.PsiElement; import com.intellij.util.containers.Stack; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import org.jetbrains.asm4.MethodVisitor; import org.jetbrains.asm4.Type; import org.jetbrains.asm4.commons.InstructionAdapter; @@ -31,7 +33,9 @@ import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor; import org.jetbrains.jet.lang.psi.*; import org.jetbrains.jet.lang.resolve.BindingContext; import org.jetbrains.jet.lang.resolve.DescriptorUtils; +import org.jetbrains.jet.lang.resolve.java.JvmAbi; import org.jetbrains.jet.lang.resolve.java.JvmClassName; +import org.jetbrains.jet.lang.resolve.java.JvmPrimitiveType; import org.jetbrains.jet.lang.resolve.java.JvmStdlibNames; import org.jetbrains.jet.lang.resolve.name.Name; import org.jetbrains.jet.lang.types.JetType; @@ -256,4 +260,48 @@ public class CodegenUtil { return defaultFlags; } } + + public static Type unboxType(final Type type) { + JvmPrimitiveType jvmPrimitiveType = JvmPrimitiveType.getByWrapperAsmType(type); + if (jvmPrimitiveType != null) { + return jvmPrimitiveType.getAsmType(); + } + else { + throw new UnsupportedOperationException("Unboxing: " + type); + } + } + + public static Type boxType(Type asmType) { + JvmPrimitiveType jvmPrimitiveType = JvmPrimitiveType.getByAsmType(asmType); + if (jvmPrimitiveType != null) { + return jvmPrimitiveType.getWrapper().getAsmType(); + } + else { + return asmType; + } + } + + public static boolean isIntPrimitive(Type type) { + return type == Type.INT_TYPE || type == Type.SHORT_TYPE || type == Type.BYTE_TYPE || type == Type.CHAR_TYPE; + } + + public static boolean isPrimitive(Type type) { + return type.getSort() != Type.OBJECT && type.getSort() != Type.ARRAY; + } + + public static Type correctElementType(Type type) { + String internalName = type.getInternalName(); + assert internalName.charAt(0) == '['; + return Type.getType(internalName.substring(1)); + } + + @Nullable + public static String getLocalNameForObject(JetObjectDeclaration object) { + PsiElement parent = object.getParent(); + if (parent instanceof JetClassObject) { + return JvmAbi.CLASS_OBJECT_CLASS_NAME; + } + + return null; + } } diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/ExpressionCodegen.java b/compiler/backend/src/org/jetbrains/jet/codegen/ExpressionCodegen.java index 20a53905a11..6853ac16709 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/ExpressionCodegen.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/ExpressionCodegen.java @@ -57,7 +57,6 @@ import java.util.*; import static org.jetbrains.asm4.Opcodes.*; import static org.jetbrains.jet.codegen.AsmTypeConstants.*; import static org.jetbrains.jet.codegen.CodegenUtil.*; -import static org.jetbrains.jet.codegen.JetTypeMapper.*; import static org.jetbrains.jet.codegen.context.CodegenBinding.*; import static org.jetbrains.jet.lang.resolve.BindingContext.*; import static org.jetbrains.jet.lang.resolve.BindingContextUtils.*; @@ -1060,8 +1059,10 @@ public class ExpressionCodegen extends JetVisitor implem .getCalleeExpression() .getConstructorReferenceExpression()); assert superConstructor != null; + //noinspection SuspiciousMethodCalls CallableMethod superCallable = typeMapper - .mapToCallableMethod(superConstructor, typeMapper.getCalculatedClosure(superConstructor.getContainingDeclaration())); + .mapToCallableMethod(superConstructor, + bindingContext.get(CLOSURE, superConstructor.getContainingDeclaration())); Type[] argumentTypes = superCallable.getSignature().getAsmMethod().getArgumentTypes(); ResolvedCall resolvedCall = bindingContext.get(BindingContext.RESOLVED_CALL, superCall.getCalleeExpression()); assert resolvedCall != null; @@ -2885,12 +2886,14 @@ public class ExpressionCodegen extends JetVisitor implem v.dup(); final ClassDescriptor classDescriptor = ((ConstructorDescriptor) constructorDescriptor).getContainingDeclaration(); + CallableMethod method = typeMapper - .mapToCallableMethod((ConstructorDescriptor) constructorDescriptor, typeMapper - .getCalculatedClosure(classDescriptor)); + .mapToCallableMethod((ConstructorDescriptor) constructorDescriptor, + bindingContext.get(CLOSURE, classDescriptor)); receiver.put(receiver.type, v); - pushClosureOnStack(typeMapper.getCalculatedClosure(classDescriptor), true); + + pushClosureOnStack(bindingContext.get(CLOSURE, classDescriptor), true); invokeMethodWithArguments(method, expression, StackValue.none()); } } @@ -3200,7 +3203,7 @@ The "returned" value of try expression with no finally is either the last expres DeclarationDescriptor descriptor = rightType.getConstructor().getDeclarationDescriptor(); if (descriptor instanceof ClassDescriptor || descriptor instanceof TypeParameterDescriptor) { StackValue value = genQualified(receiver, left); - value.put(JetTypeMapper.boxType(value.type), v); + value.put(boxType(value.type), v); assert leftType != null; if (opToken != JetTokens.AS_SAFE) { @@ -3268,7 +3271,7 @@ The "returned" value of try expression with no finally is either the last expres assert condJetType != null; condType = asmType(condJetType); if (!(isNumberPrimitive(condType) || condType.getSort() == Type.BOOLEAN)) { - subjectType = JetTypeMapper.boxType(subjectType); + subjectType = boxType(subjectType); expressionToMatch.coerce(subjectType, v); } } diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/FunctionCodegen.java b/compiler/backend/src/org/jetbrains/jet/codegen/FunctionCodegen.java index 7402fee48f5..a80106233aa 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/FunctionCodegen.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/FunctionCodegen.java @@ -665,7 +665,7 @@ public class FunctionCodegen { iv.invokevirtual(state.getInjector().getJetTypeMapper().mapType( ((ClassDescriptor) owner.getContextDescriptor()).getDefaultType(), MapTypeMode.VALUE).getInternalName(), jvmSignature.getName(), jvmSignature.getDescriptor()); - if (JetTypeMapper.isPrimitive(jvmSignature.getReturnType()) && !JetTypeMapper.isPrimitive(overridden.getReturnType())) { + if (isPrimitive(jvmSignature.getReturnType()) && !isPrimitive(overridden.getReturnType())) { StackValue.valueOf(iv, jvmSignature.getReturnType()); } if (jvmSignature.getReturnType() == Type.VOID_TYPE) { diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/ImplementationBodyCodegen.java b/compiler/backend/src/org/jetbrains/jet/codegen/ImplementationBodyCodegen.java index 31e2818d2e3..ce1dcbf5ec2 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/ImplementationBodyCodegen.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/ImplementationBodyCodegen.java @@ -27,6 +27,7 @@ import org.jetbrains.asm4.Type; import org.jetbrains.asm4.commons.InstructionAdapter; import org.jetbrains.asm4.commons.Method; import org.jetbrains.jet.codegen.context.CalculatedClosure; +import org.jetbrains.jet.codegen.context.CodegenBinding; import org.jetbrains.jet.codegen.context.CodegenContext; import org.jetbrains.jet.codegen.context.MutableClosure; import org.jetbrains.jet.codegen.signature.*; @@ -51,6 +52,7 @@ import java.util.*; import static org.jetbrains.asm4.Opcodes.*; import static org.jetbrains.jet.codegen.CodegenUtil.*; import static org.jetbrains.jet.codegen.AsmTypeConstants.*; +import static org.jetbrains.jet.codegen.context.CodegenBinding.CLOSURE; import static org.jetbrains.jet.codegen.context.CodegenBinding.eclosingClassDescriptor; import static org.jetbrains.jet.codegen.context.CodegenBinding.enumEntryNeedSubclass; import static org.jetbrains.jet.lang.resolve.BindingContextUtils.callableDescriptorToDeclaration; @@ -704,7 +706,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen { List parameterTypes = new ArrayList(); assert superType != null; ClassDescriptor superClassDescriptor = (ClassDescriptor) superType.getConstructor().getDeclarationDescriptor(); - if (typeMapper.hasThis0(superClassDescriptor)) { + if (CodegenBinding.hasThis0(bindingContext, superClassDescriptor)) { iv.load(1, OBJECT_TYPE); parameterTypes.add(typeMapper.mapType( eclosingClassDescriptor(typeMapper.getBindingContext(), descriptor).getDefaultType(), MapTypeMode.VALUE)); @@ -1006,7 +1008,8 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen { assert resolvedCall != null; final ConstructorDescriptor superConstructor = (ConstructorDescriptor) resolvedCall.getResultingDescriptor(); - final CalculatedClosure closureForSuper = typeMapper.getCalculatedClosure(superConstructor.getContainingDeclaration()); + //noinspection SuspiciousMethodCalls + final CalculatedClosure closureForSuper = bindingContext.get(CLOSURE, superConstructor.getContainingDeclaration()); CallableMethod superCallable = typeMapper.mapToCallableMethod(superConstructor, closureForSuper); @@ -1113,8 +1116,9 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen { ConstructorDescriptor constructorDescriptor = (ConstructorDescriptor) bindingContext .get(BindingContext.REFERENCE_TARGET, superCall.getCalleeExpression().getConstructorReferenceExpression()); assert constructorDescriptor != null; - CallableMethod method = typeMapper.mapToCallableMethod(constructorDescriptor, typeMapper - .getCalculatedClosure(constructorDescriptor.getContainingDeclaration())); + //noinspection SuspiciousMethodCalls + CallableMethod method = typeMapper.mapToCallableMethod(constructorDescriptor, bindingContext + .get(CLOSURE, constructorDescriptor.getContainingDeclaration())); codegen.invokeMethodWithArguments(method, superCall, StackValue.none()); } else { @@ -1152,7 +1156,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen { iv.load(0, OBJECT_TYPE); Type type = codegen.expressionType(initializer); if (jetType.isNullable()) { - type = JetTypeMapper.boxType(type); + type = boxType(type); } codegen.gen(initializer, type); // @todo write directly to the field. Fix test excloset.jet::test6 @@ -1170,7 +1174,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen { } private static boolean skipDefaultValue(PropertyDescriptor propertyDescriptor, Object value, Type type) { - if (JetTypeMapper.isPrimitive(type)) { + if (isPrimitive(type)) { if (!propertyDescriptor.getType().isNullable() && value instanceof Number) { if (type == Type.INT_TYPE && ((Number) value).intValue() == 0) { return true; diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/JetTypeMapper.java b/compiler/backend/src/org/jetbrains/jet/codegen/JetTypeMapper.java index 6032d680e2b..473ced0835f 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/JetTypeMapper.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/JetTypeMapper.java @@ -24,10 +24,8 @@ import org.jetbrains.jet.codegen.context.CalculatedClosure; import org.jetbrains.jet.codegen.context.EnclosedValueDescriptor; import org.jetbrains.jet.codegen.signature.*; import org.jetbrains.jet.lang.descriptors.*; -import org.jetbrains.jet.lang.psi.JetClassObject; import org.jetbrains.jet.lang.psi.JetDelegatorToSuperCall; import org.jetbrains.jet.lang.psi.JetElement; -import org.jetbrains.jet.lang.psi.JetObjectDeclaration; import org.jetbrains.jet.lang.resolve.BindingContext; import org.jetbrains.jet.lang.resolve.BindingTrace; import org.jetbrains.jet.lang.resolve.DescriptorUtils; @@ -76,17 +74,6 @@ public class JetTypeMapper { this.classBuilderMode = classBuilderMode; } - public boolean hasThis0(ClassDescriptor classDescriptor) { - //noinspection SuspiciousMethodCalls - final CalculatedClosure closure = bindingContext.get(CLOSURE, classDescriptor); - return closure != null && closure.getCaptureThis() != null; - } - - public CalculatedClosure getCalculatedClosure(ClassDescriptor classDescriptor) { - //noinspection SuspiciousMethodCalls - return bindingContext.get(CLOSURE, classDescriptor); - } - public BindingTrace getBindingTrace() { return bindingTrace; } @@ -95,20 +82,6 @@ public class JetTypeMapper { return bindingContext; } - public static boolean isIntPrimitive(Type type) { - return type == Type.INT_TYPE || type == Type.SHORT_TYPE || type == Type.BYTE_TYPE || type == Type.CHAR_TYPE; - } - - public static boolean isPrimitive(Type type) { - return type.getSort() != Type.OBJECT && type.getSort() != Type.ARRAY; - } - - public static Type correctElementType(Type type) { - String internalName = type.getInternalName(); - assert internalName.charAt(0) == '['; - return Type.getType(internalName.substring(1)); - } - @NotNull public JvmClassName getOwner(DeclarationDescriptor descriptor, OwnerKind kind) { MapTypeMode mapTypeMode = ownerKindToMapTypeMode(kind); @@ -237,16 +210,6 @@ public class JetTypeMapper { return mapType(jetType, signatureVisitor, MapTypeMode.VALUE); } - @Nullable - public static String getLocalNameForObject(JetObjectDeclaration object) { - PsiElement parent = object.getParent(); - if (parent instanceof JetClassObject) { - return JvmAbi.CLASS_OBJECT_CLASS_NAME; - } - - return null; - } - @NotNull public Type mapType(@NotNull final JetType jetType, @NotNull MapTypeMode kind) { return mapType(jetType, null, kind); @@ -407,26 +370,6 @@ public class JetTypeMapper { } } - public static Type unboxType(final Type type) { - JvmPrimitiveType jvmPrimitiveType = JvmPrimitiveType.getByWrapperAsmType(type); - if (jvmPrimitiveType != null) { - return jvmPrimitiveType.getAsmType(); - } - else { - throw new UnsupportedOperationException("Unboxing: " + type); - } - } - - public static Type boxType(Type asmType) { - JvmPrimitiveType jvmPrimitiveType = JvmPrimitiveType.getByAsmType(asmType); - if (jvmPrimitiveType != null) { - return jvmPrimitiveType.getWrapper().getAsmType(); - } - else { - return asmType; - } - } - public CallableMethod mapToCallableMethod(@NotNull FunctionDescriptor functionDescriptor, boolean superCall, OwnerKind kind) { final DeclarationDescriptor functionParent = functionDescriptor.getOriginal().getContainingDeclaration(); @@ -840,8 +783,10 @@ public class JetTypeMapper { final ConstructorDescriptor superConstructor = (ConstructorDescriptor) superDescriptor; if (isObjectLiteral(bindingContext, descriptor.getContainingDeclaration())) { + //noinspection SuspiciousMethodCalls CallableMethod superCallable = mapToCallableMethod(superConstructor, - getCalculatedClosure(superConstructor.getContainingDeclaration())); + bindingContext.get(CLOSURE, + superConstructor.getContainingDeclaration())); final List types = superCallable.getSignature().getKotlinParameterTypes(); if (types != null) { for (JvmMethodParameterSignature type : types) { diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/StackValue.java b/compiler/backend/src/org/jetbrains/jet/codegen/StackValue.java index 1fa962571c3..a760e265208 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/StackValue.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/StackValue.java @@ -57,7 +57,7 @@ public abstract class StackValue { instructionAdapter.aconst(null); } else { - Type boxed = JetTypeMapper.boxType(type); + Type boxed = CodegenUtil.boxType(type); instructionAdapter.invokestatic(boxed.getInternalName(), "valueOf", "(" + type.getDescriptor() + ")" + boxed.getDescriptor()); } } @@ -167,7 +167,7 @@ public abstract class StackValue { private static void box(final Type type, final Type toType, InstructionAdapter v) { // TODO handle toType correctly - if (type == Type.INT_TYPE || (JetTypeMapper.isIntPrimitive(type) && toType.getInternalName().equals("java/lang/Integer"))) { + if (type == Type.INT_TYPE || (CodegenUtil.isIntPrimitive(type) && toType.getInternalName().equals("java/lang/Integer"))) { v.invokestatic("java/lang/Integer", "valueOf", "(I)Ljava/lang/Integer;"); } else if (type == Type.BOOLEAN_TYPE) { @@ -590,7 +590,7 @@ public abstract class StackValue { public ArrayElement(Type type, boolean unbox) { super(type); - this.boxed = unbox ? JetTypeMapper.boxType(type) : type; + this.boxed = unbox ? CodegenUtil.boxType(type) : type; } @Override @@ -677,6 +677,7 @@ public abstract class StackValue { } } else { + //noinspection ConstantConditions ((IntrinsicMethod) setter).generate(codegen, v, null, null, null, null, state); } } @@ -1239,6 +1240,7 @@ public abstract class StackValue { return callableMethod.getReceiverClass(); } else { + //noinspection ConstantConditions return callableMethod.getThisType().getAsmType(); } } diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/context/CodegenBinding.java b/compiler/backend/src/org/jetbrains/jet/codegen/context/CodegenBinding.java index df9ca8797cf..d4c9808861f 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/context/CodegenBinding.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/context/CodegenBinding.java @@ -319,4 +319,10 @@ public class CodegenBinding { return Boolean.TRUE.equals(bindingContext.get(CAPTURED_IN_CLOSURE, variableDescriptor)) && variableDescriptor.isVar(); } + + public static boolean hasThis0(BindingContext bindingContext, ClassDescriptor classDescriptor) { + //noinspection SuspiciousMethodCalls + final CalculatedClosure closure = bindingContext.get(CLOSURE, classDescriptor); + return closure != null && closure.getCaptureThis() != null; + } } diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/context/CodegenContext.java b/compiler/backend/src/org/jetbrains/jet/codegen/context/CodegenContext.java index b91dbf1a204..18031570ac6 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/context/CodegenContext.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/context/CodegenContext.java @@ -32,6 +32,7 @@ import java.util.Map; import static org.jetbrains.jet.codegen.AsmTypeConstants.*; import static org.jetbrains.jet.codegen.context.CodegenBinding.CLASS_FOR_FUNCTION; +import static org.jetbrains.jet.codegen.context.CodegenBinding.CLOSURE; import static org.jetbrains.jet.codegen.context.CodegenBinding.FQN; /* @@ -457,7 +458,9 @@ public abstract class CodegenContext { CodegenContext parentContext, LocalLookup localLookup ) { - super(contextDescriptor, contextKind, parentContext, (MutableClosure) typeMapper.getCalculatedClosure(contextDescriptor), + //noinspection SuspiciousMethodCalls + super(contextDescriptor, contextKind, parentContext, (MutableClosure) typeMapper.getBindingContext().get(CLOSURE, + contextDescriptor), contextDescriptor, localLookup); initOuterExpression(typeMapper, contextDescriptor); @@ -477,7 +480,9 @@ public abstract class CodegenContext { CodegenContext parentContext, LocalLookup localLookup ) { - super(contextDescriptor, contextKind, parentContext, (MutableClosure) typeMapper.getCalculatedClosure(contextDescriptor), + //noinspection SuspiciousMethodCalls + super(contextDescriptor, contextKind, parentContext, (MutableClosure) typeMapper.getBindingContext().get(CLOSURE, + contextDescriptor), contextDescriptor, localLookup); initOuterExpression(typeMapper, contextDescriptor); @@ -504,8 +509,9 @@ public abstract class CodegenContext { CodegenContext parentContext, LocalLookup localLookup ) { + //noinspection SuspiciousMethodCalls super(contextDescriptor, OwnerKind.IMPLEMENTATION, parentContext, - (MutableClosure) typeMapper.getCalculatedClosure(classDescriptor), classDescriptor, localLookup); + (MutableClosure) typeMapper.getBindingContext().get(CLOSURE, classDescriptor), classDescriptor, localLookup); this.classDescriptor = classDescriptor; initOuterExpression(typeMapper, classDescriptor); diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/intrinsics/ArrayGet.java b/compiler/backend/src/org/jetbrains/jet/codegen/intrinsics/ArrayGet.java index 53211f029e7..f027d82c387 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/intrinsics/ArrayGet.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/intrinsics/ArrayGet.java @@ -40,7 +40,7 @@ public class ArrayGet implements IntrinsicMethod { @NotNull GenerationState state ) { receiver.put(AsmTypeConstants.OBJECT_TYPE, v); - Type type = JetTypeMapper.correctElementType(receiver.type); + Type type = CodegenUtil.correctElementType(receiver.type); codegen.gen(arguments.get(0), Type.INT_TYPE); diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/intrinsics/ArraySet.java b/compiler/backend/src/org/jetbrains/jet/codegen/intrinsics/ArraySet.java index 8abcb537030..5c0b398e271 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/intrinsics/ArraySet.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/intrinsics/ArraySet.java @@ -40,7 +40,7 @@ public class ArraySet implements IntrinsicMethod { @NotNull GenerationState state ) { receiver.put(AsmTypeConstants.OBJECT_TYPE, v); - Type type = JetTypeMapper.correctElementType(receiver.type); + Type type = CodegenUtil.correctElementType(receiver.type); codegen.gen(arguments.get(0), Type.INT_TYPE); codegen.gen(arguments.get(1), type); diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/intrinsics/BinaryOp.java b/compiler/backend/src/org/jetbrains/jet/codegen/intrinsics/BinaryOp.java index 1a4d5135922..c603cd9dc45 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/intrinsics/BinaryOp.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/intrinsics/BinaryOp.java @@ -20,10 +20,7 @@ import com.intellij.psi.PsiElement; import org.jetbrains.annotations.NotNull; import org.jetbrains.asm4.Type; import org.jetbrains.asm4.commons.InstructionAdapter; -import org.jetbrains.jet.codegen.ExpressionCodegen; -import org.jetbrains.jet.codegen.GenerationState; -import org.jetbrains.jet.codegen.JetTypeMapper; -import org.jetbrains.jet.codegen.StackValue; +import org.jetbrains.jet.codegen.*; import org.jetbrains.jet.lang.psi.JetExpression; import java.util.List; @@ -52,7 +49,7 @@ public class BinaryOp implements IntrinsicMethod { ) { boolean nullable = expectedType.getSort() == Type.OBJECT; if (nullable) { - expectedType = JetTypeMapper.unboxType(expectedType); + expectedType = CodegenUtil.unboxType(expectedType); } if (arguments.size() == 1) { // Intrinsic is called as an ordinary function @@ -68,7 +65,7 @@ public class BinaryOp implements IntrinsicMethod { v.visitInsn(expectedType.getOpcode(opcode)); if (nullable) { - StackValue.onStack(expectedType).put(expectedType = JetTypeMapper.boxType(expectedType), v); + StackValue.onStack(expectedType).put(expectedType = CodegenUtil.boxType(expectedType), v); } return StackValue.onStack(expectedType); } diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/intrinsics/Increment.java b/compiler/backend/src/org/jetbrains/jet/codegen/intrinsics/Increment.java index 2ac4a99c328..01738401ae6 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/intrinsics/Increment.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/intrinsics/Increment.java @@ -20,10 +20,7 @@ import com.intellij.psi.PsiElement; import org.jetbrains.annotations.NotNull; import org.jetbrains.asm4.Type; import org.jetbrains.asm4.commons.InstructionAdapter; -import org.jetbrains.jet.codegen.ExpressionCodegen; -import org.jetbrains.jet.codegen.GenerationState; -import org.jetbrains.jet.codegen.JetTypeMapper; -import org.jetbrains.jet.codegen.StackValue; +import org.jetbrains.jet.codegen.*; import org.jetbrains.jet.lang.psi.JetExpression; import org.jetbrains.jet.lang.psi.JetParenthesizedExpression; import org.jetbrains.jet.lang.psi.JetReferenceExpression; @@ -52,7 +49,7 @@ public class Increment implements IntrinsicMethod { ) { boolean nullable = expectedType.getSort() == Type.OBJECT; if (nullable) { - expectedType = JetTypeMapper.unboxType(expectedType); + expectedType = CodegenUtil.unboxType(expectedType); } if (arguments.size() > 0) { JetExpression operand = arguments.get(0); @@ -61,7 +58,7 @@ public class Increment implements IntrinsicMethod { } if (operand instanceof JetReferenceExpression) { final int index = codegen.indexOfLocal((JetReferenceExpression) operand); - if (index >= 0 && JetTypeMapper.isIntPrimitive(expectedType)) { + if (index >= 0 && CodegenUtil.isIntPrimitive(expectedType)) { return StackValue.preIncrement(index, myDelta); } } diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/intrinsics/Inv.java b/compiler/backend/src/org/jetbrains/jet/codegen/intrinsics/Inv.java index c92acc431e7..2be6d427ab7 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/intrinsics/Inv.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/intrinsics/Inv.java @@ -20,10 +20,7 @@ import com.intellij.psi.PsiElement; import org.jetbrains.annotations.NotNull; import org.jetbrains.asm4.Type; import org.jetbrains.asm4.commons.InstructionAdapter; -import org.jetbrains.jet.codegen.ExpressionCodegen; -import org.jetbrains.jet.codegen.GenerationState; -import org.jetbrains.jet.codegen.JetTypeMapper; -import org.jetbrains.jet.codegen.StackValue; +import org.jetbrains.jet.codegen.*; import org.jetbrains.jet.lang.psi.JetExpression; import java.util.List; @@ -45,7 +42,7 @@ public class Inv implements IntrinsicMethod { ) { boolean nullable = expectedType.getSort() == Type.OBJECT; if (nullable) { - expectedType = JetTypeMapper.unboxType(expectedType); + expectedType = CodegenUtil.unboxType(expectedType); } receiver.put(expectedType, v); if (expectedType == Type.LONG_TYPE) { diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/intrinsics/UnaryMinus.java b/compiler/backend/src/org/jetbrains/jet/codegen/intrinsics/UnaryMinus.java index 56038c8ec2a..adbd2af96ae 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/intrinsics/UnaryMinus.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/intrinsics/UnaryMinus.java @@ -20,10 +20,7 @@ import com.intellij.psi.PsiElement; import org.jetbrains.annotations.NotNull; import org.jetbrains.asm4.Type; import org.jetbrains.asm4.commons.InstructionAdapter; -import org.jetbrains.jet.codegen.ExpressionCodegen; -import org.jetbrains.jet.codegen.GenerationState; -import org.jetbrains.jet.codegen.JetTypeMapper; -import org.jetbrains.jet.codegen.StackValue; +import org.jetbrains.jet.codegen.*; import org.jetbrains.jet.lang.psi.JetExpression; import java.util.List; @@ -44,7 +41,7 @@ public class UnaryMinus implements IntrinsicMethod { ) { boolean nullable = expectedType.getSort() == Type.OBJECT; if (nullable) { - expectedType = JetTypeMapper.unboxType(expectedType); + expectedType = CodegenUtil.unboxType(expectedType); } if (arguments.size() == 1) { codegen.gen(arguments.get(0), expectedType); diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/intrinsics/UnaryPlus.java b/compiler/backend/src/org/jetbrains/jet/codegen/intrinsics/UnaryPlus.java index fc603142d19..4c5435d290d 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/intrinsics/UnaryPlus.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/intrinsics/UnaryPlus.java @@ -21,10 +21,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.asm4.Type; import org.jetbrains.asm4.commons.InstructionAdapter; -import org.jetbrains.jet.codegen.ExpressionCodegen; -import org.jetbrains.jet.codegen.GenerationState; -import org.jetbrains.jet.codegen.JetTypeMapper; -import org.jetbrains.jet.codegen.StackValue; +import org.jetbrains.jet.codegen.*; import org.jetbrains.jet.lang.psi.JetExpression; import java.util.List; @@ -45,7 +42,7 @@ public class UnaryPlus implements IntrinsicMethod { ) { boolean nullable = expectedType.getSort() == Type.OBJECT; if (nullable) { - expectedType = JetTypeMapper.unboxType(expectedType); + expectedType = CodegenUtil.unboxType(expectedType); } if (receiver != null && receiver != StackValue.none()) { receiver.put(expectedType, v); diff --git a/compiler/jet.as.java.psi/src/org/jetbrains/jet/asJava/JavaElementFinder.java b/compiler/jet.as.java.psi/src/org/jetbrains/jet/asJava/JavaElementFinder.java index 4aaec962799..07b3adc0e98 100644 --- a/compiler/jet.as.java.psi/src/org/jetbrains/jet/asJava/JavaElementFinder.java +++ b/compiler/jet.as.java.psi/src/org/jetbrains/jet/asJava/JavaElementFinder.java @@ -29,7 +29,7 @@ import com.intellij.psi.search.GlobalSearchScope; import com.intellij.util.SmartList; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import org.jetbrains.jet.codegen.JetTypeMapper; +import org.jetbrains.jet.codegen.CodegenUtil; import org.jetbrains.jet.codegen.NamespaceCodegen; import org.jetbrains.jet.lang.psi.*; import org.jetbrains.jet.lang.resolve.java.JavaPsiFacadeKotlinHacks; @@ -160,7 +160,7 @@ public class JavaElementFinder extends PsiElementFinder implements JavaPsiFacade if (given != null) return given; if (declaration instanceof JetObjectDeclaration) { - return JetTypeMapper.getLocalNameForObject((JetObjectDeclaration) declaration); + return CodegenUtil.getLocalNameForObject((JetObjectDeclaration) declaration); } return null;