getting rid of $$DImpl
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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<Type> explicitArgTypes = callableMethod.getValueParameterTypes();
|
||||
|
||||
@@ -59,10 +55,6 @@ public class ConstructorFrameMap extends FrameMap {
|
||||
return myOuterThisIndex;
|
||||
}
|
||||
|
||||
public int getDelegateThisIndex() {
|
||||
return myDelegateThisIndex;
|
||||
}
|
||||
|
||||
public int getFirstTypeParameter() {
|
||||
return myFirstTypeParameter;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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<FunctionDescriptor> overridden = new HashSet<FunctionDescriptor>();
|
||||
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));
|
||||
}
|
||||
|
||||
@@ -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<Type> valueParameterTypes) {
|
||||
boolean delegate = kind == OwnerKind.DELEGATING_IMPLEMENTATION;
|
||||
List<ValueParameterDescriptor> parameters = descriptor.getOriginal().getValueParameters();
|
||||
List<Type> parameterTypes = new ArrayList<Type>();
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user