Search in sources :

Example 1 with ResolvedCallWithRealDescriptor

use of org.jetbrains.kotlin.codegen.coroutines.ResolvedCallWithRealDescriptor in project kotlin by JetBrains.

the class ExpressionCodegen method invokeFunction.

@NotNull
public StackValue invokeFunction(@NotNull Call call, @NotNull ResolvedCall<?> resolvedCall, @NotNull StackValue receiver) {
    ResolvedCallWithRealDescriptor callWithRealDescriptor = CoroutineCodegenUtilKt.replaceSuspensionFunctionWithRealDescriptor(resolvedCall, state.getProject(), state.getBindingContext());
    if (callWithRealDescriptor != null) {
        StackValue coroutineInstanceValueForSuspensionPoint = getCoroutineInstanceValueForSuspensionPoint(resolvedCall);
        StackValue coroutineInstanceValue = coroutineInstanceValueForSuspensionPoint != null ? coroutineInstanceValueForSuspensionPoint : getContinuationParameterFromEnclosingSuspendFunction(resolvedCall);
        tempVariables.put(callWithRealDescriptor.getFakeContinuationExpression(), coroutineInstanceValue);
        return invokeFunction(callWithRealDescriptor.getResolvedCall(), receiver);
    }
    FunctionDescriptor fd = accessibleFunctionDescriptor(resolvedCall);
    ClassDescriptor superCallTarget = getSuperCallTarget(call);
    fd = context.getAccessorForSuperCallIfNeeded(fd, superCallTarget, state);
    Collection<ExpressionCodegenExtension> codegenExtensions = ExpressionCodegenExtension.Companion.getInstances(state.getProject());
    if (!codegenExtensions.isEmpty()) {
        ExpressionCodegenExtension.Context context = new ExpressionCodegenExtension.Context(typeMapper, v);
        for (ExpressionCodegenExtension extension : codegenExtensions) {
            StackValue stackValue = extension.applyFunction(receiver, resolvedCall, context);
            if (stackValue != null)
                return stackValue;
        }
    }
    Callable callable = resolveToCallable(fd, superCallTarget != null, resolvedCall);
    return callable.invokeMethodWithArguments(resolvedCall, receiver, this);
}
Also used : BindingContext(org.jetbrains.kotlin.resolve.BindingContext) ExpressionCodegenExtension(org.jetbrains.kotlin.codegen.extensions.ExpressionCodegenExtension) ResolvedCallWithRealDescriptor(org.jetbrains.kotlin.codegen.coroutines.ResolvedCallWithRealDescriptor) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

NotNull (org.jetbrains.annotations.NotNull)1 ResolvedCallWithRealDescriptor (org.jetbrains.kotlin.codegen.coroutines.ResolvedCallWithRealDescriptor)1 ExpressionCodegenExtension (org.jetbrains.kotlin.codegen.extensions.ExpressionCodegenExtension)1 BindingContext (org.jetbrains.kotlin.resolve.BindingContext)1