Implicit receivers checked properly. Receiver checks restructured.

This commit is contained in:
Andrey Breslav
2011-10-11 18:25:01 +04:00
parent a39379edbf
commit c53754b3e8
23 changed files with 253 additions and 189 deletions
@@ -73,7 +73,7 @@ public class ClassContext {
thisIdx++;
}
final boolean hasReceiver = descriptor.getReceiver().exists();
final boolean hasReceiver = descriptor.getReceiverParameter().exists();
if (hasReceiver) {
thisIdx++;
}
@@ -104,7 +104,7 @@ public class ClassContext {
}
private ReceiverDescriptor receiver() {
return contextType instanceof FunctionDescriptor ? ((FunctionDescriptor) contextType).getReceiver() : ReceiverDescriptor.NO_RECEIVER;
return contextType instanceof FunctionDescriptor ? ((FunctionDescriptor) contextType).getReceiverParameter() : ReceiverDescriptor.NO_RECEIVER;
}
private boolean hasReceiver() {
@@ -42,7 +42,7 @@ public class ClosureCodegen {
}
public static Method erasedInvokeSignature(FunctionDescriptor fd) {
boolean isExtensionFunction = fd.getReceiver().exists();
boolean isExtensionFunction = fd.getReceiverParameter().exists();
int paramCount = fd.getValueParameters().size();
if (isExtensionFunction) {
paramCount++;
@@ -151,7 +151,7 @@ public class ClosureCodegen {
iv.load(0, Type.getObjectType(className));
final ReceiverDescriptor receiver = funDescriptor.getReceiver();
final ReceiverDescriptor receiver = funDescriptor.getReceiverParameter();
int count = 1;
if (receiver.exists()) {
StackValue.local(count, JetTypeMapper.TYPE_OBJECT).put(JetTypeMapper.TYPE_OBJECT, iv);
@@ -229,7 +229,7 @@ public class ClosureCodegen {
public static String getInternalClassName(FunctionDescriptor descriptor) {
final int paramCount = descriptor.getValueParameters().size();
if (descriptor.getReceiver().exists()) {
if (descriptor.getReceiverParameter().exists()) {
return "jet/ExtensionFunction" + paramCount;
}
else {
@@ -250,7 +250,7 @@ public class ClosureCodegen {
Method descriptor = erasedInvokeSignature(fd);
String owner = getInternalClassName(fd);
final CallableMethod result = new CallableMethod(owner, descriptor, Opcodes.INVOKEVIRTUAL, Arrays.asList(descriptor.getArgumentTypes()));
if (fd.getReceiver().exists()) {
if (fd.getReceiverParameter().exists()) {
result.setNeedsReceiver(null);
}
result.requestGenerateCallee(Type.getObjectType(getInternalClassName(fd)));
@@ -2,7 +2,6 @@ package org.jetbrains.jet.codegen;
import com.intellij.psi.*;
import com.intellij.psi.util.PsiTreeUtil;
import jet.Function1;
import jet.JetObject;
import jet.typeinfo.TypeInfo;
import jet.typeinfo.TypeInfoProjection;
@@ -546,7 +545,7 @@ public class JetTypeMapper {
}
public Method mapSignature(String name, FunctionDescriptor f) {
final ReceiverDescriptor receiver = f.getReceiver();
final ReceiverDescriptor receiver = f.getReceiverParameter();
final List<ValueParameterDescriptor> parameters = f.getValueParameters();
List<Type> parameterTypes = new ArrayList<Type>();
if (receiver.exists()) {