getting rid of $$DImpl
This commit is contained in:
@@ -26,9 +26,6 @@ public class ClassCodegen {
|
|||||||
else {
|
else {
|
||||||
generateInterface(parentContext, aClass);
|
generateInterface(parentContext, aClass);
|
||||||
generateImplementation(parentContext, aClass, OwnerKind.IMPLEMENTATION);
|
generateImplementation(parentContext, aClass, OwnerKind.IMPLEMENTATION);
|
||||||
if (!ImplementationBodyCodegen.isEnum(aClass)) {
|
|
||||||
generateImplementation(parentContext, aClass, OwnerKind.DELEGATING_IMPLEMENTATION);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ClassDescriptor descriptor = state.getBindingContext().get(BindingContext.CLASS, aClass);
|
ClassDescriptor descriptor = state.getBindingContext().get(BindingContext.CLASS, aClass);
|
||||||
|
|||||||
@@ -61,14 +61,7 @@ public class ClassContext {
|
|||||||
|
|
||||||
public ClassContext intoClass(ClassDescriptor descriptor, OwnerKind kind) {
|
public ClassContext intoClass(ClassDescriptor descriptor, OwnerKind kind) {
|
||||||
final StackValue thisValue;
|
final StackValue thisValue;
|
||||||
if (kind == OwnerKind.DELEGATING_IMPLEMENTATION) {
|
thisValue = StackValue.local(0, JetTypeMapper.TYPE_OBJECT);
|
||||||
thisValue = StackValue.instanceField(JetTypeMapper.jetInterfaceType(descriptor),
|
|
||||||
JetTypeMapper.jetDelegatingImplementationType(descriptor).getInternalName(),
|
|
||||||
"$this");
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
thisValue = StackValue.local(0, JetTypeMapper.TYPE_OBJECT);
|
|
||||||
}
|
|
||||||
|
|
||||||
return new ClassContext(descriptor, kind, thisValue, this, null);
|
return new ClassContext(descriptor, kind, thisValue, this, null);
|
||||||
}
|
}
|
||||||
@@ -185,7 +178,7 @@ public class ClassContext {
|
|||||||
|
|
||||||
Integer index = typeInfoConstants.get(type);
|
Integer index = typeInfoConstants.get(type);
|
||||||
if(index == null) {
|
if(index == null) {
|
||||||
index = Integer.valueOf(typeInfoConstants.size());
|
index = typeInfoConstants.size();
|
||||||
typeInfoConstants.put(type, index);
|
typeInfoConstants.put(type, index);
|
||||||
}
|
}
|
||||||
return index;
|
return index;
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
public class ConstructorFrameMap extends FrameMap {
|
public class ConstructorFrameMap extends FrameMap {
|
||||||
private int myOuterThisIndex = -1;
|
private int myOuterThisIndex = -1;
|
||||||
private int myDelegateThisIndex = -1;
|
|
||||||
private int myFirstTypeParameter = -1;
|
private int myFirstTypeParameter = -1;
|
||||||
private int myTypeParameterCount = 0;
|
private int myTypeParameterCount = 0;
|
||||||
|
|
||||||
@@ -27,9 +26,6 @@ public class ConstructorFrameMap extends FrameMap {
|
|||||||
myOuterThisIndex = enterTemp(); // outer class instance
|
myOuterThisIndex = enterTemp(); // outer class instance
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (kind == OwnerKind.DELEGATING_IMPLEMENTATION) {
|
|
||||||
myDelegateThisIndex = enterTemp(); // $this
|
|
||||||
}
|
|
||||||
|
|
||||||
List<Type> explicitArgTypes = callableMethod.getValueParameterTypes();
|
List<Type> explicitArgTypes = callableMethod.getValueParameterTypes();
|
||||||
|
|
||||||
@@ -59,10 +55,6 @@ public class ConstructorFrameMap extends FrameMap {
|
|||||||
return myOuterThisIndex;
|
return myOuterThisIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getDelegateThisIndex() {
|
|
||||||
return myDelegateThisIndex;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getFirstTypeParameter() {
|
public int getFirstTypeParameter() {
|
||||||
return myFirstTypeParameter;
|
return myFirstTypeParameter;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ public class FunctionCodegen {
|
|||||||
boolean isAbstract = kind == OwnerKind.INTERFACE || bodyExpressions == null;
|
boolean isAbstract = kind == OwnerKind.INTERFACE || bodyExpressions == null;
|
||||||
if (isAbstract) flags |= Opcodes.ACC_ABSTRACT;
|
if (isAbstract) flags |= Opcodes.ACC_ABSTRACT;
|
||||||
|
|
||||||
if (isAbstract && (kind == OwnerKind.IMPLEMENTATION || kind == OwnerKind.DELEGATING_IMPLEMENTATION)) {
|
if (isAbstract && (kind == OwnerKind.IMPLEMENTATION )) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -206,14 +206,6 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
|||||||
iv.putfield(classname, fieldName, interfaceDesc);
|
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>();
|
HashSet<FunctionDescriptor> overridden = new HashSet<FunctionDescriptor>();
|
||||||
for (JetDeclaration declaration : myClass.getDeclarations()) {
|
for (JetDeclaration declaration : myClass.getDeclarations()) {
|
||||||
if (declaration instanceof JetFunction) {
|
if (declaration instanceof JetFunction) {
|
||||||
@@ -299,22 +291,13 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
|||||||
ConstructorDescriptor constructorDescriptor, boolean isJavaSuperclass,
|
ConstructorDescriptor constructorDescriptor, boolean isJavaSuperclass,
|
||||||
ConstructorFrameMap frameMap) {
|
ConstructorFrameMap frameMap) {
|
||||||
ClassDescriptor classDecl = constructorDescriptor.getContainingDeclaration();
|
ClassDescriptor classDecl = constructorDescriptor.getContainingDeclaration();
|
||||||
boolean isDelegating = kind == OwnerKind.DELEGATING_IMPLEMENTATION;
|
|
||||||
PsiElement declaration = state.getBindingContext().get(BindingContext.DESCRIPTOR_TO_DECLARATION, classDecl);
|
PsiElement declaration = state.getBindingContext().get(BindingContext.DESCRIPTOR_TO_DECLARATION, classDecl);
|
||||||
Type type;
|
Type type;
|
||||||
if (declaration instanceof PsiClass) {
|
if (declaration instanceof PsiClass) {
|
||||||
type = JetTypeMapper.psiClassType((PsiClass) declaration);
|
type = JetTypeMapper.psiClassType((PsiClass) declaration);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
type = isDelegating
|
type = JetTypeMapper.jetImplementationType(classDecl);
|
||||||
? JetTypeMapper.jetDelegatingImplementationType(classDecl)
|
|
||||||
: JetTypeMapper.jetImplementationType(classDecl);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!isJavaSuperclass) {
|
|
||||||
if (kind == OwnerKind.DELEGATING_IMPLEMENTATION) {
|
|
||||||
codegen.thisToStack();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isJavaSuperclass) {
|
if (isJavaSuperclass) {
|
||||||
@@ -325,9 +308,6 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
|||||||
iv.dup();
|
iv.dup();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (kind == OwnerKind.DELEGATING_IMPLEMENTATION) {
|
|
||||||
iv.load(frameMap.getDelegateThisIndex(), state.getTypeMapper().jvmType(classDecl, OwnerKind.INTERFACE));
|
|
||||||
}
|
|
||||||
if (classDecl.getContainingDeclaration() instanceof ClassDescriptor) {
|
if (classDecl.getContainingDeclaration() instanceof ClassDescriptor) {
|
||||||
iv.load(frameMap.getOuterThisIndex(), state.getTypeMapper().jvmType((ClassDescriptor) descriptor.getContainingDeclaration(), OwnerKind.IMPLEMENTATION));
|
iv.load(frameMap.getOuterThisIndex(), state.getTypeMapper().jvmType((ClassDescriptor) descriptor.getContainingDeclaration(), OwnerKind.IMPLEMENTATION));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,13 +20,13 @@ import java.util.*;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @author yole
|
* @author yole
|
||||||
|
* @author alex.tkachman
|
||||||
*/
|
*/
|
||||||
public class JetTypeMapper {
|
public class JetTypeMapper {
|
||||||
public static final Type TYPE_OBJECT = Type.getObjectType("java/lang/Object");
|
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_TYPEINFO = Type.getType(TypeInfo.class);
|
||||||
public static final Type TYPE_TYPEINFOPROJECTION = Type.getType(TypeInfoProjection.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_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 TYPE_NOTHING = Type.getObjectType("jet/Nothing");
|
||||||
public static final Type JL_INTEGER_TYPE = Type.getObjectType("java/lang/Integer");
|
public static final Type JL_INTEGER_TYPE = Type.getObjectType("java/lang/Integer");
|
||||||
public static final Type JL_LONG_TYPE = Type.getObjectType("java/lang/Long");
|
public static final Type JL_LONG_TYPE = Type.getObjectType("java/lang/Long");
|
||||||
@@ -213,9 +213,6 @@ public class JetTypeMapper {
|
|||||||
else if (kind == OwnerKind.IMPLEMENTATION) {
|
else if (kind == OwnerKind.IMPLEMENTATION) {
|
||||||
return jvmNameForImplementation(jetClass);
|
return jvmNameForImplementation(jetClass);
|
||||||
}
|
}
|
||||||
else if (kind == OwnerKind.DELEGATING_IMPLEMENTATION) {
|
|
||||||
return jvmNameForDelegatingImplementation(jetClass);
|
|
||||||
}
|
|
||||||
else {
|
else {
|
||||||
assert false : "Unsuitable kind";
|
assert false : "Unsuitable kind";
|
||||||
return "java/lang/Object";
|
return "java/lang/Object";
|
||||||
@@ -543,7 +540,6 @@ public class JetTypeMapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Method mapConstructorSignature(ConstructorDescriptor descriptor, OwnerKind kind, List<Type> valueParameterTypes) {
|
private Method mapConstructorSignature(ConstructorDescriptor descriptor, OwnerKind kind, List<Type> valueParameterTypes) {
|
||||||
boolean delegate = kind == OwnerKind.DELEGATING_IMPLEMENTATION;
|
|
||||||
List<ValueParameterDescriptor> parameters = descriptor.getOriginal().getValueParameters();
|
List<ValueParameterDescriptor> parameters = descriptor.getOriginal().getValueParameters();
|
||||||
List<Type> parameterTypes = new ArrayList<Type>();
|
List<Type> parameterTypes = new ArrayList<Type>();
|
||||||
ClassDescriptor classDescriptor = descriptor.getContainingDeclaration();
|
ClassDescriptor classDescriptor = descriptor.getContainingDeclaration();
|
||||||
@@ -551,9 +547,6 @@ public class JetTypeMapper {
|
|||||||
if (outerDescriptor instanceof ClassDescriptor) {
|
if (outerDescriptor instanceof ClassDescriptor) {
|
||||||
parameterTypes.add(jvmType((ClassDescriptor) outerDescriptor, OwnerKind.IMPLEMENTATION));
|
parameterTypes.add(jvmType((ClassDescriptor) outerDescriptor, OwnerKind.IMPLEMENTATION));
|
||||||
}
|
}
|
||||||
if (delegate) {
|
|
||||||
parameterTypes.add(jetInterfaceType(classDescriptor));
|
|
||||||
}
|
|
||||||
for (ValueParameterDescriptor parameter : parameters) {
|
for (ValueParameterDescriptor parameter : parameters) {
|
||||||
final Type type = mapType(parameter.getOutType());
|
final Type type = mapType(parameter.getOutType());
|
||||||
parameterTypes.add(type);
|
parameterTypes.add(type);
|
||||||
@@ -624,7 +617,6 @@ public class JetTypeMapper {
|
|||||||
if (classDescriptor != null) {
|
if (classDescriptor != null) {
|
||||||
result.add(jvmName(classDescriptor, OwnerKind.INTERFACE));
|
result.add(jvmName(classDescriptor, OwnerKind.INTERFACE));
|
||||||
result.add(jvmName(classDescriptor, OwnerKind.IMPLEMENTATION));
|
result.add(jvmName(classDescriptor, OwnerKind.IMPLEMENTATION));
|
||||||
result.add(jvmName(classDescriptor, OwnerKind.DELEGATING_IMPLEMENTATION));
|
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ public class OwnerKind {
|
|||||||
public static final OwnerKind NAMESPACE = new OwnerKind("namespace");
|
public static final OwnerKind NAMESPACE = new OwnerKind("namespace");
|
||||||
public static final OwnerKind INTERFACE = new OwnerKind("interface");
|
public static final OwnerKind INTERFACE = new OwnerKind("interface");
|
||||||
public static final OwnerKind IMPLEMENTATION = new OwnerKind("implementation");
|
public static final OwnerKind IMPLEMENTATION = new OwnerKind("implementation");
|
||||||
public static final OwnerKind DELEGATING_IMPLEMENTATION = new OwnerKind("delegating implementation");
|
|
||||||
|
|
||||||
public static class DelegateKind extends OwnerKind {
|
public static class DelegateKind extends OwnerKind {
|
||||||
private final StackValue delegate;
|
private final StackValue delegate;
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ public class PropertyCodegen {
|
|||||||
throw new UnsupportedOperationException("expect a property to have a property descriptor");
|
throw new UnsupportedOperationException("expect a property to have a property descriptor");
|
||||||
}
|
}
|
||||||
final PropertyDescriptor propertyDescriptor = (PropertyDescriptor) 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);
|
generateBackingField(p, propertyDescriptor);
|
||||||
generateGetter(p, propertyDescriptor);
|
generateGetter(p, propertyDescriptor);
|
||||||
generateSetter(p, propertyDescriptor);
|
generateSetter(p, propertyDescriptor);
|
||||||
|
|||||||
@@ -504,9 +504,9 @@ public class CallResolver {
|
|||||||
return OverloadResolutionResult.singleFailedCandidate(failedCandidates.iterator().next());
|
return OverloadResolutionResult.singleFailedCandidate(failedCandidates.iterator().next());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
StringBuilder stringBuilder = new StringBuilder();
|
StringBuilder stringBuilder = new StringBuilder("\n");
|
||||||
for (Descriptor functionDescriptor : failedCandidates) {
|
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);
|
tracing.reportOverallResolutionError(trace, "None of the following functions can be called with the arguments supplied: " + stringBuilder);
|
||||||
|
|||||||
Reference in New Issue
Block a user