From db71959c0dbd027857e08309ed04d6a2b407a1db Mon Sep 17 00:00:00 2001 From: Alex Tkachman Date: Wed, 7 Sep 2011 18:38:42 +0200 Subject: [PATCH] getting rid of $$DImpl --- .../jetbrains/jet/codegen/ClassCodegen.java | 3 --- .../jetbrains/jet/codegen/ClassContext.java | 11 ++-------- .../jet/codegen/ConstructorFrameMap.java | 8 ------- .../jet/codegen/FunctionCodegen.java | 2 +- .../codegen/ImplementationBodyCodegen.java | 22 +------------------ .../jetbrains/jet/codegen/JetTypeMapper.java | 10 +-------- .../org/jetbrains/jet/codegen/OwnerKind.java | 1 - .../jet/codegen/PropertyCodegen.java | 2 +- .../jet/lang/resolve/calls/CallResolver.java | 4 ++-- 9 files changed, 8 insertions(+), 55 deletions(-) diff --git a/idea/src/org/jetbrains/jet/codegen/ClassCodegen.java b/idea/src/org/jetbrains/jet/codegen/ClassCodegen.java index dc8f9961c02..382e72d39a7 100644 --- a/idea/src/org/jetbrains/jet/codegen/ClassCodegen.java +++ b/idea/src/org/jetbrains/jet/codegen/ClassCodegen.java @@ -26,9 +26,6 @@ public class ClassCodegen { else { generateInterface(parentContext, aClass); generateImplementation(parentContext, aClass, OwnerKind.IMPLEMENTATION); - if (!ImplementationBodyCodegen.isEnum(aClass)) { - generateImplementation(parentContext, aClass, OwnerKind.DELEGATING_IMPLEMENTATION); - } } ClassDescriptor descriptor = state.getBindingContext().get(BindingContext.CLASS, aClass); diff --git a/idea/src/org/jetbrains/jet/codegen/ClassContext.java b/idea/src/org/jetbrains/jet/codegen/ClassContext.java index da21e7e8501..0739c39808f 100644 --- a/idea/src/org/jetbrains/jet/codegen/ClassContext.java +++ b/idea/src/org/jetbrains/jet/codegen/ClassContext.java @@ -61,14 +61,7 @@ public class ClassContext { public ClassContext intoClass(ClassDescriptor descriptor, OwnerKind kind) { final StackValue thisValue; - if (kind == OwnerKind.DELEGATING_IMPLEMENTATION) { - thisValue = StackValue.instanceField(JetTypeMapper.jetInterfaceType(descriptor), - JetTypeMapper.jetDelegatingImplementationType(descriptor).getInternalName(), - "$this"); - } - else { - thisValue = StackValue.local(0, JetTypeMapper.TYPE_OBJECT); - } + thisValue = StackValue.local(0, JetTypeMapper.TYPE_OBJECT); return new ClassContext(descriptor, kind, thisValue, this, null); } @@ -185,7 +178,7 @@ public class ClassContext { Integer index = typeInfoConstants.get(type); if(index == null) { - index = Integer.valueOf(typeInfoConstants.size()); + index = typeInfoConstants.size(); typeInfoConstants.put(type, index); } return index; diff --git a/idea/src/org/jetbrains/jet/codegen/ConstructorFrameMap.java b/idea/src/org/jetbrains/jet/codegen/ConstructorFrameMap.java index 4ae7b71fd88..f1961e5ac18 100644 --- a/idea/src/org/jetbrains/jet/codegen/ConstructorFrameMap.java +++ b/idea/src/org/jetbrains/jet/codegen/ConstructorFrameMap.java @@ -14,7 +14,6 @@ import java.util.List; */ public class ConstructorFrameMap extends FrameMap { private int myOuterThisIndex = -1; - private int myDelegateThisIndex = -1; private int myFirstTypeParameter = -1; private int myTypeParameterCount = 0; @@ -27,9 +26,6 @@ public class ConstructorFrameMap extends FrameMap { myOuterThisIndex = enterTemp(); // outer class instance } } - if (kind == OwnerKind.DELEGATING_IMPLEMENTATION) { - myDelegateThisIndex = enterTemp(); // $this - } List explicitArgTypes = callableMethod.getValueParameterTypes(); @@ -59,10 +55,6 @@ public class ConstructorFrameMap extends FrameMap { return myOuterThisIndex; } - public int getDelegateThisIndex() { - return myDelegateThisIndex; - } - public int getFirstTypeParameter() { return myFirstTypeParameter; } diff --git a/idea/src/org/jetbrains/jet/codegen/FunctionCodegen.java b/idea/src/org/jetbrains/jet/codegen/FunctionCodegen.java index 534d3745eab..15b1f823c5b 100644 --- a/idea/src/org/jetbrains/jet/codegen/FunctionCodegen.java +++ b/idea/src/org/jetbrains/jet/codegen/FunctionCodegen.java @@ -91,7 +91,7 @@ public class FunctionCodegen { boolean isAbstract = kind == OwnerKind.INTERFACE || bodyExpressions == null; if (isAbstract) flags |= Opcodes.ACC_ABSTRACT; - if (isAbstract && (kind == OwnerKind.IMPLEMENTATION || kind == OwnerKind.DELEGATING_IMPLEMENTATION)) { + if (isAbstract && (kind == OwnerKind.IMPLEMENTATION )) { return; } diff --git a/idea/src/org/jetbrains/jet/codegen/ImplementationBodyCodegen.java b/idea/src/org/jetbrains/jet/codegen/ImplementationBodyCodegen.java index ec4c31d888b..8ed05984cf2 100644 --- a/idea/src/org/jetbrains/jet/codegen/ImplementationBodyCodegen.java +++ b/idea/src/org/jetbrains/jet/codegen/ImplementationBodyCodegen.java @@ -206,14 +206,6 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen { iv.putfield(classname, fieldName, interfaceDesc); } - if (kind == OwnerKind.DELEGATING_IMPLEMENTATION) { - String interfaceDesc = JetTypeMapper.jetInterfaceType(descriptor).getDescriptor(); - v.visitField(Opcodes.ACC_PRIVATE | Opcodes.ACC_FINAL, "$this", interfaceDesc, /*TODO*/null, null); - iv.load(0, classType); - iv.load(frameMap.getDelegateThisIndex(), argTypes[0]); - iv.putfield(classname, "$this", interfaceDesc); - } - HashSet overridden = new HashSet(); for (JetDeclaration declaration : myClass.getDeclarations()) { if (declaration instanceof JetFunction) { @@ -299,22 +291,13 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen { ConstructorDescriptor constructorDescriptor, boolean isJavaSuperclass, ConstructorFrameMap frameMap) { ClassDescriptor classDecl = constructorDescriptor.getContainingDeclaration(); - boolean isDelegating = kind == OwnerKind.DELEGATING_IMPLEMENTATION; PsiElement declaration = state.getBindingContext().get(BindingContext.DESCRIPTOR_TO_DECLARATION, classDecl); Type type; if (declaration instanceof PsiClass) { type = JetTypeMapper.psiClassType((PsiClass) declaration); } else { - type = isDelegating - ? JetTypeMapper.jetDelegatingImplementationType(classDecl) - : JetTypeMapper.jetImplementationType(classDecl); - } - - if (!isJavaSuperclass) { - if (kind == OwnerKind.DELEGATING_IMPLEMENTATION) { - codegen.thisToStack(); - } + type = JetTypeMapper.jetImplementationType(classDecl); } if (isJavaSuperclass) { @@ -325,9 +308,6 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen { iv.dup(); } - if (kind == OwnerKind.DELEGATING_IMPLEMENTATION) { - iv.load(frameMap.getDelegateThisIndex(), state.getTypeMapper().jvmType(classDecl, OwnerKind.INTERFACE)); - } if (classDecl.getContainingDeclaration() instanceof ClassDescriptor) { iv.load(frameMap.getOuterThisIndex(), state.getTypeMapper().jvmType((ClassDescriptor) descriptor.getContainingDeclaration(), OwnerKind.IMPLEMENTATION)); } diff --git a/idea/src/org/jetbrains/jet/codegen/JetTypeMapper.java b/idea/src/org/jetbrains/jet/codegen/JetTypeMapper.java index 8666e7cd8ba..e2ddd632193 100644 --- a/idea/src/org/jetbrains/jet/codegen/JetTypeMapper.java +++ b/idea/src/org/jetbrains/jet/codegen/JetTypeMapper.java @@ -20,13 +20,13 @@ import java.util.*; /** * @author yole + * @author alex.tkachman */ public class JetTypeMapper { public static final Type TYPE_OBJECT = Type.getObjectType("java/lang/Object"); public static final Type TYPE_TYPEINFO = Type.getType(TypeInfo.class); public static final Type TYPE_TYPEINFOPROJECTION = Type.getType(TypeInfoProjection.class); public static final Type TYPE_JET_OBJECT = Type.getType(JetObject.class); - public static final Type TYPE_CLASS = Type.getType(Class.class); public static final Type TYPE_NOTHING = Type.getObjectType("jet/Nothing"); public static final Type JL_INTEGER_TYPE = Type.getObjectType("java/lang/Integer"); public static final Type JL_LONG_TYPE = Type.getObjectType("java/lang/Long"); @@ -213,9 +213,6 @@ public class JetTypeMapper { else if (kind == OwnerKind.IMPLEMENTATION) { return jvmNameForImplementation(jetClass); } - else if (kind == OwnerKind.DELEGATING_IMPLEMENTATION) { - return jvmNameForDelegatingImplementation(jetClass); - } else { assert false : "Unsuitable kind"; return "java/lang/Object"; @@ -543,7 +540,6 @@ public class JetTypeMapper { } private Method mapConstructorSignature(ConstructorDescriptor descriptor, OwnerKind kind, List valueParameterTypes) { - boolean delegate = kind == OwnerKind.DELEGATING_IMPLEMENTATION; List parameters = descriptor.getOriginal().getValueParameters(); List parameterTypes = new ArrayList(); ClassDescriptor classDescriptor = descriptor.getContainingDeclaration(); @@ -551,9 +547,6 @@ public class JetTypeMapper { if (outerDescriptor instanceof ClassDescriptor) { parameterTypes.add(jvmType((ClassDescriptor) outerDescriptor, OwnerKind.IMPLEMENTATION)); } - if (delegate) { - parameterTypes.add(jetInterfaceType(classDescriptor)); - } for (ValueParameterDescriptor parameter : parameters) { final Type type = mapType(parameter.getOutType()); parameterTypes.add(type); @@ -624,7 +617,6 @@ public class JetTypeMapper { if (classDescriptor != null) { result.add(jvmName(classDescriptor, OwnerKind.INTERFACE)); result.add(jvmName(classDescriptor, OwnerKind.IMPLEMENTATION)); - result.add(jvmName(classDescriptor, OwnerKind.DELEGATING_IMPLEMENTATION)); } return result; } diff --git a/idea/src/org/jetbrains/jet/codegen/OwnerKind.java b/idea/src/org/jetbrains/jet/codegen/OwnerKind.java index 55c71dde735..efb642c0096 100644 --- a/idea/src/org/jetbrains/jet/codegen/OwnerKind.java +++ b/idea/src/org/jetbrains/jet/codegen/OwnerKind.java @@ -13,7 +13,6 @@ public class OwnerKind { public static final OwnerKind NAMESPACE = new OwnerKind("namespace"); public static final OwnerKind INTERFACE = new OwnerKind("interface"); public static final OwnerKind IMPLEMENTATION = new OwnerKind("implementation"); - public static final OwnerKind DELEGATING_IMPLEMENTATION = new OwnerKind("delegating implementation"); public static class DelegateKind extends OwnerKind { private final StackValue delegate; diff --git a/idea/src/org/jetbrains/jet/codegen/PropertyCodegen.java b/idea/src/org/jetbrains/jet/codegen/PropertyCodegen.java index b808817e7c3..da1201c4453 100644 --- a/idea/src/org/jetbrains/jet/codegen/PropertyCodegen.java +++ b/idea/src/org/jetbrains/jet/codegen/PropertyCodegen.java @@ -36,7 +36,7 @@ public class PropertyCodegen { throw new UnsupportedOperationException("expect a property to have a property descriptor"); } final PropertyDescriptor propertyDescriptor = (PropertyDescriptor) descriptor; - if (kind == OwnerKind.NAMESPACE || kind == OwnerKind.IMPLEMENTATION || kind == OwnerKind.DELEGATING_IMPLEMENTATION) { + if (kind == OwnerKind.NAMESPACE || kind == OwnerKind.IMPLEMENTATION) { generateBackingField(p, propertyDescriptor); generateGetter(p, propertyDescriptor); generateSetter(p, propertyDescriptor); diff --git a/idea/src/org/jetbrains/jet/lang/resolve/calls/CallResolver.java b/idea/src/org/jetbrains/jet/lang/resolve/calls/CallResolver.java index 0f681833fe6..32a4b8bb5ba 100644 --- a/idea/src/org/jetbrains/jet/lang/resolve/calls/CallResolver.java +++ b/idea/src/org/jetbrains/jet/lang/resolve/calls/CallResolver.java @@ -504,9 +504,9 @@ public class CallResolver { return OverloadResolutionResult.singleFailedCandidate(failedCandidates.iterator().next()); } else { - StringBuilder stringBuilder = new StringBuilder(); + StringBuilder stringBuilder = new StringBuilder("\n"); for (Descriptor functionDescriptor : failedCandidates) { - stringBuilder.append(DescriptorRenderer.TEXT.render(functionDescriptor)).append(" "); + stringBuilder.append(DescriptorRenderer.TEXT.render(functionDescriptor)).append("\n"); } tracing.reportOverallResolutionError(trace, "None of the following functions can be called with the arguments supplied: " + stringBuilder);