one more step towards CallableMethod unification

This commit is contained in:
Dmitry Jemerov
2011-07-14 17:52:05 +02:00
parent a075ce780b
commit 0e7b8b8f35
3 changed files with 14 additions and 1 deletions
@@ -20,6 +20,7 @@ public class CallableMethod {
private boolean needsReceiverOnStack = false;
private boolean ownerFromCall = false;
private ClassDescriptor receiverClass = null;
private Type generateCalleeType = null;
public CallableMethod(String owner, Method signature, int invokeOpcode, List<Type> valueParameterTypes) {
this.owner = owner;
@@ -80,4 +81,12 @@ public class CallableMethod {
void invoke(InstructionAdapter v) {
v.visitMethodInsn(getInvokeOpcode(), getOwner(), getSignature().getName(), getSignature().getDescriptor());
}
public void requestGenerateCallee(Type objectType) {
generateCalleeType = objectType;
}
public Type getGenerateCalleeType() {
return generateCalleeType;
}
}
@@ -251,6 +251,7 @@ public class ClosureCodegen {
if (fd.getReceiverType() != null) {
result.setNeedsReceiver(null);
}
result.requestGenerateCallee(Type.getObjectType(getInternalClassName(fd)));
return result;
}
}
@@ -806,7 +806,6 @@ public class ExpressionCodegen extends JetVisitor {
callableMethod = typeMapper.mapToCallableMethod((PsiNamedElement) declarationPsiElement);
}
else {
gen(callee, Type.getObjectType(ClosureCodegen.getInternalClassName(fd)));
callableMethod = ClosureCodegen.asCallableMethod(fd);
}
@@ -861,6 +860,10 @@ public class ExpressionCodegen extends JetVisitor {
}
private void invokeMethodWithArguments(CallableMethod callableMethod, JetCall expression, final boolean haveReceiver) {
final Type calleeType = callableMethod.getGenerateCalleeType();
if (calleeType != null && expression instanceof JetCallExpression) {
gen(((JetCallExpression) expression).getCalleeExpression(), calleeType);
}
if (callableMethod.isOwnerFromCall()) {
setOwnerFromCall(callableMethod, expression);
}