Refactor JetTypeMapper.mapToCallableMethod parameters
Pass CodegenContext instead of two parameters that are always calculated by it and instead of the other one which is always OwnerKind.IMPLEMENTATION (except a single case where it was context.kind, but that case doesn't seem to matter)
This commit is contained in:
@@ -1774,7 +1774,6 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
boolean isStatic = containingDeclaration instanceof PackageFragmentDescriptor;
|
||||
boolean isSuper = superExpression != null;
|
||||
boolean isInsideClass = isCallInsideSameClassAsDeclared(propertyDescriptor, context);
|
||||
boolean isInsideModule = isCallInsideSameModuleAsDeclared(propertyDescriptor, context);
|
||||
|
||||
JetType delegateType = getPropertyDelegateType(propertyDescriptor, state.getBindingContext());
|
||||
boolean isDelegatedProperty = delegateType != null;
|
||||
@@ -1817,9 +1816,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
|
||||
PropertyGetterDescriptor getter = propertyDescriptor.getGetter();
|
||||
if (getter != null) {
|
||||
callableGetter = typeMapper.mapToCallableMethod(
|
||||
getter, isSuper || MethodKind.SYNTHETIC_ACCESSOR == methodKind, isInsideClass, isInsideModule,
|
||||
OwnerKind.IMPLEMENTATION);
|
||||
callableGetter = typeMapper.mapToCallableMethod(getter, isSuper || MethodKind.SYNTHETIC_ACCESSOR == methodKind, context);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1830,9 +1827,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
callableSetter = null;
|
||||
}
|
||||
else {
|
||||
callableSetter = typeMapper.mapToCallableMethod(
|
||||
setter, isSuper || MethodKind.SYNTHETIC_ACCESSOR == methodKind, isInsideClass, isInsideModule,
|
||||
OwnerKind.IMPLEMENTATION);
|
||||
callableSetter = typeMapper.mapToCallableMethod(setter, isSuper || MethodKind.SYNTHETIC_ACCESSOR == methodKind, context);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1844,7 +1839,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
propertyDescriptor = unwrapFakeOverride(propertyDescriptor);
|
||||
if (callableMethod == null) {
|
||||
owner = typeMapper.getOwner(isBackingFieldInAnotherClass ? propertyDescriptor.getContainingDeclaration() : propertyDescriptor,
|
||||
context.getContextKind(), isInsideModule);
|
||||
context.getContextKind(), isCallInsideSameModuleAsDeclared(propertyDescriptor, context));
|
||||
}
|
||||
else {
|
||||
owner = callableMethod.getOwner();
|
||||
@@ -2073,10 +2068,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
}
|
||||
else {
|
||||
SimpleFunctionDescriptor originalOfSamAdapter = (SimpleFunctionDescriptor) SamCodegenUtil.getOriginalIfSamAdapter(fd);
|
||||
return typeMapper.mapToCallableMethod(originalOfSamAdapter != null ? originalOfSamAdapter : fd, superCall,
|
||||
isCallInsideSameClassAsDeclared(fd, context),
|
||||
isCallInsideSameModuleAsDeclared(fd, context),
|
||||
OwnerKind.IMPLEMENTATION);
|
||||
return typeMapper.mapToCallableMethod(originalOfSamAdapter != null ? originalOfSamAdapter : fd, superCall, context);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -49,8 +49,6 @@ import java.util.*;
|
||||
|
||||
import static org.jetbrains.asm4.Opcodes.*;
|
||||
import static org.jetbrains.jet.codegen.AsmUtil.*;
|
||||
import static org.jetbrains.jet.codegen.CodegenUtil.isCallInsideSameClassAsDeclared;
|
||||
import static org.jetbrains.jet.codegen.CodegenUtil.isCallInsideSameModuleAsDeclared;
|
||||
import static org.jetbrains.jet.codegen.JvmSerializationBindings.*;
|
||||
import static org.jetbrains.jet.codegen.binding.CodegenBinding.asmTypeForAnonymousClass;
|
||||
import static org.jetbrains.jet.codegen.binding.CodegenBinding.isLocalNamedFun;
|
||||
@@ -610,11 +608,9 @@ public class FunctionCodegen extends ParentCodegenAwareImpl {
|
||||
|
||||
CallableMethod method;
|
||||
if (functionDescriptor instanceof ConstructorDescriptor) {
|
||||
method = state.getTypeMapper().mapToCallableMethod((ConstructorDescriptor) functionDescriptor);
|
||||
method = typeMapper.mapToCallableMethod((ConstructorDescriptor) functionDescriptor);
|
||||
} else {
|
||||
method = state.getTypeMapper()
|
||||
.mapToCallableMethod(functionDescriptor, false, isCallInsideSameClassAsDeclared(functionDescriptor, methodContext),
|
||||
isCallInsideSameModuleAsDeclared(functionDescriptor, methodContext), OwnerKind.IMPLEMENTATION);
|
||||
method = typeMapper.mapToCallableMethod(functionDescriptor, false, methodContext);
|
||||
}
|
||||
|
||||
iv.visitMethodInsn(method.getInvokeOpcode(), method.getOwner().getInternalName(), method.getSignature().getAsmMethod().getName(),
|
||||
|
||||
@@ -999,10 +999,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
boolean callFromAccessor = !JetTypeMapper.isAccessor(functionDescriptor);
|
||||
CallableMethod callableMethod = isConstructor ?
|
||||
typeMapper.mapToCallableMethod((ConstructorDescriptor) functionDescriptor) :
|
||||
typeMapper.mapToCallableMethod(functionDescriptor, callFromAccessor,
|
||||
isCallInsideSameClassAsDeclared(functionDescriptor, context),
|
||||
isCallInsideSameModuleAsDeclared(functionDescriptor, context),
|
||||
context.getContextKind());
|
||||
typeMapper.mapToCallableMethod(functionDescriptor, callFromAccessor, context);
|
||||
|
||||
Method method = callableMethod.getSignature().getAsmMethod();
|
||||
Type[] argTypes = method.getArgumentTypes();
|
||||
|
||||
@@ -24,6 +24,7 @@ import org.jetbrains.jet.codegen.*;
|
||||
import org.jetbrains.jet.codegen.binding.BindingTraceAware;
|
||||
import org.jetbrains.jet.codegen.binding.CalculatedClosure;
|
||||
import org.jetbrains.jet.codegen.binding.CodegenBinding;
|
||||
import org.jetbrains.jet.codegen.context.CodegenContext;
|
||||
import org.jetbrains.jet.codegen.signature.BothSignatureWriter;
|
||||
import org.jetbrains.jet.codegen.signature.JvmMethodParameterKind;
|
||||
import org.jetbrains.jet.codegen.signature.JvmMethodParameterSignature;
|
||||
@@ -399,15 +400,13 @@ public class JetTypeMapper extends BindingTraceAware {
|
||||
public CallableMethod mapToCallableMethod(
|
||||
@NotNull FunctionDescriptor functionDescriptor,
|
||||
boolean superCall,
|
||||
boolean isInsideClass,
|
||||
boolean isInsideModule,
|
||||
OwnerKind kind
|
||||
@NotNull CodegenContext<?> context
|
||||
) {
|
||||
DeclarationDescriptor functionParent = functionDescriptor.getOriginal().getContainingDeclaration();
|
||||
|
||||
functionDescriptor = unwrapFakeOverride(functionDescriptor.getOriginal());
|
||||
|
||||
JvmMethodSignature descriptor = mapSignature(functionDescriptor.getOriginal(), kind);
|
||||
JvmMethodSignature descriptor = mapSignature(functionDescriptor.getOriginal());
|
||||
Type owner;
|
||||
Type ownerForDefaultImpl;
|
||||
Type ownerForDefaultParam;
|
||||
@@ -428,12 +427,13 @@ public class JetTypeMapper extends BindingTraceAware {
|
||||
owner = asmTypeForAnonymousClass(bindingContext, functionDescriptor);
|
||||
ownerForDefaultImpl = ownerForDefaultParam = thisClass = owner;
|
||||
invokeOpcode = INVOKEVIRTUAL;
|
||||
descriptor = mapSignature(functionDescriptor, kind);
|
||||
descriptor = mapSignature(functionDescriptor);
|
||||
calleeType = owner;
|
||||
}
|
||||
else if (functionParent instanceof PackageFragmentDescriptor) {
|
||||
assert !superCall;
|
||||
owner = asmTypeForPackage((PackageFragmentDescriptor) functionParent, functionDescriptor, isInsideModule);
|
||||
owner = asmTypeForPackage((PackageFragmentDescriptor) functionParent, functionDescriptor,
|
||||
isCallInsideSameModuleAsDeclared(functionDescriptor, context));
|
||||
ownerForDefaultImpl = ownerForDefaultParam = owner;
|
||||
invokeOpcode = INVOKESTATIC;
|
||||
thisClass = null;
|
||||
@@ -460,8 +460,6 @@ public class JetTypeMapper extends BindingTraceAware {
|
||||
boolean originalIsInterface = isInterface(declarationOwner);
|
||||
boolean currentIsInterface = isInterface(currentOwner);
|
||||
|
||||
boolean isAccessor = isAccessor(functionDescriptor);
|
||||
|
||||
ClassDescriptor receiver;
|
||||
if (currentIsInterface && !originalIsInterface) {
|
||||
receiver = declarationOwner;
|
||||
@@ -483,11 +481,12 @@ public class JetTypeMapper extends BindingTraceAware {
|
||||
invokeOpcode = superCall ? INVOKESTATIC : INVOKEINTERFACE;
|
||||
}
|
||||
else {
|
||||
if (isAccessor) {
|
||||
if (isAccessor(functionDescriptor)) {
|
||||
invokeOpcode = INVOKESTATIC;
|
||||
}
|
||||
else {
|
||||
boolean isPrivateFunInvocation = isInsideClass && functionDescriptor.getVisibility() == Visibilities.PRIVATE;
|
||||
boolean isPrivateFunInvocation = isCallInsideSameClassAsDeclared(functionDescriptor, context) &&
|
||||
functionDescriptor.getVisibility() == Visibilities.PRIVATE;
|
||||
invokeOpcode = superCall || isPrivateFunInvocation ? INVOKESPECIAL : INVOKEVIRTUAL;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user