Minor refactoring in ExpressionCodegen

Inline useless method, factor out resolveToCallableMethod logic from
resolveToCallable
This commit is contained in:
Alexander Udalov
2013-04-15 19:04:11 +04:00
parent f509407852
commit 141b996709
@@ -1962,29 +1962,28 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
return StackValue.none(); return StackValue.none();
} }
@NotNull
Callable resolveToCallable(@NotNull FunctionDescriptor fd, boolean superCall) { Callable resolveToCallable(@NotNull FunctionDescriptor fd, boolean superCall) {
IntrinsicMethod intrinsic = state.getIntrinsics().getIntrinsic(fd); IntrinsicMethod intrinsic = state.getIntrinsics().getIntrinsic(fd);
if (intrinsic != null) { if (intrinsic != null) {
return intrinsic; return intrinsic;
} }
CallableMethod callableMethod; return resolveToCallableMethod(fd, superCall, context);
//if (fd instanceof VariableAsFunctionDescriptor) { }
// assert !superCall;
// callableMethod = ClosureCodegen.asCallableMethod((FunctionDescriptor) fd); @NotNull
//} private CallableMethod resolveToCallableMethod(@NotNull FunctionDescriptor fd, boolean superCall, @NotNull CodegenContext context) {
if (isCallAsFunctionObject(fd)) { if (isCallAsFunctionObject(fd)) {
SimpleFunctionDescriptor invoke = createInvoke(fd); return typeMapper.asCallableMethod(createInvoke(fd));
callableMethod = typeMapper.asCallableMethod(invoke);
} }
else { else {
SimpleFunctionDescriptor originalOfSamAdapter = getOriginalIfSamAdapter(fd); SimpleFunctionDescriptor originalOfSamAdapter = getOriginalIfSamAdapter(fd);
callableMethod = typeMapper.mapToCallableMethod(originalOfSamAdapter != null ? originalOfSamAdapter : fd, superCall, return typeMapper.mapToCallableMethod(originalOfSamAdapter != null ? originalOfSamAdapter : fd, superCall,
isCallInsideSameClassAsDeclared(fd, context), isCallInsideSameClassAsDeclared(fd, context),
isCallInsideSameModuleAsDeclared(fd, context), isCallInsideSameModuleAsDeclared(fd, context),
OwnerKind.IMPLEMENTATION); OwnerKind.IMPLEMENTATION);
} }
return callableMethod;
} }
private boolean isCallAsFunctionObject(FunctionDescriptor fd) { private boolean isCallAsFunctionObject(FunctionDescriptor fd) {
@@ -2008,10 +2007,6 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
public void invokeMethodWithArguments(CallableMethod callableMethod, JetCallElement expression, StackValue receiver) { public void invokeMethodWithArguments(CallableMethod callableMethod, JetCallElement expression, StackValue receiver) {
JetExpression calleeExpression = expression.getCalleeExpression(); JetExpression calleeExpression = expression.getCalleeExpression();
invokeMethodWithArguments(callableMethod, receiver, calleeExpression);
}
private void invokeMethodWithArguments(CallableMethod callableMethod, StackValue receiver, JetExpression calleeExpression) {
Call call = bindingContext.get(CALL, calleeExpression); Call call = bindingContext.get(CALL, calleeExpression);
ResolvedCall<? extends CallableDescriptor> resolvedCall = bindingContext.get(BindingContext.RESOLVED_CALL, calleeExpression); ResolvedCall<? extends CallableDescriptor> resolvedCall = bindingContext.get(BindingContext.RESOLVED_CALL, calleeExpression);