Refactoring: remove 'call' argument
when it can be taken from resolved call
This commit is contained in:
@@ -44,7 +44,6 @@ import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContextUtils;
|
||||
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
|
||||
import org.jetbrains.jet.lang.resolve.bindingContextUtil.BindingContextUtilPackage;
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.*;
|
||||
import org.jetbrains.jet.lang.resolve.calls.util.CallMaker;
|
||||
import org.jetbrains.jet.lang.resolve.constants.CompileTimeConstant;
|
||||
@@ -615,7 +614,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
ResolvedCall<FunctionDescriptor> resolvedCall = bindingContext.get(COMPONENT_RESOLVED_CALL, variableDeclaration);
|
||||
assert resolvedCall != null : "Resolved call is null for " + variableDeclaration.getText();
|
||||
Call call = makeFakeCall(new TransientReceiver(elementType));
|
||||
invokeFunction(call, StackValue.local(loopParameterVar, asmElementType), resolvedCall);
|
||||
invokeFunction(call, resolvedCall, StackValue.local(loopParameterVar, asmElementType));
|
||||
|
||||
v.store(componentVarIndex, componentAsmType);
|
||||
}
|
||||
@@ -702,8 +701,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
|
||||
iteratorVarIndex = createLoopTempVariable(asmTypeForIterator);
|
||||
|
||||
Call call = bindingContext.get(LOOP_RANGE_ITERATOR_CALL, forExpression.getLoopRange());
|
||||
invokeFunction(call, StackValue.none(), iteratorCall);
|
||||
invokeFunction(iteratorCall, StackValue.none());
|
||||
v.store(iteratorVarIndex, asmTypeForIterator);
|
||||
}
|
||||
|
||||
@@ -720,7 +718,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
LOOP_RANGE_HAS_NEXT_RESOLVED_CALL, loopRange,
|
||||
"No hasNext() function " + DiagnosticUtils.atLocation(loopRange));
|
||||
@SuppressWarnings("ConstantConditions") Call fakeCall = makeFakeCall(new TransientReceiver(iteratorCall.getResultingDescriptor().getReturnType()));
|
||||
invokeFunction(fakeCall, StackValue.local(iteratorVarIndex, asmTypeForIterator), hasNextCall);
|
||||
invokeFunction(fakeCall, hasNextCall, StackValue.local(iteratorVarIndex, asmTypeForIterator));
|
||||
|
||||
JetType type = hasNextCall.getResultingDescriptor().getReturnType();
|
||||
assert type != null && JetTypeChecker.DEFAULT.isSubtypeOf(type, KotlinBuiltIns.getInstance().getBooleanType());
|
||||
@@ -734,7 +732,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
protected void assignToLoopParameter() {
|
||||
@SuppressWarnings("ConstantConditions") Call fakeCall =
|
||||
makeFakeCall(new TransientReceiver(iteratorCall.getResultingDescriptor().getReturnType()));
|
||||
invokeFunction(fakeCall, StackValue.local(iteratorVarIndex, asmTypeForIterator), nextCall);
|
||||
invokeFunction(fakeCall, nextCall, StackValue.local(iteratorVarIndex, asmTypeForIterator));
|
||||
//noinspection ConstantConditions
|
||||
v.store(loopParameterVar, asmType(nextCall.getResultingDescriptor().getReturnType()));
|
||||
}
|
||||
@@ -1941,7 +1939,6 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
return generateNewCall(expression, resolvedCall, receiver);
|
||||
}
|
||||
|
||||
Call call = getCall(expression, bindingContext);
|
||||
if (funDescriptor.getOriginal() instanceof SamConstructorDescriptor) {
|
||||
//noinspection ConstantConditions
|
||||
SamType samType = SamType.create(funDescriptor.getReturnType());
|
||||
@@ -1949,7 +1946,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
return invokeSamConstructor(expression, resolvedCall, samType);
|
||||
}
|
||||
|
||||
return invokeFunction(call, receiver, resolvedCall);
|
||||
return invokeFunction(resolvedCall, receiver);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -2024,9 +2021,14 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public StackValue invokeFunction(Call call, StackValue receiver, ResolvedCall<?> resolvedCall) {
|
||||
public StackValue invokeFunction(@NotNull ResolvedCall<?> resolvedCall, @NotNull StackValue receiver) {
|
||||
return invokeFunction(resolvedCall.getCall(), resolvedCall, receiver);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public StackValue invokeFunction(@NotNull Call call, @NotNull ResolvedCall<?> resolvedCall, @NotNull StackValue receiver) {
|
||||
if (resolvedCall instanceof VariableAsFunctionResolvedCall) {
|
||||
return invokeFunction(call, receiver, ((VariableAsFunctionResolvedCall) resolvedCall).getFunctionCall());
|
||||
return invokeFunction(call, ((VariableAsFunctionResolvedCall) resolvedCall).getFunctionCall(), receiver);
|
||||
}
|
||||
|
||||
FunctionDescriptor fd = (FunctionDescriptor) resolvedCall.getResultingDescriptor();
|
||||
@@ -2602,7 +2604,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
}
|
||||
else {
|
||||
Call call = CallMaker.makeCall(fakeExpression, NO_RECEIVER, null, fakeExpression, fakeArguments);
|
||||
result = codegen.invokeFunction(call, StackValue.none(), fakeResolvedCall);
|
||||
result = codegen.invokeFunction(call, fakeResolvedCall, StackValue.none());
|
||||
}
|
||||
|
||||
InstructionAdapter v = codegen.v;
|
||||
@@ -2735,8 +2737,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
return StackValue.onStack(returnType);
|
||||
}
|
||||
|
||||
Call call = getCall(reference, bindingContext);
|
||||
return invokeFunction(call, receiver, resolvedCall);
|
||||
return invokeFunction(resolvedCall, receiver);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2747,7 +2748,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
}
|
||||
else {
|
||||
ResolvedCall<? extends CallableDescriptor> resolvedCall = getResolvedCallWithAssert(operationReference, bindingContext);
|
||||
invokeFunction(resolvedCall.getCall(), StackValue.none(), resolvedCall);
|
||||
invokeFunction(resolvedCall, StackValue.none());
|
||||
}
|
||||
if (operationReference.getReferencedNameElementType() == JetTokens.NOT_IN) {
|
||||
genInvertBoolean(v);
|
||||
@@ -2929,8 +2930,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
gen(right, type);
|
||||
}
|
||||
else {
|
||||
Call call = getCall(expression, bindingContext);
|
||||
StackValue result = invokeFunction(call, receiver, resolvedCall);
|
||||
StackValue result = invokeFunction(resolvedCall, receiver);
|
||||
type = Type.INT_TYPE;
|
||||
result.put(type, v);
|
||||
v.iconst(0);
|
||||
@@ -3053,7 +3053,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
ResolvedCall<?> resolvedCall = getResolvedCallWithAssert(expression, bindingContext);
|
||||
|
||||
if (isPrimitiveNumberClassDescriptor(cls) || !(op.getName().asString().equals("inc") || op.getName().asString().equals("dec"))) {
|
||||
return invokeFunction(resolvedCall.getCall(), receiver, resolvedCall);
|
||||
return invokeFunction(resolvedCall, receiver);
|
||||
}
|
||||
|
||||
CallableMethod callableMethod = (CallableMethod) callable;
|
||||
@@ -3213,7 +3213,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
ResolvedCall<FunctionDescriptor> resolvedCall = bindingContext.get(COMPONENT_RESOLVED_CALL, variableDeclaration);
|
||||
assert resolvedCall != null : "Resolved call is null for " + variableDeclaration.getText();
|
||||
Call call = makeFakeCall(initializerAsReceiver);
|
||||
invokeFunction(call, local, resolvedCall);
|
||||
invokeFunction(call, resolvedCall, local);
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -384,9 +384,7 @@ public class PropertyCodegen {
|
||||
BindingContext bindingContext = state.getBindingContext();
|
||||
ResolvedCall<FunctionDescriptor> resolvedCall =
|
||||
bindingContext.get(BindingContext.DELEGATED_PROPERTY_RESOLVED_CALL, callableDescriptor);
|
||||
|
||||
Call call = bindingContext.get(BindingContext.DELEGATED_PROPERTY_CALL, callableDescriptor);
|
||||
assert call != null : "Call should be recorded for delegate call " + signature.toString();
|
||||
assert resolvedCall != null : "Resolve call should be recorded for delegate call " + signature.toString();
|
||||
|
||||
if (codegen.getContext().getContextKind() != OwnerKind.PACKAGE) {
|
||||
v.load(0, OBJECT_TYPE);
|
||||
@@ -405,7 +403,7 @@ public class PropertyCodegen {
|
||||
}
|
||||
|
||||
codegen.tempVariables.put(
|
||||
call.getValueArguments().get(1).asElement(),
|
||||
resolvedCall.getCall().getValueArguments().get(1).asElement(),
|
||||
new StackValue(PROPERTY_METADATA_TYPE) {
|
||||
@Override
|
||||
public void put(Type type, InstructionAdapter v) {
|
||||
@@ -417,7 +415,7 @@ public class PropertyCodegen {
|
||||
);
|
||||
|
||||
StackValue delegatedProperty = codegen.intermediateValueForProperty(callableDescriptor.getCorrespondingProperty(), true, null);
|
||||
StackValue lastValue = codegen.invokeFunction(call, delegatedProperty, resolvedCall);
|
||||
StackValue lastValue = codegen.invokeFunction(resolvedCall, delegatedProperty);
|
||||
|
||||
Type asmType = signature.getReturnType();
|
||||
lastValue.put(asmType, v);
|
||||
|
||||
@@ -100,7 +100,6 @@ public interface BindingContext {
|
||||
WritableSlice<JetExpression, DelegatingBindingTrace> TRACE_DELTAS_CACHE = Slices.createSimpleSlice();
|
||||
|
||||
WritableSlice<JetExpression, ResolvedCall<FunctionDescriptor>> LOOP_RANGE_ITERATOR_RESOLVED_CALL = Slices.createSimpleSlice();
|
||||
WritableSlice<JetExpression, Call> LOOP_RANGE_ITERATOR_CALL = Slices.createSimpleSlice();
|
||||
|
||||
WritableSlice<JetExpression, ResolvedCall<FunctionDescriptor>> LOOP_RANGE_HAS_NEXT_RESOLVED_CALL = Slices.createSimpleSlice();
|
||||
WritableSlice<JetExpression, ResolvedCall<FunctionDescriptor>> LOOP_RANGE_NEXT_RESOLVED_CALL = Slices.createSimpleSlice();
|
||||
|
||||
-1
@@ -93,7 +93,6 @@ public class ForLoopConventionsChecker {
|
||||
if (iteratorResolutionResults.isSuccess()) {
|
||||
ResolvedCall<FunctionDescriptor> iteratorResolvedCall = iteratorResolutionResults.getResultingCall();
|
||||
context.trace.record(LOOP_RANGE_ITERATOR_RESOLVED_CALL, loopRangeExpression, iteratorResolvedCall);
|
||||
context.trace.record(LOOP_RANGE_ITERATOR_CALL, loopRangeExpression, iteratorCall);
|
||||
|
||||
FunctionDescriptor iteratorFunction = iteratorResolvedCall.getResultingDescriptor();
|
||||
JetType iteratorType = iteratorFunction.getReturnType();
|
||||
|
||||
Reference in New Issue
Block a user