some static methods moved from JetTypeMapper to CodegenUtil & CodegenBinding
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<StackValue, StackValue> 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<StackValue, StackValue> 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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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<Type> parameterTypes = new ArrayList<Type>();
|
||||
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;
|
||||
|
||||
@@ -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<JvmMethodParameterSignature> types = superCallable.getSignature().getKotlinParameterTypes();
|
||||
if (types != null) {
|
||||
for (JvmMethodParameterSignature type : types) {
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user