Refactoring, unified closures generation
This commit is contained in:
committed by
Andrey Breslav
parent
45ca14345f
commit
6d6d6fadc1
@@ -1328,9 +1328,22 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
|||||||
FunctionDescriptor descriptor = bindingContext.get(FUNCTION, declaration);
|
FunctionDescriptor descriptor = bindingContext.get(FUNCTION, declaration);
|
||||||
assert descriptor != null : "Function is not resolved to descriptor: " + declaration.getText();
|
assert descriptor != null : "Function is not resolved to descriptor: " + declaration.getText();
|
||||||
|
|
||||||
|
return genClosure(
|
||||||
|
declaration, descriptor, new FunctionGenerationStrategy.FunctionDefault(state, descriptor, declaration), samType, kind
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
private StackValue genClosure(
|
||||||
|
@NotNull PsiElement declaration,
|
||||||
|
@NotNull FunctionDescriptor descriptor,
|
||||||
|
@NotNull FunctionGenerationStrategy strategy,
|
||||||
|
@Nullable SamType samType,
|
||||||
|
@NotNull KotlinSyntheticClass.Kind kind
|
||||||
|
) {
|
||||||
ClosureCodegen closureCodegen = new ClosureCodegen(
|
ClosureCodegen closureCodegen = new ClosureCodegen(
|
||||||
state, declaration, descriptor, samType, context, kind, this,
|
state, declaration, descriptor, samType, context, kind, this,
|
||||||
new FunctionGenerationStrategy.FunctionDefault(state, descriptor, declaration), parentCodegen
|
strategy, parentCodegen
|
||||||
);
|
);
|
||||||
closureCodegen.gen();
|
closureCodegen.gen();
|
||||||
|
|
||||||
@@ -2492,11 +2505,8 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
|||||||
FunctionDescriptor functionDescriptor = bindingContext.get(FUNCTION, expression);
|
FunctionDescriptor functionDescriptor = bindingContext.get(FUNCTION, expression);
|
||||||
if (functionDescriptor != null) {
|
if (functionDescriptor != null) {
|
||||||
CallableReferenceGenerationStrategy strategy = new CallableReferenceGenerationStrategy(state, functionDescriptor, resolvedCall);
|
CallableReferenceGenerationStrategy strategy = new CallableReferenceGenerationStrategy(state, functionDescriptor, resolvedCall);
|
||||||
ClosureCodegen closureCodegen = new ClosureCodegen(state, expression, functionDescriptor, null, context,
|
|
||||||
KotlinSyntheticClass.Kind.CALLABLE_REFERENCE_WRAPPER,
|
return genClosure(expression, functionDescriptor, strategy, null, KotlinSyntheticClass.Kind.CALLABLE_REFERENCE_WRAPPER);
|
||||||
this, strategy, getParentCodegen());
|
|
||||||
closureCodegen.gen();
|
|
||||||
return closureCodegen.putInstanceOnStack(v, this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
VariableDescriptor variableDescriptor = bindingContext.get(VARIABLE, expression);
|
VariableDescriptor variableDescriptor = bindingContext.get(VARIABLE, expression);
|
||||||
|
|||||||
Reference in New Issue
Block a user